#95 closed defect (fixed)
Undestroyed global objects
Reported by: | jlaybar | Owned by: | danirus |
---|---|---|---|
Priority: | highest | Milestone: | |
Component: | DataBase | Version: | head |
Severity: | critical | Keywords: | |
Cc: |
Description
Hello
When I compile this code for the second time TOL can´t decompile the variables
which are in memory. I would like to know why?
Cheers
Real fun2( Matrix a, Matrix b )
{
Real c = Rows(a);
Real d = Rows(b);
Real out = And(c==d);
Text If (out , WriteLn("ERROR: TOL No descarga memoria!!!"));
out
};
Matrix fun1(Matrix a, Matrix b)
{
Real fun2(a,b);
a
};
Matrix a = Col(0,0);
Matrix b = Col(1,1);
Matrix out = fun1(a,b);
Change History (7)
comment:1 Changed 21 years ago by
comment:2 Changed 21 years ago by
Owner: | changed from manuelb to danirus |
---|
When marking bug #94 as duplicate, bugzilla has assigned me this one too for
some reason (Bugzilla bug?). Reassign to it's owner.
comment:3 Changed 21 years ago by
Status: | new → assigned |
---|
comment:4 Changed 21 years ago by
Priority: | normal → highest |
---|---|
Severity: | normal → critical |
This bug is so important.
I change its Priority and Severity.
comment:5 Changed 21 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
This bug has been too slippery but finally has been resolved.
In order to understand this bug we must define two cases with a common code.
First case fails but the second works.
_
Common tol code:
Real x = 1;
Real fCommon (Real p) { Real out = p+p; out };
_
First case:
Real f1 (Real p1) { Real fCommon(p1); p1 };
Real res = f1(x);
Now decompile (F9);
WriteLn(FormatReal(x));
_
Second case:
Real f2(Real p2) { Real ret = fCommon(p2); ret };
Real res = f2(x);
Now decompile (F9);
WriteLn(FormatReal(x));
In "first case", the first sentence of function f1 creates an orphan Tol Object,
because it's never joined with a declared object (with an assignment
expression), as such as happens in f2 function, where "Real ret" is a valid
declared object that receive their value from an assignment operator.
When we evaluate a sentence like that ("Real someFunction (someParam);") Tol
creates something like a Zombi object. This object will never be pushed in the
stack where all Tol objects of a local scope must be.
Solution (Development info):
Function Evaluate (in graimp.cpp) requires a little piece of code two push zombi
objects (also called orphan objects) into the stack_. A new static BText
function must be developed to get a new name for each zombi object in the stack.
After this bug I am hungry.
comment:6 Changed 21 years ago by
The solution has been improved by reducing the changes.
A Zombi object created in all local scopes can be correctly removed as a Renamed
Object without name just after their evaluation.
For this reason the changes in class BText will be no longer needed, and the
stack no needs references to zombi objects.
comment:7 Changed 21 years ago by
Improving the behavior and trying to support some specific features already in
use, I've been doing some changes to get the name of the last object evaluated
at exit time in a function.
The aim is to support code like this, where two last sentence creates two
Series. The second receives its name from the first parameter:
Anything MakeAnyGlobal(Anything object, Text name) {
Text grammar = Grammar(object);
Eval(grammar + " a = object;");
Real PutName(name, a);
Real Msg("MakeAnyGlobal", name);
Eval("MakeGlobal("+name+")")
};
PutDescription("Convierte un objeto cualquiera a global", MakeAnyGlobal);
Serie SqlAlgGetData(Text name, Serie ser) {
Serie If (ObjectExist("Serie",name),
Eval(name) ,
{ Anything MakeAnyGlobal(ser,name) }
)
};
PutDescription(" Devuelve una serie con los datos a analizar a partir del codigo
del output .",SqlAlgGetData);
Serie ser = SubSer(Trend(y2000m01d01, Mensual),y2000m01d01,y2000m12d01);
Serie SqlAlgGetData("otraSerie",ser);
* Bug 94 has been marked as a duplicate of this bug. *