@@ -280,14 +280,15 @@ The attribute [transition-strictness] is used as transition attribute for testin
280280This is a rule that may lead to unexpected nondeterminism if it is wrongly implemented.
281281In order to expose incorrect nondeterminism we need to model-check a program that exposes the nondeterminism.
282282*/
283- rule [elabHeatDefault ]:
283+ rule [elabHeat-default ]:
284284 (. => elab(K)) ~> elab(KL:KLabel(HeadKs:KList,, (K:K => CHOLE),, TailKs:KList))
285285when
286286 defaultElabChildren(KL)
287287 //notBool customElabChildren(KL)
288288 andBool notBool isElab(K)
289+ andBool notBool isElabNaked(K)
289290 andBool isElab(HeadKs) //Forces elaboration left-to-right. Required when KL == 'ListWrap of statements.
290- [transition-strictness]
291+ [transition-strictness]
291292
292293rule [elabCool-default]:
293294 (ElabK:K => .) ~> elab(_:KLabel(_,, (CHOLE => ElabK),, _))
@@ -460,11 +461,11 @@ rule defaultElabChildren(KL:KLabel) =>
460461 orBool (KL ==KLabel ' Throw)
461462 orBool (KL ==KLabel 'Synchronized)
462463 orBool (KL ==KLabel ' Try)
463- // orBool (KL ==KLabel 'Catch)
464- // orBool (KL ==KLabel ' LocalVarDecStm)
465- // orBool (KL ==KLabel 'LocalVarDec)
466- // orBool (KL ==KLabel ' Block)
467- // orBool (KL ==KLabel 'ClassDecStm)
464+ /* orBool (KL ==KLabel 'Catch)
465+ orBool (KL ==KLabel ' LocalVarDecStm)
466+ orBool (KL ==KLabel 'LocalVarDec)
467+ orBool (KL ==KLabel ' Block)
468+ orBool (KL ==KLabel 'ClassDecStm)*/
468469 /*orBool (KL ==KLabel ' MethodDec)
469470 orBool (KL ==KLabel 'MethodDecHead)
470471 orBool (KL ==KLabel ' DeprMethodDecHead)
@@ -494,8 +495,8 @@ rule defaultElabChildren(KL:KLabel) =>
494495// orBool (KL ==KLabel 'TypeName)
495496 orBool (KL ==KLabel ' ExprName)
496497
497- orBool auxLabelInElab(KL)
498498 orBool (KL ==KLabel 'MethodName)
499+ orBool auxLabelInElab(KL)
499500 /*orBool (KL ==KLabel ' PackageOrTypeName)
500501 orBool (KL ==KLabel 'TypeArgs)
501502 orBool (KL ==KLabel ' TypeArgs)
@@ -546,8 +547,18 @@ rule auxLabelInElab(KL:KLabel) =>
546547 orBool KL ==KLabel 'stmtAndExp`(_`,_`)
547548 orBool KL ==KLabel ' toString`(_`)
548549
549- /*@ Represents terms that shoud never be wrapped by elab() or related wrappers. They are processed to their final state
550- in elaboration phase. Those are types names, package names, id's ad literals.
550+ /*@ elabHeat-naked-children
551+ Since a naked term is always computed int oa KResult during elaboration,
552+ we can use a simple context rule to heat such terms.
553+ */
554+ context elab(KL:KLabel(_:KList,, HOLE,, _:KList))
555+ when
556+ defaultElabChildren(KL)
557+ andBool isElabNaked(HOLE)
558+
559+ /*@ Naked terms are those that should be computed directly into KResult during elaboration.
560+ Those are literals, types and packages. They are heated "as is" , without being wrapped into elab().
561+ An exception is the class literal that is not executed during elaboration.
551562*/
552563syntax K ::= "isElabNaked" "(" K ")" [function]
553564rule isElabNaked(K:K) =>
@@ -561,15 +572,10 @@ rule isElabNaked(K:K) =>
561572 orBool (getKLabel(K) ==KLabel ' PackageName)
562573 orBool (getKLabel(K) ==KLabel 'PackageOrTypeName)
563574 orBool (getKLabel(K) ==KLabel ' Id)
564- orBool (getKLabel(K) ==KLabel ' Lit)
575+ orBool (getKLabel(K) ==KLabel 'Lit andBool getInnerKLabel(K) =/=KLabel ' Class )
565576
566- /*@ The sole place where isElabNaked is used - naked terms should be automatically unwrapped from elab() wrapper.
567- Will not match .K - is not isElabNaked. (.K) is matched by [elabDotK].
568- */
569- rule [unwrapElabNaked]:
570- elab(K:K) => K
571- when
572- isElabNaked(K)
577+ syntax KLabel ::= "getInnerKLabel" "(" K ")" [function]
578+ rule getInnerKLabel(_:KLabel(KL:KLabel(_))) => KL
573579
574580/*@ The default algorithm of transforming the term from elab to elabRes, when the children were completely elaborated.
575581 Deletes elabRes wrappers from children. This algorithm is activated when the following conditions apply:
@@ -1238,13 +1244,15 @@ rule [elab-QNewInstance]:
12381244rule [elabInstanceOf]:
12391245 elabDispose(' InstanceOf(TE:TypedExp,, RT2 :RefType)) => elabRes('InstanceOf(TE,, RT2) :: bool)
12401246
1241- context ' Lit('Class(HOLE))
1247+ //@ Class literal types are heated by this rule.
1248+ context elab(' Lit('Class(HOLE)))
12421249
12431250rule [elabLitClass]:
1244- ' Lit('Class(T:Type)) => elabRes(' Lit('Class(T:Type)) :: class String2Id("java.lang.Class"))
1251+ elab( ' Lit('Class(T:Type) )) => elabRes(' Lit('Class(T:Type)) :: class String2Id("java.lang.Class"))
12451252
12461253rule [elabArrayAccess]:
1247- elabDispose(' ArrayAccess(TargetExp:K::arrayOf T:Type,, IndexTE:TypedExp)) => elabRes('ArrayAccess(TargetExp::arrayOf T,, IndexTE) :: T)
1254+ elabDispose(' ArrayAccess(TargetExp:K::arrayOf T:Type,, IndexTE:TypedExp))
1255+ => elabRes('ArrayAccess(TargetExp::arrayOf T,, IndexTE) :: T)
12481256
12491257rule [elabArrayLength]:
12501258 elabDispose(' Field(Qual:K :: arrayOf T:Type,, X:Id))
0 commit comments