Changeset: f9f146af208a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/f9f146af208a Modified Files: clients/Tests/exports.stable.out monetdb5/mal/mal.h monetdb5/mal/mal_function.c monetdb5/mal/mal_instruction.c monetdb5/mal/mal_instruction.h monetdb5/mal/mal_listing.c monetdb5/mal/mal_resolve.c monetdb5/mal/mal_type.h monetdb5/optimizer/opt_coercion.c monetdb5/optimizer/opt_emptybind.c monetdb5/optimizer/opt_garbageCollector.c monetdb5/optimizer/opt_generator.c monetdb5/optimizer/opt_macro.c monetdb5/optimizer/opt_mergetable.c monetdb5/optimizer/opt_multiplex.c monetdb5/optimizer/opt_projectionpath.c monetdb5/optimizer/opt_pushselect.c monetdb5/optimizer/opt_remap.c Branch: no_type_bat Log Message:
cleanup some more fields in mal. diffs (truncated from 693 to 300 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -992,7 +992,6 @@ const char *getRef; int getShtConstant(MalBlkPtr mb, sht val); int getStrConstant(MalBlkPtr mb, str val); const char *getTraceRef; -malType getType(MalBlkPtr mb, const char *nme); str getTypeIdentifier(malType tpe); str getTypeName(malType tpe); char *getVarName(MalBlkPtr mb, int idx); diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h --- a/monetdb5/mal/mal.h +++ b/monetdb5/mal/mal.h @@ -96,12 +96,6 @@ mal_export const char *mal_version(void) #define LIST_MAL_DEBUG (LIST_MAL_NAME | LIST_MAL_VALUE | LIST_MAL_TYPE | LIST_MAL_PROPS | LIST_MAL_FLOW) #define LIST_MAL_ALL (LIST_MAL_NAME | LIST_MAL_VALUE | LIST_MAL_TYPE | LIST_MAL_MAPI) -/* type check status is kept around to improve type checking efficiency */ -#define TYPE_ERROR -1 -#define TYPE_UNKNOWN 0 -#define TYPE_RESOLVED 2 -#define GARBAGECONTROL 3 - #define VARARGS 1 /* deal with variable arguments */ #define VARRETS 2 @@ -147,14 +141,14 @@ typedef struct VARRECORD { typedef struct INSTR { bte token; /* instruction type */ - bit barrier; /* flow of control modifier takes: + bte barrier; /* flow of control modifier takes: BARRIER, LEAVE, REDO, EXIT, CATCH, RAISE */ - bit typechk; /* type check status */ - bte gc; /* garbage control flags */ - bte polymorphic:3, /* complex type analysis */ + uint16_t polymorphic:3, /* complex type analysis */ varargs:2, /* variable number of arguments */ inlineProp:1, /* inline property */ - unsafeProp:1; /* unsafe property */ + unsafeProp:1, /* unsafe property */ + gc:1, /* garbage control flags */ + typeresolved:1; /* true if type is resolved */ int jump; /* controlflow program counter */ int pc; /* location in MAL plan for profiler */ MALfcn fcn; /* resolved function address */ @@ -171,7 +165,6 @@ typedef struct INSTR { typedef struct MALBLK { char binding[IDLENGTH]; /* related C-function */ str help; /* supportive commentary */ - str statichelp; /* static help string should not be freed */ oid tag; /* unique block tag */ struct MALBLK *alternative; int vtop; /* next free slot */ diff --git a/monetdb5/mal/mal_function.c b/monetdb5/mal/mal_function.c --- a/monetdb5/mal/mal_function.c +++ b/monetdb5/mal/mal_function.c @@ -174,7 +174,7 @@ chkFlow(MalBlkPtr mb) if (ps->retc != p->retc) { throw(MAL, "chkFlow", "%s.%s invalid return target!", getModuleId(sig), getFunctionId(sig)); - } else if (ps->typechk == TYPE_RESOLVED) + } else if (ps->typeresolved) for (e = 0; e < p->retc; e++) { if (resolvedType(getArgType(mb, ps, e), getArgType(mb, p, e)) < 0) { str tpname = getTypeName(getArgType(mb, p, e)); @@ -358,7 +358,7 @@ cloneFunction(Module scope, Symbol proc, /* clear polymorphic and type to force analysis */ for (i = 0; i < new->def->stop; i++) { pp = getInstrPtr(new->def, i); - pp->typechk = TYPE_UNKNOWN; + pp->typeresolved = false; pp->polymorphic = 0; } /* clear type fixations */ diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c --- a/monetdb5/mal/mal_instruction.c +++ b/monetdb5/mal/mal_instruction.c @@ -191,7 +191,7 @@ resetMalTypes(MalBlkPtr mb, int stop) int i; for (i = 0; i < stop; i++) - mb->stmt[i]->typechk = TYPE_UNKNOWN; + mb->stmt[i]->typeresolved = false; mb->stop = stop; mb->errors = NULL; } @@ -272,10 +272,9 @@ freeMalBlk(MalBlkPtr mb) mb->binding[0] = 0; mb->tag = 0; mb->memory = 0; - if (mb->help && mb->statichelp != mb->help) + if (mb->help) GDKfree(mb->help); mb->help = 0; - mb->statichelp = 0; mb->inlineProp = 0; mb->unsafeProp = 0; freeException(mb->errors); @@ -382,7 +381,7 @@ newInstructionArgs(MalBlkPtr mb, const c } *p = (InstrRecord) { .maxarg = args, - .typechk = TYPE_UNKNOWN, + .typeresolved = false, .modname = modnme, .fcnname = fcnnme, .argc = 1, @@ -416,7 +415,7 @@ copyInstructionArgs(const InstrRecord *p if (args > p->maxarg) memset(new->argv + p->maxarg, 0, (args - p->maxarg) * sizeof(new->argv[0])); - new->typechk = TYPE_UNKNOWN; + new->typeresolved = false; new->maxarg = args; return new; } @@ -433,7 +432,7 @@ clrFunction(InstrPtr p) p->token = ASSIGNsymbol; p->fcn = 0; p->blk = 0; - p->typechk = TYPE_UNKNOWN; + p->typeresolved = false; setModuleId(p, NULL); setFunctionId(p, NULL); } @@ -516,7 +515,7 @@ findVariable(MalBlkPtr mb, const char *n if (name == NULL) return -1; for (i = mb->vtop - 1; i >= 0; i--) - if (idcmp(name, getVarName(mb, i)) == 0) + if (idcmp(name, mb->var[i].name) == 0) return i; return -1; } @@ -712,7 +711,7 @@ cloneVariable(MalBlkPtr tm, MalBlkPtr mb else { res = newTmpVariable(tm, getVarType(mb, x)); if (*mb->var[x].name) - strcpy(tm->var[x].name, mb->var[x].name); /* res = newVariable(tm, getVarName(mb, x), strlen(getVarName(mb,x)), getVarType(mb, x)); */ + strcpy(tm->var[x].name, mb->var[x].name); } if (res < 0) return res; diff --git a/monetdb5/mal/mal_instruction.h b/monetdb5/mal/mal_instruction.h --- a/monetdb5/mal/mal_instruction.h +++ b/monetdb5/mal/mal_instruction.h @@ -54,7 +54,7 @@ setFunctionId(InstrPtr p, const char *s) p->fcnname = s; } #endif -#define garbageControl(P) ((P)->gc & GARBAGECONTROL) +#define garbageControl(P) ((P)->gc) #define getInstrPtr(M,I) (M)->stmt[I] #define putInstrPtr(M,I,P) (M)->stmt[I] = P @@ -171,7 +171,6 @@ mal_export str operatorName(int i); mal_export int findVariable(MalBlkPtr mb, const char *name); mal_export int findVariableLength(MalBlkPtr mb, const char *name, int len); -mal_export malType getType(MalBlkPtr mb, const char *nme); mal_export str getArgDefault(MalBlkPtr mb, InstrPtr p, int idx); mal_export int newVariable(MalBlkPtr mb, const char *name, size_t len, malType type); diff --git a/monetdb5/mal/mal_listing.c b/monetdb5/mal/mal_listing.c --- a/monetdb5/mal/mal_listing.c +++ b/monetdb5/mal/mal_listing.c @@ -390,7 +390,7 @@ fcnDefinition(MalBlkPtr mb, InstrPtr p, if (!copystring(&t, extra, &len)) return base; } - if (p->typechk == TYPE_UNKNOWN) { + if (!p->typeresolved) { if (!copystring(&t, " type check needed", &len)) return base; } @@ -468,12 +468,13 @@ operatorName(int i) /* internal symbols */ case FCNcall: + assert(0); return "FCNcall"; case CMDcall: + assert(0); return "CMDcall"; - case THRDcall: - return "THRcall"; case PATcall: + assert(0); return "PATcall"; } return ""; @@ -493,7 +494,7 @@ instruction2str(MalBlkPtr mb, MalStkPtr if (!flg) { *t++ = '#'; len--; - if (p->typechk == TYPE_UNKNOWN) { + if (!p->typeresolved) { *t++ = '!'; /* error */ len--; } @@ -645,7 +646,7 @@ instruction2str(MalBlkPtr mb, MalStkPtr if (!copystring(&t, extra, &len)) return base; } - if (p->typechk == TYPE_UNKNOWN) { + if (!p->typeresolved) { if (!copystring(&t, " type check needed", &len)) return base; } diff --git a/monetdb5/mal/mal_resolve.c b/monetdb5/mal/mal_resolve.c --- a/monetdb5/mal/mal_resolve.c +++ b/monetdb5/mal/mal_resolve.c @@ -27,7 +27,7 @@ static malType getPolyType(malType t, int *polytype); static int updateTypeMap(int formal, int actual, int polytype[MAXTYPEVAR]); -static int typeKind(MalBlkPtr mb, InstrPtr p, int i); +static bool typeResolved(MalBlkPtr mb, InstrPtr p, int i); int resolvedType(int dsttype, int srctype) @@ -105,9 +105,9 @@ resolveType(int *rtype, int dsttype, int ATOMtype(tp) == TYPE_str || \ (!isPolyType(tp) && tp < TYPE_any && \ tp >= 0 && ATOMextern(tp))) { \ - getInstrPtr(mb, 0)->gc |= GARBAGECONTROL; \ + getInstrPtr(mb, 0)->gc = true; \ setVarCleanup(mb, getArg(p, b)); \ - p->gc |= GARBAGECONTROL; \ + p->gc = true; \ } \ } while (0) @@ -419,7 +419,7 @@ findFunctionType(Module scope, MalBlkPtr * Beware, this is not yet effectuated in the interpreter. */ - p->typechk = TYPE_RESOLVED; + p->typeresolved = true; p->inlineProp = inlineprop; p->unsafeProp = unsafe; for (i = 0; i < p->retc; i++) { @@ -429,7 +429,7 @@ findFunctionType(Module scope, MalBlkPtr mb->errors = createMalException(mb, idx, TYPE, "Assignment to constant"); } - p->typechk = TYPE_UNKNOWN; + p->typeresolved = false; goto wrapup; } if (!isVarFixed(mb, getArg(p, i)) && ts >= 0) { @@ -449,8 +449,8 @@ findFunctionType(Module scope, MalBlkPtr getArgType(mb, p, i) < TYPE_any && getArgType(mb, p, i) >= 0 && ATOMstorage(getArgType(mb, p, i)) == TYPE_str)) { - getInstrPtr(mb, 0)->gc |= GARBAGECONTROL; - p->gc |= GARBAGECONTROL; + getInstrPtr(mb, 0)->gc = true; + p->gc = true; } /* * It may happen that an argument was still untyped and as a @@ -484,7 +484,7 @@ findFunctionType(Module scope, MalBlkPtr /* Any previousely found error in the block * turns the complete block into erroneous. if (mb->errors) { - p->typechk = TYPE_UNKNOWN; + p->typeresolved = false; goto wrapup; } */ @@ -506,7 +506,7 @@ findFunctionType(Module scope, MalBlkPtr mb->errors = createMalException(mb, idx, TYPE, "object code for command %s.%s missing", p->modname, p->fcnname); - p->typechk = TYPE_UNKNOWN; + p->typeresolved = false; goto wrapup; } break; @@ -562,7 +562,7 @@ typeMismatch(MalBlkPtr mb, InstrPtr p, i GDKfree(n1); GDKfree(n2); } - p->typechk = TYPE_UNKNOWN; + p->typeresolved = false; } /* @@ -583,7 +583,7 @@ typeChecker(Module scope, MalBlkPtr mb, int s1 = -1, i, k; Module m = 0; - p->typechk = TYPE_UNKNOWN; + p->typeresolved = false; if ((p->fcn || p->blk) && p->token >= FCNcall && p->token <= PATcall) { p->token = ASSIGNsymbol; p->fcn = NULL; _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org