Update of /cvsroot/monetdb/MonetDB5/src/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3360

Modified Files:
        mal_box.mx mal_builder.mx mal_debugger.mx mal_factory.mx 
        mal_function.mx mal_instruction.mx mal_interpreter.mx 
        mal_parser.mx mal_profiler.mx mal_resolve.mx mal_session.mx 
Log Message:
This is the first of a large collection of source updates, which still
render both M5 kernel and SQL unstable (6 and 55 tests respectively).
Also leakage tests should be redone.

The changes are geared at reducing the storage cost of variable records
by using bit-flags instead of char fields. It reduces the storage from 64
down to 40. Likewise a reshuffling in InstrPtr saved some space.
In passing, the naming of the functions dealing with them have been cleaned
and stratified.

A related issue is that Lifespan analysis has been separated out, 
to save space and since it is only needed by a limited number of optimizers.

All this on top of some fixes to static MAL code analysis. It is more strict
on variable initialization before use. Performancewise it should be a little
faster as well.


Index: mal_parser.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_parser.mx,v
retrieving revision 1.208
retrieving revision 1.209
diff -u -d -r1.208 -r1.209
--- mal_parser.mx       30 Dec 2007 18:21:13 -0000      1.208
+++ mal_parser.mx       2 Jan 2008 08:18:52 -0000       1.209
@@ -1430,7 +1430,7 @@
                        }
                        @:GETvariable@
                        if( currChar(cntxt)==':') {
-                               freezeVarType(curBlk,varid);
+                               setVarUDFtype(curBlk,varid);
                                type = typeElm(cntxt,getVarType(curBlk,varid));
                                setPolymorphic(curInstr, type, FALSE); 
                                setVarType(curBlk,varid,type);
@@ -1480,7 +1480,7 @@
                @:GETvariable@
                if( !(currChar(cntxt)==':' && CURRENT(cntxt)[1]=='=') ){
                        if( currChar(cntxt)==':') {
-                               freezeVarType(curBlk,varid);
+                               setVarUDFtype(curBlk,varid);
                                type = typeElm(cntxt,getVarType(curBlk,varid));
                                setPolymorphic(curInstr, type, FALSE);
                                setVarType(curBlk,varid,type);
@@ -1532,11 +1532,11 @@
                        if( currChar(cntxt)==':') {
                                csttpe = 
typeElm(cntxt,getVarType(curBlk,cstidx));
                                if(csttpe == getVarType(curBlk,cstidx) ){
-                                       freezeVarType(curBlk,cstidx);
+                                       setVarUDFtype(curBlk,cstidx);
                                } else {
                                        cstidx = 
defConstant(curBlk,csttpe,&cst);
                                        setPolymorphic(curInstr,csttpe, FALSE);
-                                       freezeVarType(curBlk,cstidx);
+                                       setVarUDFtype(curBlk,cstidx);
                                        free = 0;
                                }
                        } else if( cst.vtype != getVarType(curBlk,cstidx)){
@@ -1558,7 +1558,7 @@
                        cstidx = defConstant(curBlk,csttpe,&cst);
                        setPolymorphic(curInstr,csttpe, FALSE);
                        if( flag )
-                               freezeVarType(curBlk,cstidx);
+                               setVarUDFtype(curBlk,cstidx);
                        curInstr = pushArgument(curBlk,curInstr,cstidx);
                        @1;
                }
@@ -1727,9 +1727,8 @@
                                cst.len = strlen(start);
                                cst.val.sval= GDKstrdup(start);
                                getArg(curInstr,0)= defConstant(curBlk, 
TYPE_str,&cst);
-                               /* mark the constant for not being copied to 
the stack */
-                               isConstant(curBlk,getArg(curInstr,0)) = 
-                                               
-isConstant(curBlk,getArg(curInstr,0));
+                               clrVarConstant(curBlk, getArg(curInstr,0));
+                               setVarDisabled(curBlk, getArg(curInstr,0));
                                pushInstruction(curBlk,curInstr);
                        }
                        echoInput(cntxt);

Index: mal_factory.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_factory.mx,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- mal_factory.mx      25 Dec 2007 13:08:47 -0000      1.71
+++ mal_factory.mx      2 Jan 2008 08:18:51 -0000       1.72
@@ -432,9 +432,9 @@
                stk->cmd= flag;
                /* initialize the stack */
                for(i= psig->argc; i< mb->vtop; i++)
-               if( isConstant(mb,i) > 0 ){
+               if( isVarConstant(mb,i) > 0 ){
                        lhs = &stk->stk[i];
-                       rhs = &getConstant(mb,i);
+                       rhs = &getVarConstant(mb,i);
                        VALcopy(lhs,rhs);
                } else {
                        lhs = &stk->stk[i];

Index: mal_box.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_box.mx,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- mal_box.mx  30 Nov 2007 12:36:02 -0000      1.81
+++ mal_box.mx  2 Jan 2008 08:18:51 -0000       1.82
@@ -740,7 +740,7 @@
 void
 printBox(stream *fd, Box obj)
 {
-       printStack(fd, obj->sym, obj->val,0);
+       printStack(fd, obj->sym, obj->val);
 }
 
 void

Index: mal_function.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_function.mx,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -d -r1.147 -r1.148
--- mal_function.mx     9 Dec 2007 16:21:05 -0000       1.147
+++ mal_function.mx     2 Jan 2008 08:18:51 -0000       1.148
@@ -57,6 +57,14 @@
 #include "mal_module.h"
 #include "mal_resolve.h"
 
+typedef struct{
+       short beginLifespan, endLifespan, lastUpdate;
+}*Lifespan, LifespanRecord;
+
+#define getLastUpdate(L,I)     (L[I].lastUpdate)
+#define getEndLifespan(L,I)    (L[I].endLifespan)
+#define getBeginLifespan(L,I)  (L[I].beginLifespan)
+
 /* #define DEBUG_MAL_FCN */
 /* #define DEBUG_CLONE */
 
@@ -70,13 +78,16 @@
 
 mal_export Symbol   getFunctionSymbol(Module scope, InstrPtr p);
 mal_export void chkFlow(MalBlkPtr mb);
-mal_export void chkDeclarations(MalBlkPtr mb,int reset);
+mal_export void chkDeclarations(MalBlkPtr mb);
+mal_export void clrDeclarations(MalBlkPtr mb);
 mal_export int getBarrierEnvelop(MalBlkPtr mb);
 mal_export int isLoopBarrier(MalBlkPtr mb, int pc);
 mal_export int getBlockExit(MalBlkPtr mb,int pc);
 mal_export int getBlockBegin(MalBlkPtr mb,int pc);
-mal_export void setLifespan(MalBlkPtr mb);
-mal_export void debugLifespan(MalBlkPtr mb);
+
+#define newLifespan(M) (Lifespan)GDKmalloc(sizeof(LifespanRecord)*(M)->vtop)
+mal_export void setLifespan(MalBlkPtr mb, Lifespan span);
+mal_export void debugLifespan(MalBlkPtr mb, Lifespan span);
 
 mal_export void printFunction(stream *fd, MalBlkPtr mb, int listing);
 mal_export void showFlowGraph(MalBlkPtr mb, MalStkPtr stk, str fname);
@@ -339,10 +350,6 @@
                        }
                        retseen = 1;
                        break;
-           case ENDsymbol:
-                       lastInstruction = lastInstruction < 
mb->stop?i:lastInstruction;
-                       i= mb->stop;
-                       break;
            case RAISEsymbol:
                break;
                default:
@@ -591,7 +598,7 @@
        }
        /* clear type fixations */
        for(i=0;i< new->def->vtop; i++)
-               new->def->var[i]->fixtype=0;
+               clrVarFixed(new->def,i);
 
 #ifdef DEBUG_MAL_FCN
        printf("FUNCTION TO BE CHECKED\n");
@@ -657,9 +664,13 @@
 
 Also take care of the nested block structure. Because the span should
 fall within a single block. This is handled by the chkflow already.
+
+The lifespan assumes that any potential conflict of variable
+declaration within blocks have been detected already by chkDeclarations().
+A variable may be introduced only once.
 @c
 void
-debugLifespan(MalBlkPtr mb)
+debugLifespan(MalBlkPtr mb, Lifespan span)
 {
        int i;
 
@@ -668,60 +679,53 @@
                        printf("%c%d ", TMPMARKER, getVar(mb,i)->tmpindex); 
                else
                        printf("%8s ", getVar(mb,i)->name);
-               printf("%d - %d  update %d scope= %d\n", 
-                       getBeginLifespan(mb,i),
-                       getEndLifespan(mb,i),
-                       getLastUpdate(mb,i),
-                       getScope(mb,i));
+               printf("%d - %d  update %d \n", 
+                       getBeginLifespan(span,i),
+                       getEndLifespan(span,i),
+                       getLastUpdate(span,i));
        }
 }
+
 void
-setLifespan(MalBlkPtr mb)
+setLifespan(MalBlkPtr mb, Lifespan span)
 {
-       int pc, j, k, depth=0, blkId=1,scopes[256];
+       int pc, k, depth=0, scopes[256];
        InstrPtr p;
+       int top=0, *decl= (int*)alloca(sizeof(int)*mb->vtop);
 
-       for (k = 0; k < mb->vtop; k++) {
-               VarPtr v = getVar(mb, k);
-               v->lastUpdate = v->beginLifespan = v->endLifespan = 0;
-               v->isused= 0;
-       }
-       scopes[depth]=blkId;
+       memset((char*) span,0, sizeof(LifespanRecord)* mb->vtop);
        for (pc = 0; pc < mb->stop; pc++) {
                p = getInstrPtr(mb, pc);
                if( p->token == NOOPsymbol)
                        continue;
 
                for (k = 0; k < p->argc; k++) {
-                       VarPtr v = getVar(mb, p->argv[k]);
+                       int v = getArg(p,k);
 
-                       if (v->beginLifespan == 0 )
-                               v->beginLifespan = pc;
+                       if (span[v].beginLifespan == 0 ){
+                               span[v].beginLifespan = pc;
+                               /* remember the variable in the scope stack*/
+                               decl[top++]= v;
+                       }
                        if (k < p->retc && 
                                p->barrier != RETURNsymbol &&
                                p->barrier != YIELDsymbol)
-                                       v->lastUpdate= pc;
-                       if (pc > v->endLifespan && v->scope== scopes[depth])
-                               v->endLifespan = pc;
[EMAIL PROTECTED]
-For all variables we keep track if it is used, cq modified.
-This simplifies subsequent optimization.
[EMAIL PROTECTED]
-                       if( k >= p->retc)
-                               v->isused= v->isused || !v->isatypevar;
-                       else
-                               v->isused= v->isused || blockCntrl(p) || 
blockStart(p);
+                                       span[v].lastUpdate= pc;
+                       if (pc > span[v].endLifespan )
+                               span[v].endLifespan = pc;
                }
 @-
 At a block exit we can finalize some variables.
 @c
                if( blockExit(p)){
-                       depth--;
-                       for (j = 0; j < mb->vtop; j++) {
-                               VarPtr v = getVar(mb, j);
-                               if( v->scope == scopes[depth] )
-                                       v->endLifespan= pc;
+                       for(top--; top>=scopes[depth]; top--)
+                               span[decl[top]].endLifespan= pc;
+                       if( depth== 0) {
+                               mb->errors++;
+                               GDKerror("too many unnest operations.");
+                               return;
                        }
+                       depth--;
                }
                if( blockStart(p)){
                        if( depth== 255) {
@@ -729,13 +733,12 @@
                                GDKerror("too deeply nested scope");
                                return;
                        }
-                       scopes[++depth]= ++blkId;
+                       scopes[++depth]= top;
                }
        }
        /* debugLifespan(mb); */
 }
 
[EMAIL PROTECTED]
 int
 isLoopBarrier(MalBlkPtr mb, int pc){
        InstrPtr p;
@@ -802,6 +805,7 @@
 before being used. Since barrier blocks may be skipped at
 runtime, they actually introduce a separate scope.
 Variables declared within a block may not be used outside it.
+Variables can only be declared once.
 
 In many situation chkFlow and chkDeclarations should be called
 together. Moreover, an erroneous chkFlow most likely implies
@@ -810,39 +814,29 @@
 Since in interactive mode each statement is handled separately,
 we have to remember the scope assigned to a variable.
 @c
-#define getDeclarePoint(I) decl[I]
-void chkDeclarations(MalBlkPtr mb,int reset){
+void clrDeclarations(MalBlkPtr mb){
+       int i;
+       for(i=0;i<mb->vtop; i++){
+               clrVarInit(mb,i);
+               clrVarUsed(mb,i);
+               clrVarDisabled(mb,i);
+       }
+}
+
+void chkDeclarations(MalBlkPtr mb){
        int pc,i, k,l;
        InstrPtr p;
-       short s, blks[MAXDEPTH], top= 0, blkId=1;
+       short blks[MAXDEPTH], top= 0, blkId=1;
        int *decl =(int*) alloca(sizeof(int) * mb->vtop);
 
        memset((char*) decl, 0, sizeof(int) * mb->vtop);
-       blks[top] = 1;
-       blks[++top]= 0;
-       if( reset) 
-       for(i=0; i<mb->vtop; i++){
-               getDeclarePoint(i)=0;
-               getVarScope(mb,i)=0;
-               if( mb->var[i]->name == 0 && !isTmpVar(mb,i)){
-                       showScriptException(mb,0,TYPE,"Name missing in variable 
%d",i);
-                       mb->errors++;
-               }
-       }
+       blks[top] = blkId;
 
        /* all signature variables are declared at outer level */
        p= getInstrPtr(mb,0);
-       for(k=p->retc;k<p->argc; k++){
-               getVarScope(mb,p->argv[k])= 1;
-           getDeclarePoint(p->argv[k])= 0;
-       }
-       /* and the function name as well */
-       if( getFunctionId(p) == NULL){
-               showScriptException(mb,0, TYPE,
-                       "Function name missing in signature");
-               return;
-       }
-               
+       for(k=0;k<p->argc; k++)
+               decl[getArg(p,k)]= blkId;
+
        /* printFunction(GDKout,mb, LIST_MAL_ALL);*/
 
        for(pc=1;pc<mb->stop; pc++){
@@ -850,61 +844,79 @@
                /* check correct use of the arguments*/
                for(k=p->retc;k<p->argc; k++) {
                        l=getArg(p,k);
-                       if( isConstant(mb, l) || isTypeVar(mb,l) ){
-                               /* ok defined */
-                       } else 
-                       if( (s = getVarScope(mb,l) ) ==0 ) {
+                       setVarUsed(mb,l);
+                       if( decl[l] == 0){
[EMAIL PROTECTED]
+The problem created here is that only variables are
+recognized that are declared through instructions.
+For interactive code, and code that is based on a global
+stack this is insufficient. In those cases, the variable
+can be defined in a previous execution.
+We have to recognize if the declaration takes place
+in the context of a global stack. 
[EMAIL PROTECTED]
+                               if( p->barrier == CATCHsymbol){
+                                       decl[l] = blks[0];
+                               } else
+                               if( !( isVarConstant(mb, l) || 
isVarTypedef(mb,l)) &&
+                                       !isVarInit(mb,l) ) {
                                        showScriptException(mb,pc,TYPE,
                                                "'%s' may not be used before 
being initialized", 
                                                getVarName(mb,l));
-                                               mb->errors++;
-                       } else 
-                       if( getDeclarePoint(l) >= top){
-                                               showScriptException(mb,pc,TYPE,
-                                                       "'%s' may not be used 
before being set",
+                                       mb->errors++;
+                               }
+                       } else {
+                           /* is the block still active ? */
+                           for( i=0; i<= top; i++)
+                                       if( blks[i] == decl[l] ) 
+                                               break;
+                           if( i> top || blks[i]!= decl[l] ){
+                                   showScriptException(mb,pc,TYPE,
+                                                       "'%s' used outside 
scope",
                                                        getVarName(mb,l));
-                                               mb->errors++;
+                               mb->errors++;
+                           }
                        }
+                       if( (blockCntrl(p) || blockStart(p)) && !isTmpVar(mb,l))
+                               setVarInit(mb, l);
                }
-               /* introduce new variables or propagate them to lower depth */
+               /* define variables */
                for(k=0; k<p->retc; k++){
                        l= getArg(p,k);
-                       if( getVarScope(mb, l) == 0){
+                       setVarInit(mb,l);
+                       if( decl[l] == 0){
                                /* variable has not been defined yet */
-                               if( (p->barrier== RETURNsymbol || p->barrier== 
YIELDsymbol) &&
-                                       getVarType(mb,l) != TYPE_void  && 
p->retc==p->argc){
-                                   showScriptException(mb,pc,TYPE,
-                                                       "'%s' returns before 
being initialized",
-                                                       getVarName(mb,l));
-                                               mb->errors++;
-                               }
-                               /* declare its scope */
-                           getVarScope(mb, l) = blks[top-1];
-                           getDeclarePoint(l) = top-1;
+                               /* exceptions are always declared at level 1 */
+                               if( p->barrier == CATCHsymbol)
+                                       decl[l] = blks[0];
+                               else
+                                       decl[l] = blks[top];
+#ifdef DEBUG_MAL_FCN
+                               stream_printf(GDKout,"defined %s in block 
%d\n", 
+                                       getVarName(mb,l),decl[l]);
+#endif
                        } else {
                            /* is the block still active ? */
-                           s = getVarScope(mb,l);
-                           for( i=0; i< top; i++)
-                           if( blks[i] == s ) break;
-                           if( i< top && blks[i]!= s && !isTmpVar(mb, l)){
+                           for( i=0; i<= top; i++)
+                                       if( blks[i] == decl[l] ) 
+                                               break;
+                           if( i> top || blks[i]!= decl[l] ){
                                    showScriptException(mb,pc,TYPE,
-                                                       "'%s' used outside 
declaration",
+                                                       "'%s' used outside 
scope",
                                                        getVarName(mb,l));
                                mb->errors++;
                            }
-                               /* declare its new scope */
-                               if( getDeclarePoint(l) > top -1){
-                                       getVarScope(mb, l) = blks[top-1];
-                                       getDeclarePoint(l) = top-1;
-                               }
                        }
+                       if( blockCntrl(p) || blockStart(p) )
+                               setVarUsed(mb, l);
                }
                if( p->barrier){
                        if( blockStart(p)){
-                               blkId++;
                                if( top <MAXDEPTH-2){
-                                       blks[top]= blkId;
-                                       blks[++top]= 0;
+                                       blks[++top]= ++blkId;
+#ifdef DEBUG_MAL_FCN
+                               stream_printf(GDKout,"new block %d at top 
%d\n",blks[top], top);
+#endif
                                } else {
                                        showScriptException(mb,pc,SYNTAX,
                                                "too deeply nested  MAL 
program");
@@ -913,8 +925,10 @@
                                }
                        }
                        if( blockExit(p) && top > 0) {
+#ifdef DEBUG_MAL_FCN
+                               stream_printf(GDKout,"leave block %d at top 
%d\n",blks[top], top);
+#endif
                            top--;
-                           blks[top]= 0;
                        }
                }
        }
@@ -1010,6 +1024,8 @@
        stream *f;
        InstrPtr p;
        int i, k;
+       Lifespan span;
+       span = newLifespan(mb);
 
        (void) stk;             /* fool the compiler */
 
@@ -1017,7 +1033,7 @@
                f = GDKout;
        else
                f = open_wastream(fname);
-       setLifespan(mb);
+       setLifespan(mb,span);
        p = getInstrPtr(mb, 0);
        stream_printf(f, "digraph %s{\n", getFunctionId(p));
        p = getInstrPtr(mb, 0);
@@ -1035,7 +1051,7 @@
                if( p->retc== 0 || getArgType(mb,p,0)== TYPE_void) /* assume 
side effects */
                for (k = p->retc; k < p->argc; k++) 
                        if (getArgType(mb,p,k) != TYPE_void && 
-                               !isConstant(mb,getArg(p,k)))
+                               !isVarConstant(mb,getArg(p,k)))
                                showOutFlow(mb, i, p->argv[k], f);
 
                if( getFunctionId(p)== 0)

Index: mal_resolve.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_resolve.mx,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- mal_resolve.mx      30 Dec 2007 18:21:13 -0000      1.131
+++ mal_resolve.mx      2 Jan 2008 08:18:52 -0000       1.132
@@ -374,9 +374,9 @@
        p->typechk= TYPE_RESOLVED;
        for(i=0;i<p->retc;i++) {
                int ts= returntype[i];
-               if( !isFixed(mb,getArg(p,i)) && ts>=0) {
+               if( !isVarFixed(mb,getArg(p,i)) && ts>=0) {
                        setVarType(mb, getArg(p,i),ts);
-                       setFixed(mb, getArg(p,i));
+                       setVarFixed(mb, getArg(p,i));
                }
                @:prepostProcess(ts,i,mb)@
        }
@@ -460,15 +460,15 @@
 Since we now know the storage type of the receiving variable, we can
 set the garbagge collection flag.
 @= prepostProcess
-       if (findGDKtype(@1) == TYPE_bat){
-               setVarCleanup(mb,getArg(p,@2)) = TRUE;
+       if( findGDKtype(@1) == TYPE_bat){
+               setVarCleanup(mb,getArg(p,@2));
                getInstrPtr(@3,0)->gc |= GARBAGECONTROL;
                p->gc|= QUICKCLEANUP;
        } else if (!isPolyType(@1)  && @1< TYPE_any && 
                @1>=0 && ATOMstorage(@1)== TYPE_str &&
-               !isConstant(mb,getArg(p,@2))){
+               !isVarConstant(mb,getArg(p,@2))){
                getInstrPtr(@3,0)->gc |= GARBAGECONTROL;
-               setVarCleanup(mb,getArg(p,@2)) = TRUE;
+               setVarCleanup(mb,getArg(p,@2));
                p->gc|= QUICKCLEANUP;
        } 
 @c
@@ -607,7 +607,7 @@
 
        if( isaSignature(p) ) {
                for(k=0;k<p->argc;k++)
-                       setFixed(mb,getArg(p,k));
+                       setVarFixed(mb,getArg(p,k));
                for(k=p->retc;k<p->argc;k++){
                        @:prepostProcess(getArgType(mb,p,k),k,mb)@
                }
@@ -689,9 +689,9 @@
                        rhs= lhs;
                } 
 
-               if( !isFixed(mb,getArg(p,k))) {
+               if( !isVarFixed(mb,getArg(p,k))) {
                        setVarType(mb,getArg(p,k),rhs);
-                       setFixed(mb,getArg(p,k));
+                       setVarFixed(mb,getArg(p,k));
                }
                @:prepostProcess(s1,0,mb)@
        }
@@ -814,7 +814,7 @@
 
        chkTypes(s,mb);
        chkFlow(mb);
-       chkDeclarations(mb,FALSE);
+       chkDeclarations(mb);
 }
 @- Polymorphic type analysis
 MAL provides for type variables of the form any$N. This feature

Index: mal_session.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_session.mx,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -d -r1.147 -r1.148
--- mal_session.mx      30 Dec 2007 18:21:14 -0000      1.147
+++ mal_session.mx      2 Jan 2008 08:18:52 -0000       1.148
@@ -407,7 +407,7 @@
        for (i = j = start; i < mb->vtop; i++) {
                if (isTmpVar(mb, i) || unknownType(getVarType(mb,i)) ) {
                        if (glb) {
-                               if (!isConstant(mb,i))
+                               if (!isVarConstant(mb,i))
                                        garbageElement(&glb->stk[i]);
                                /* clean stack entry */
                                glb->stk[i].vtype = TYPE_int;
@@ -416,7 +416,7 @@
                        }
                        clearVariable(mb, i);
                } else {
-                       assert(!mb->var[i]->value.vtype || 
mb->var[i]->isaconstant );
+                       assert(!mb->var[i]->value.vtype || isVarConstant(mb,i) 
);
                        if (i != j) {
                                VarPtr v = getVar(mb,j);
                                getVar(mb,j) = getVar(mb,i);

Index: mal_instruction.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_instruction.mx,v
retrieving revision 1.292
retrieving revision 1.293
diff -u -d -r1.292 -r1.293
--- mal_instruction.mx  30 Dec 2007 18:21:12 -0000      1.292
+++ mal_instruction.mx  2 Jan 2008 08:18:51 -0000       1.293
@@ -318,21 +318,23 @@
 typedef struct VARRECORD {
        str name;               /* argname or lexical value repr */
        malType type;           /* internal type signature */
-       bit isaconstant;        /* value cannot change */
-       bit isatypevar;         /* denotes a type variable */
-       bit fixtype;            /* the type has been fixed */
-       bit isudftype;          /* type defined in program */
-       bit cleanup;            /* remove upon function return */
-       bit isused;             /* in-out argument to function */
        int tmpindex;           /* temporary variable */
-       short scope;            /* block id where it is declared */
-       short beginLifespan, endLifespan, lastUpdate;   /* for optimizers */
        ValRecord value;
-
+       short flags;            /* see below, reserve some space */
        short propc, maxprop;   /* proc count and max number of properties */
        short prps[];           /* property array */
 } *VarPtr, VarRecord;
 
+/* Variable properties */
+#define VAR_CONSTANT   1
+#define VAR_TYPEVAR            2
+#define VAR_FIXTYPE            4
+#define VAR_UDFTYPE            8
+#define VAR_CLEANUP            16
+#define VAR_INIT               32
+#define VAR_USED               64
+#define VAR_DISABLED   128 /* used for comments and scheduler */
+
 /* type check status is kept around to improve type checking efficiency */
 #define TYPE_ERROR      -1
 #define TYPE_UNKNOWN     0
@@ -357,9 +359,9 @@
        bit gc;                 /* garbage control flags */
        bit polymorphic;        /* complex type analysis */
        bit varargs;            /* variable number of arguments or targets */
+       int jump;               /* controlflow program counter */
        MALfcn fcn;             /* resolved function address */
        struct MALBLK *blk;     /* resolved MAL function address */
-       int jump;               /* controlflow program counter */
 @-
 The MAL instruction representation. The strings should not be garbage collected
 upon destruction of the definition. They are part of the global namespace.
@@ -429,6 +431,7 @@
 
 #define getInstrPtr(M,I)    (M)->stmt[I]
 #define getSignature(S)     getInstrPtr((S)->def,0)
+#define isMain(M)                      ((getInstrPtr(M,0))->fcnname== 
putName("main",4))
 #define getFcnName(M)       getFunctionId(getInstrPtr(M,0))
 #define getArgCount(M)      getInstrPtr(M,0)->argc
 #define getModName(M)       getModuleId(getInstrPtr(M,0))
@@ -436,26 +439,25 @@
 
 #define getVar(M,I)     (M)->var[I]
 #define getVarTmp(M,I)      (M)->var[I]->tmpindex
-#define isTypeVar(M,I)  ((M)->var[I]->isatypevar)
 #define isTmpVar(M,I)   (!(M)->var[I]->name || *(M)->var[I]->name == TMPMARKER)
 #define getVarType(M,I)     ((M)->var[I]->type)
 #define getVarGDKType(M,I)      getGDKType((M)->var[I]->type)
-#define getVarScope(M,I)   ((M)->var[I]->scope)
-
-#define isFixed(M,I)        ((M)->var[I]->fixtype)
-#define freezeVarType(M,I) getVar(M,I)->isudftype = 1;
-#define setFixed(M,I)       ((M)->var[I]->fixtype= 1)
-#define setVarCleanup(M,I)     ((M)->var[I]->cleanup)
-#define isVarGarbage(M,I)     ((M)->var[I]->cleanup)
-#define setVarUsed(M,I,V)              ((M)->var[I]->isused= V)
-#define isVarUsed(M,I)         ((M)->var[I]->isused)
-#define getConstant(M,I)     ((M)->var[I]->value)
-#define isConstant(M,I) ((M)->var[I]->isaconstant)
[EMAIL PROTECTED]
[EMAIL PROTECTED] varProperty
+#define [EMAIL PROTECTED](M,I)       ((M)->var[I]->flags &= [EMAIL PROTECTED])
+#define [EMAIL PROTECTED](M,I)       ((M)->var[I]->flags |= [EMAIL PROTECTED])
+#define [EMAIL PROTECTED](M,I)        ((M)->var[I]->flags & [EMAIL PROTECTED])
[EMAIL PROTECTED]
+@:varProperty(Fixed,FIXTYPE)@
+@:varProperty(Cleanup,CLEANUP)@
+@:varProperty(Used,USED)@
+@:varProperty(Init,INIT)@
+@:varProperty(Disabled,DISABLED)@
+@:varProperty(Typedef,TYPEVAR)@
+@:varProperty(UDFtype,UDFTYPE)@
+@:varProperty(Constant,CONSTANT)@
 
-#define getLastUpdate(M,I)     ((M)->var[I]->lastUpdate)
-#define getEndLifespan(M,I)    ((M)->var[I]->endLifespan)
-#define getBeginLifespan(M,I)  ((M)->var[I]->beginLifespan)
-#define getScope(M,I)  ((M)->var[I]->scope)
+#define getVarConstant(M,I)     ((M)->var[I]->value)
 
 #define getDestVar(P)   (P)->argv[0]
 #define setDestVar(P,X)   (P)->argv[0]  =X
@@ -1254,7 +1256,7 @@
 str
 getArgDefault(MalBlkPtr mb, InstrPtr p, int idx)
 {
-       ValPtr v = &getConstant(mb, getArg(p, idx));
+       ValPtr v = &getVarConstant(mb, getArg(p, idx));
 
        if (v->vtype == TYPE_str)
                return v->val.sval;
@@ -1396,10 +1398,10 @@
        mb->var[n]->maxprop = 2*MAXARG;
 
        setVarType(mb, n, type);
-       isConstant(mb, n) = 0;
-       setVarCleanup(mb, n) = FALSE;
-       getVar(mb, n)->isudftype = 0;
-       getVar(mb, n)->isused = 0;
+       clrVarConstant(mb, n);
+       clrVarCleanup(mb, n);
+       clrVarUDFtype(mb, n);
+       clrVarUsed(mb, n);
        mb->vtop++;
        return n;
 }
@@ -1439,13 +1441,6 @@
        n = mb->vtop;
        if (getVar(mb, n) == NULL)
                getVar(mb, n) = (VarPtr) GDKzalloc(sizeof(VarRecord) + 2*MAXARG 
* sizeof(short));
-/* already captured by memset
-    mb->var[n]->name = 0;
-    isConstant(mb,n) = 0;
-    setVarCleanup(mb,n) = FALSE;
-       getVar(mb,n)->isudftype= 0;
-       getVar(mb,n)->isused= 0;
-*/
        getVarTmp(mb, n) = n;
        setVarType(mb, n, type);
        mb->var[n]->propc = 0;
@@ -1471,10 +1466,10 @@
        int n;
 
        n = type == TYPE_any ? -1 : findTmpVariable(mb, type);
-       if (n > 0 && isTypeVar(mb, n))
+       if (n > 0 && isVarTypedef(mb, n))
                return n;
        n = newTmpVariable(mb, type);
-       isTypeVar(mb, n) = TRUE;
+       setVarTypedef(mb, n);
        return n;
 }
 
@@ -1497,14 +1492,8 @@
        w = (VarPtr) GDKzalloc(sizeof(VarRecord) + v->maxprop * sizeof(short));
        w->name = v->name ? GDKstrdup(v->name) : 0;
        w->type = v->type;
-       w->cleanup = v->cleanup;
-       w->fixtype = v->fixtype;
-       w->isudftype = v->isudftype;
-       w->isused = v->isused;
-       w->isaconstant = v->isaconstant;
-       w->isatypevar = v->isatypevar;
+       w->flags = v->flags;
        w->tmpindex = v->tmpindex;
-       w->scope = v->scope;
        w->propc = v->propc;
        w->maxprop = v->maxprop;
        for (i=0; i<v->propc; i++)
@@ -1550,18 +1539,12 @@
                return;
        if (v->name)
                GDKfree(v->name);
-       if (v->isaconstant)
+       if (isVarConstant(mb,varid))
                VALclear(&v->value);
        v->name = 0;
        v->type = 0;
-       v->cleanup = 0;
-       v->fixtype = 0;
-       v->isudftype = 0;
-       v->isused = 0;
-       v->isaconstant = 0;
-       v->isatypevar = 0;
+       v->flags = 0;
        v->tmpindex = 0;
-       v->scope = 0;
        v->propc = 0;
 }
 
@@ -1796,7 +1779,7 @@
        for (i = mb->vtop - 1; i >= k; i--) {
                VarPtr v = getVar(mb, i);
 
-               if (v && v->isaconstant &&
+               if (v && isVarConstant(mb,i) &&
                        v->type == cst->vtype &&
                        ATOMcmp(cst->vtype, VALget(&v->value), p) == 0)
                        return i;
@@ -1849,9 +1832,9 @@
                return k;
        }
        k = newTmpVariable(mb, type);
-       isConstant(mb, k) = 1;
-       setFixed(mb, k);
-       vr = &getConstant(mb, k);
+       setVarConstant(mb, k);
+       setVarFixed(mb, k);
+       vr = &getVarConstant(mb, k);
        *vr = *cst;
        return k;
 }
@@ -1990,13 +1973,14 @@
        p= getInstrPtr(mb,0);
 
        for(i=p->argc; i<mb->vtop; i++)
-       if( !mb->var[i]->isudftype &&
-               mb->var[i]->isused &&
-               !mb->var[i]->isaconstant &&
+       if( !isVarUDFtype(mb,i) &&
+               isVarUsed(mb,i) &&
+               !isVarTypedef(mb,i) &&
+               !isVarConstant(mb,i) && 
                !isExceptionVariable(mb->var[i]->name)){
-               setVarType(mb,i,TYPE_any);
-               setVarCleanup(mb,i) = FALSE;
-               mb->var[i]->fixtype= 0;
+                       setVarType(mb,i,TYPE_any);
+                       clrVarCleanup(mb,i);
+                       clrVarFixed(mb,i);
        }
        for(i=1; i<mb->stop-1; i++){
                p= getInstrPtr(mb,i);
@@ -2181,7 +2165,7 @@
                        str nme;
                        char nmebuf[PATHLENGTH];
                        tpe = getTypeName(getArgType(mb, p, i));
-                       if (isTmpVar(mb, getArg(p, i)) || isTypeVar(mb, 
getArg(p, i))) {
+                       if (isTmpVar(mb, getArg(p, i)) || isVarTypedef(mb, 
getArg(p, i))) {
                                snprintf(nmebuf, PATHLENGTH, "%c%d", TMPMARKER, 
getVarTmp(mb, getArg(p, i)));
                                nme = nmebuf;
                        } else
@@ -2200,7 +2184,7 @@
                        char nmebuf[PATHLENGTH];
 
                        tpe = getTypeName(getArgType(mb, p, i));
-                       if (isTmpVar(mb, getArg(p, i)) || isTypeVar(mb, 
getArg(p, i))) {
+                       if (isTmpVar(mb, getArg(p, i)) || isVarTypedef(mb, 
getArg(p, i))) {
                                snprintf(nmebuf, PATHLENGTH, "%c%d", TMPMARKER, 
getVarTmp(mb, getArg(p, i)));
                                nme = nmebuf;
                        } else
@@ -2233,7 +2217,7 @@
                                advance(s);
                        }
                        tpe = getTypeName(getArgType(mb, p, i));
-                       if (isTmpVar(mb, getArg(p, i)) || isTypeVar(mb, 
getArg(p, i))) {
+                       if (isTmpVar(mb, getArg(p, i)) || isVarTypedef(mb, 
getArg(p, i))) {
                                snprintf(nmebuf, PATHLENGTH, "%c%d", TMPMARKER, 
getVarTmp(mb, getArg(p, i)));
                                nme = nmebuf;
                        } else
@@ -2456,7 +2440,7 @@
                                pstring = varGetPropStr(mb, getArg(p, 0));
                        else 
                                pstring = GDKstrdup("");
-                       if (getVar(mb, getArg(p, 0))->isudftype) {
+                       if ( isVarUDFtype(mb,getArg(p, 0))) {
                                str tpe = getTypeName(getVarType(mb, getArg(p, 
0)));
 
                                sprintf(t, "%s:%s%s ", nme, tpe, pstring);
@@ -2482,7 +2466,7 @@
                                        pstring = varGetPropStr(mb, getArg(p, 
i));
                                else 
                                        pstring = GDKstrdup("");
-                               if (getVar(mb, getArg(p, i))->isudftype) {
+                               if ( isVarUDFtype(mb, getArg(p, i))) {
                                        str tpe = getTypeName(getVarType(mb, 
getArg(p, i)));
 
                                        sprintf(t, "%s:%s%s ", getArgName(mb, 
p, i), tpe, pstring);
@@ -2542,7 +2526,7 @@
                        sprintf(t, "...");
                        break;
                }
-               if (isConstant(mb, getArg(p, i))) {
+               if (isVarConstant(mb, getArg(p, i))) {
                        str cv = NULL;
 
                        VALformat(&cv, &getVar(mb, getArg(p, i))->value);
@@ -2559,9 +2543,9 @@
                        GDKfree(cv);
                        advance(t);
                } else {
-                       if( ! isTypeVar(mb,getArg(p,i)) ){
+                       if( ! isVarTypedef(mb,getArg(p,i)) ){
                                if (isTmpVar(mb, getArg(p, i))) {
-                                       if( ! isTypeVar(mb,getArg(p,i)) )
+                                       if( ! isVarTypedef(mb,getArg(p,i)) )
                                                sprintf(t, "%c%d", TMPMARKER, 
getVarTmp(mb, getArg(p, i)));
                                        advance(t);
                                } else
@@ -2581,9 +2565,9 @@
                        GDKfree(d1);
                        GDKfree(d2);
                        advance(t);
-               } else if ( isTypeVar(mb, getArg(p, i)) || 
-                                 ( isConstant(mb, getArg(p, i)) &&
-                                       ( getVar(mb, getArg(p, i))->isudftype ||
+               } else if ( isVarTypedef(mb, getArg(p, i)) || 
+                                 ( isVarConstant(mb, getArg(p, i)) &&
+                                       ( isVarUDFtype(mb, getArg(p, i)) ||
                                        ATOMcmp(getArgType(mb,p,i), 
                                                        
ATOMnilptr(getArgType(mb,p,i)), 
                                                        VALptr(&getVar(mb, 
getArg(p, i))->value) ) == 0

Index: mal_profiler.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_profiler.mx,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- mal_profiler.mx     4 Oct 2007 10:37:08 -0000       1.100
+++ mal_profiler.mx     2 Jan 2008 08:18:52 -0000       1.101
@@ -957,17 +957,17 @@
        mal_unset_lock(mal_contextLock, "trace");
 }
 
-#define CLEANUP(X)  if(X) { BBPdecref((X)->batCacheid, TRUE); 
(X)->batPersistence= TRANSIENT; } (X)= NULL;
+#define CLEANUPprofile(X)  if(X) { BBPdecref((X)->batCacheid, TRUE); 
(X)->batPersistence= TRANSIENT; } (X)= NULL;
 str
 cleanupProfiler(){
        mal_set_lock(mal_contextLock, "cleanup");
-       CLEANUP( TRACE_id_time );
-       CLEANUP( TRACE_id_pc );
-       CLEANUP( TRACE_id_modfcn );
-       CLEANUP( TRACE_id_stmt );
-       CLEANUP( TRACE_id_ibytes );
-       CLEANUP( TRACE_id_obytes );
-       CLEANUP( TRACE_id_diskspace );
+       CLEANUPprofile( TRACE_id_time );
+       CLEANUPprofile( TRACE_id_pc );
+       CLEANUPprofile( TRACE_id_modfcn );
+       CLEANUPprofile( TRACE_id_stmt );
+       CLEANUPprofile( TRACE_id_ibytes );
+       CLEANUPprofile( TRACE_id_obytes );
+       CLEANUPprofile( TRACE_id_diskspace );
        TRACE_init = 0;
        mal_unset_lock(mal_contextLock, "cleanup");
        return MAL_SUCCEED;

Index: mal_builder.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_builder.mx,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- mal_builder.mx      30 Dec 2007 18:21:11 -0000      1.30
+++ mal_builder.mx      2 Jan 2008 08:18:51 -0000       1.31
@@ -138,8 +138,8 @@
        cst.val.sval= GDKstrdup(val);
        cst.len= strlen(cst.val.sval);
        getArg(q,0) = defConstant(mb,TYPE_str,&cst);
-       /* mark the constant for not being copied to the stack */
-       isConstant(mb,getArg(q,0)) = - isConstant(mb,getArg(q,0));
+       clrVarConstant(mb,getArg(q,0));
+       setVarDisabled(mb,getArg(q,0));
        pushInstruction(mb, q);
        return q;
 }

Index: mal_debugger.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_debugger.mx,v
retrieving revision 1.215
retrieving revision 1.216
diff -u -d -r1.215 -r1.216
--- mal_debugger.mx     25 Dec 2007 13:08:47 -0000      1.215
+++ mal_debugger.mx     2 Jan 2008 08:18:51 -0000       1.216
@@ -477,7 +477,7 @@
 mal_export void mdbDump(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 mal_export void mdbHelp(stream *f);
 mal_export void printBATelm(stream *f, int i, size_t cnt, size_t first);
-mal_export void printStack(stream *f, MalBlkPtr mb, MalStkPtr s, int lifespan);
+mal_export void printStack(stream *f, MalBlkPtr mb, MalStkPtr s);
 mal_export void printBatInfo(stream *f, VarPtr n, ValPtr v);
 mal_export void printBatProperties(stream *f, VarPtr n, ValPtr v, str props);
 mal_export void printTraceCall(stream *out, MalBlkPtr mb, MalStkPtr stk, int 
pc, int flags);
@@ -510,7 +510,7 @@
 #define skipNonBlanc(c,X) while(*(X) && !isspace((int) *X)){ X++; }
 #define skipWord(c,X)    while(*(X) && isalnum((int) *X)){X++;} skipBlanc(c,X);
 
-static void printStackElm(stream *f, MalBlkPtr mb, ValPtr v, int index, size_t 
cnt, int first, int lifespan);
+static void printStackElm(stream *f, MalBlkPtr mb, ValPtr v, int index, size_t 
cnt, int first);
 
 @-
 Each client has its own breakpoint administration, kept in a global table.
@@ -1060,7 +1060,7 @@
                        str modname, fcnname;
                        Module fsym;
                        Symbol fs;
-                       int i, lifespan = *b== 'V';
+                       int i;
 
                        skipWord(cntxt, b);
                        if (*b != 0) {
@@ -1075,7 +1075,7 @@
                                        for (i = 0; i < MAXSCOPE; i++) {
                                                fs = fsym->subscope[i];
                                                while (fs != NULL) {
-                                                       printStack(out, 
fs->def, 0, lifespan);
+                                                       printStack(out, 
fs->def, 0);
                                                        fs = fs->peer;
                                                }
                                        }
@@ -1093,12 +1093,12 @@
                                        fs = fsym->subscope[i];
                                        while (fs != NULL) {
                                                if (strcmp(fs->name, fcnname) 
== 0)
-                                                       printStack(out, 
fs->def, 0,lifespan);
+                                                       printStack(out, 
fs->def, 0);
                                                fs = fs->peer;
                                        }
                                }
                        } else
-                               printStack(out, mb, stk,lifespan);
+                               printStack(out, mb, stk);
                        break;
                }
                case 'b':
@@ -1272,7 +1272,7 @@
                                        stream_printf(out, "%s Symbol not 
found\n", "#mdb ");
                                continue;
                        }
-                       printStackElm(out, mb, stk->stk + i, i, size, first,0);
+                       printStackElm(out, mb, stk->stk + i, i, size, first);
                        continue;
                }
                case 'S':
@@ -1388,7 +1388,7 @@
        stream_printf(cntxt->fdout,"!MDB dump of instruction %d\n",i);
        printFunction(cntxt->fdout, mb, LIST_MAL_ALL | LIST_MAL_PROPS);
        mdbBacktrace(cntxt, stk, i);
-       printStack(cntxt->fdout,mb,stk,0);
+       printStack(cntxt->fdout,mb,stk);
 }
 static int mdbSessionActive;
 int mdbSession(){
@@ -1523,7 +1523,7 @@
 arbitrary functions.
 @c
 void
-printStack(stream *f, MalBlkPtr mb, MalStkPtr s,int lifespan)
+printStack(stream *f, MalBlkPtr mb, MalStkPtr s)
 {
        int i = 0;
 
@@ -1531,10 +1531,10 @@
                stream_printf(f, "#Stack '%s' size=%d top=%d\n",
                                getInstrPtr(mb, 0)->fcnname, s->stksize, 
s->stktop);
                for (; i < mb->vtop; i++)
-                       printStackElm(f, mb, s->stk + i, i, 0, 0,lifespan);
+                       printStackElm(f, mb, s->stk + i, i, 0, 0);
        } else
                for (; i < mb->vtop; i++)
-                       printStackElm(f, mb, 0, i, 0, 0,lifespan);
+                       printStackElm(f, mb, 0, i, 0, 0);
 }
 
 void
@@ -1576,7 +1576,7 @@
 }
 
 void
-printStackElm(stream *f, MalBlkPtr mb, ValPtr v, int index, size_t cnt, int 
first, int lifespan)
+printStackElm(stream *f, MalBlkPtr mb, ValPtr v, int index, size_t cnt, int 
first)
 {
        str nme, nmeOnStk;
        char nmebuf[PATHLENGTH];
@@ -1588,16 +1588,7 @@
                nme = nmebuf;
        } else
                nme = n->name;
-       if( lifespan) {
-               stream_printf(f, "#[%d,%d:%d,%d](%d)  ", index, 
-                       getBeginLifespan(mb,index),
-                       getEndLifespan(mb,index),
-                       getLastUpdate(mb,index),
-                       getScope(mb,index));
-               if( isVarGarbage(mb,index) )
-                       stream_printf(f,"G ");
-               stream_printf(f, " %s\t= ", nme);
-       } else stream_printf(f, "#[%d] %s\t= ", index, nme);
+       stream_printf(f, "#[%d] %s\t= ", index, nme);
        /* if (n->type == TYPE_void)
                stream_printf(f, "nil");
        else */ if (v)
@@ -1605,8 +1596,6 @@
 
        nme = getTypeName(n->type);
        stream_printf(f, ":%s", nme);
-       if( lifespan && n->isudftype)
-               stream_printf(f," udftype");
        nmeOnStk = v ? getTypeName(v->vtype) : GDKstrdup(nme);
        if (strcmp(nmeOnStk, nme)) {
                if (isaBatType(n->type)) {
@@ -1622,9 +1611,9 @@
                } else if (!(isaBatType(n->type) && strcmp(nmeOnStk, "BAT") == 
0))
                        stream_printf(f, " != %s", nmeOnStk);
        }
-       stream_printf(f, " %s", (n->isaconstant ? " constant" : ""));
-       stream_printf(f, " %s", (n->isused==0 ? " not used" : ""));
-       stream_printf(f, " %s", (n->isatypevar ? " type variable" : ""));
+       stream_printf(f, " %s", (isVarConstant(mb,index)? " constant" : ""));
+       stream_printf(f, " %s", (isVarUsed(mb,index) ? "": " not used" ));
+       stream_printf(f, " %s", (isVarTypedef(mb,index) ? " type variable" : 
""));
        GDKfree(nme);
        GDKfree(nmeOnStk);
 

Index: mal_interpreter.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_interpreter.mx,v
retrieving revision 1.205
retrieving revision 1.206
diff -u -d -r1.205 -r1.206
--- mal_interpreter.mx  30 Dec 2007 18:21:12 -0000      1.205
+++ mal_interpreter.mx  2 Jan 2008 08:18:51 -0000       1.206
@@ -199,13 +199,14 @@
 @= initStack
        for(i= @1; i< mb->vtop; i++) {
                lhs = &stk->stk[i];
-               if( isConstant(mb,i) > 0 ){
-                       assert(mb->var[i]->cleanup == 0);
-                       rhs = &getConstant(mb,i);
-                       *lhs = *rhs;
-               } else {
+               if( isVarConstant(mb,i) > 0 ){
+                       assert(!isVarCleanup(mb,i));
+                       if( !isVarDisabled(mb,i)){
+                               rhs = &getVarConstant(mb,i);
+                               *lhs = *rhs;
+                       }
+               } else
                        lhs->vtype = getVarGDKType(mb,i);
-               }
        }
 @c
 
@@ -1533,8 +1534,8 @@
        printStack(GDKout,mb,stk,0);
 #endif
        for(k=0;k<mb->vtop; k++) {
-               if (isVarGarbage(mb,k) && (flag || isTmpVar(mb,k) )){
-                       garbageElement(v = &stk->stk[k]);
+               if(isVarCleanup(mb,k) && (flag || isTmpVar(mb,k) )){
+                       garbageElement(v= &stk->stk[k]);
                        v->vtype= TYPE_int;
                        v->val.ival= int_nil;
                }


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to