28.01.2015 Views

Hermes: A Tutorial and Reference Manual - Researcher - IBM

Hermes: A Tutorial and Reference Manual - Researcher - IBM

Hermes: A Tutorial and Reference Manual - Researcher - IBM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Typestatecheckingassignsatypestatetoeachprogrampoint.Atypestate 10 TypestateChecking isamathematicalobjectwhichcanbeinterpretedintwoways:(1)asan assertionthatcertainpropertiesofprogramvariableswillbetruewheneverthatstatementisexecuted;(2)asapointinasemilattice1.Because<br />

by<strong>Hermes</strong>.Wewilldescribethetypestatecheckingalgorithmweuse.We dataowanalysiscanbeused. certainlanguagerulesexpressedintermsofthoseassertionsaresatised. Becausetypestatesformasemilattice,certainwell-knownalgorithmsfrom willtellyouhowtoreadthetablewhichdenestheparticulartypestate rulesforeachoperation. 10.1SyntaxofTypestates Inthissection,wewilldiscusstheparticulartypestatesemilatticeused typestatesareassertions,theycanbeusedtocheckatcompile-timethat<br />

Typestatesareexplicitlywritteninthefollowingsituations:(1)ininterfacedenitions(inputports,callmessages,<strong>and</strong>constraints),(2)intable<strong>and</strong><br />

variantdenitionstoindicatewhattypestateanelementorvariantcomponentmusthave,(3)intheunwrapstatement,toindicatewhattypestate<br />

apolymorphmusthave. enclosedincurlybraces.Anattributeisanattributenamefollowedbya listofvariablenamescalledattributearguments. Atypestateiswrittenasasetofattributesseparatedbycommas<strong>and</strong><br />

dened. Y)Ṫhefollowingattributenamesarebuilt-in:init,case,checked<strong>and</strong> checkeddefinitions.Constraintattributes,likegreaterthan,areuser-<br />

Examplesofattributes:init(X.A),case(V,V.A),greaterthan(X, typestate::=f[attribute[,attribute]...]g<br />

initmusthaveasingleargument,<strong>and</strong>casemusthaveexactlytwoargu- Theargumentsofbuiltinattributesarecheckedasfollows:Attribute attribute::=attribute{nameattribute{arguments<br />

tt1;tt2<strong>and</strong>foranyt0,(t0t1^t0t2))(t0t). ofelementst1<strong>and</strong>t2haveauniquegreatestlowerboundormeettsuchthat 1Asemilatticeisasetwithapartialorderrelationshipsuchthatanypair

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!