Hi
In the JModelica.org compiler, we have a circular attribute InstDot.myInstClassDecl() that under certain circumstances gives strange results. (I have a test case that provokes it, but it is a complicated one.) I think that this is a bug in JastAdd.
The attribute in question is lazy and circular. When the bug occurs, then:
* myInstClassDecl _computed = false
* myInstClassDecl _initialized = false
* myInstClassDecl_visited = -1
* in$Circle = false
* is$Final = true
* result of state() looks like ("Copy Variables" in Eclipse debug):
state ASTNode$State (id=1360)
boundariesCrossed 0 [0x0]
CHANGE false
CIRCLE_INDEX 1053 [0x41d]
circularEvalSet LinkedHashSet<E> (id=1362)
circularEvalStack Stack<E> (id=1369)
capacityIncrement 0 [0x0]
elementCount 4 [0x4]
elementData Object[10] (id=1385)
[0] ASTNode$State$CircularStackEntry (id=1386)
[1] ASTNode$State$CircularStackEntry (id=1387)
[2] ASTNode$State$CircularStackEntry (id=1388)
[3] ASTNode$State$CircularStackEntry (id=1389)
[4] null
...
modCount 63576 [0xf858]
duringConnections 0 [0x0]
duringFlatTypeAnalysis 0 [0x0]
duringInitialTransformations 0 [0x0]
duringInstFunctionBinding 0 [0x0]
duringInstNameClassification 0 [0x0]
duringPredefinedTypes 0 [0x0]
duringScalarization 0 [0x0]
duringTransformCanonical 0 [0x0]
IN_CIRCLE true
LAST_CYCLE true
pos 0 [0x0]
RESET_CYCLE false
stack (id=1402)
This leads to the following code being executed:
if (!myInstClassDecl_initialized) {
myInstClassDecl_initialized = true;
myInstClassDecl_value = unknownInstClassDecl();
}
if (!state.IN_CIRCLE) {
// This is not executed
}
if(myInstClassDecl_visited != state.CIRCLE_INDEX) {
myInstClassDecl_visited = state.CIRCLE_INDEX;
if (state.LAST_CYCLE) {
myInstClassDecl_computed = true;
return myInstClassDecl_compute();
}
Thus myInstClassDecl_value is set to the initialization value, myInstClassDecl _computed is set to true, and the correct value is calculated and returned, but never saved in myInstClassDecl_value.
The next time myInstClassDecl() is called (right after the first call, due to being called from a circular attribute), then the initialization value is returned immediately.
That's all the information I can think of - anything else?
Jesper
Jesper MATTSSON, MSc
Software Developer & IT Administrator
Phone direct: +46 73 324 5909
Email: jesper.mattsson_at_modelon.com<mailto:jesper.mattsson_at_modelon.com>
[cid:image001.png_at_01CCC938.A149C660]
________________________________
Modelon AB
Ideon Science Park
SE-223 70 Lund, Sweden
Phone: +46 46 286 2200
Fax: +46 46 286 2201
Web:
http://www.modelon.com<
http://www.modelon.com/>
Received on Mon Jan 02 2012 - 11:02:51 CET