Changeset: edc267f8e320 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=edc267f8e320 Modified Files: monetdb5/mal/mal.h monetdb5/mal/mal_instruction.c monetdb5/mal/mal_listing.c monetdb5/mal/mal_parser.c monetdb5/mal/mal_prelude.c monetdb5/optimizer/opt_support.c Branch: mbedded Log Message:
merged diffs (285 lines): diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h --- a/monetdb5/mal/mal.h +++ b/monetdb5/mal/mal.h @@ -185,8 +185,7 @@ typedef struct MALBLK { InstrPtr *stmt; /* Instruction location */ bool inlineProp:1, /* inline property */ - unsafeProp:1, /* unsafe property */ - sealedProp:1; /* sealed property (opertions for sealed object should be on the full object once) */ + unsafeProp:1; /* unsafe property */ str errors; /* left over errors */ struct MALBLK *history; /* of optimizer actions */ 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 @@ -136,7 +136,6 @@ newMalBlk(int elements) mb->maxarg = MAXARG; /* the minimum for each instruction */ mb->inlineProp = 0; mb->unsafeProp = 0; - mb->sealedProp = 0; mb->replica = NULL; mb->starttime = 0; mb->runtime = 0; @@ -256,7 +255,6 @@ freeMalBlk(MalBlkPtr mb) mb->help = 0; mb->inlineProp = 0; mb->unsafeProp = 0; - mb->sealedProp = 0; GDKfree(mb->errors); GDKfree(mb); } @@ -350,7 +348,6 @@ copyMalBlk(MalBlkPtr old) mb->maxarg = old->maxarg; mb->inlineProp = old->inlineProp; mb->unsafeProp = old->unsafeProp; - mb->sealedProp = old->sealedProp; return mb; } 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 @@ -183,8 +183,6 @@ fcnDefinition(MalBlkPtr mb, InstrPtr p, return base; if( mb->unsafeProp && !copystring(&t, "unsafe ", &len)) return base; - if( mb->sealedProp && !copystring(&t, "sealed ", &len)) - return base; if (!copystring(&t, operatorName(p->token), &len) || !copystring(&t, " ", &len) || !copystring(&t, getModuleId(p) ? getModuleId(p) : "user", &len) || diff --git a/monetdb5/mal/mal_parser.c b/monetdb5/mal/mal_parser.c --- a/monetdb5/mal/mal_parser.c +++ b/monetdb5/mal/mal_parser.c @@ -1763,7 +1763,7 @@ parseMAL(Client cntxt, Symbol curPrg, in int cntrl = 0; /*Symbol curPrg= cntxt->curprg;*/ char c; - int inlineProp =0, unsafeProp = 0, sealedProp = 0; + int inlineProp =0, unsafeProp = 0; (void) curPrg; echoInput(cntxt); @@ -1845,15 +1845,12 @@ parseMAL(Client cntxt, Symbol curPrg, in MalBlkPtr p = parseCommandPattern(cntxt, COMMANDsymbol); if (p) { p->unsafeProp = unsafeProp; - p->sealedProp = sealedProp; } cntxt->curprg->def->unsafeProp = unsafeProp; - cntxt->curprg->def->sealedProp = sealedProp; if (inlineProp) parseError(cntxt, "<identifier> expected\n"); inlineProp = 0; unsafeProp = 0; - sealedProp = 0; continue; } if (MALkeyword(cntxt, "catch", 5)) { @@ -1877,13 +1874,10 @@ parseMAL(Client cntxt, Symbol curPrg, in cntxt->blkmode++; if ((p = parseFunction(cntxt, FUNCTIONsymbol))){ p->unsafeProp = unsafeProp; - p->sealedProp = sealedProp; cntxt->curprg->def->inlineProp = inlineProp; cntxt->curprg->def->unsafeProp = unsafeProp; - cntxt->curprg->def->sealedProp = sealedProp; inlineProp = 0; unsafeProp = 0; - sealedProp = 0; break; } } else if (MALkeyword(cntxt, "factory", 7)) { @@ -1891,11 +1885,8 @@ parseMAL(Client cntxt, Symbol curPrg, in parseError(cntxt, "parseError:INLINE ignored\n"); if( unsafeProp) parseError(cntxt, "parseError:UNSAFE ignored\n"); - if( sealedProp) - parseError(cntxt, "parseError:SEALED ignored\n"); inlineProp = 0; unsafeProp = 0; - sealedProp = 0; cntxt->blkmode++; parseFunction(cntxt, FACTORYsymbol); break; @@ -1929,13 +1920,10 @@ parseMAL(Client cntxt, Symbol curPrg, in p = parseCommandPattern(cntxt, PATTERNsymbol); if (p) { p->unsafeProp = unsafeProp; - p->sealedProp = sealedProp; } cntxt->curprg->def->unsafeProp = unsafeProp; - cntxt->curprg->def->sealedProp = sealedProp; inlineProp = 0; unsafeProp = 0; - sealedProp = 0; continue; } goto allLeft; @@ -1952,13 +1940,6 @@ parseMAL(Client cntxt, Symbol curPrg, in cntrl = RETURNsymbol; } goto allLeft; - case 's': - if (MALkeyword(cntxt, "sealed", 6)) { - sealedProp= 1; - skipSpace(cntxt); - continue; - } - goto allLeft; case 'U': case 'u': if (MALkeyword(cntxt, "unsafe", 6)) { unsafeProp= 1; diff --git a/monetdb5/mal/mal_prelude.c b/monetdb5/mal/mal_prelude.c --- a/monetdb5/mal/mal_prelude.c +++ b/monetdb5/mal/mal_prelude.c @@ -158,12 +158,32 @@ addAtom( mel_atom *atoms) } static str +makeArgument(MalBlkPtr mb, mel_arg *a, int *idx) +{ + int tpe, l; + str aname; + aname = putName(a->name); + if ( aname == 0) + throw(LOADER, "addFunctions", "Can not store argument name %s", a->name); + tpe = getAtomIndex(a->type, strlen(a->type),-1); + if (a->isbat) + tpe = newBatType(tpe); + *idx = findVariableLength(mb, aname, l = strlen(aname)); + if( *idx != -1) + throw(LOADER, "addFunctions", "Duplicate argument name %s", aname); + *idx = newVariable(mb, aname, l, tpe); + return MAL_SUCCEED; +} + +static str addFunctions(mel_func *fcn){ str msg = MAL_SUCCEED; + mel_arg *a; str mod; + int idx; Module c; Symbol s; - MalBlkPtr prg; + MalBlkPtr mb; InstrPtr sig; for(; fcn && fcn->mod; fcn++) { @@ -178,18 +198,32 @@ addFunctions(mel_func *fcn){ s = newSymbol(fcn->fcn, fcn->command ? COMMANDsymbol: PATTERNsymbol ); if ( s == NULL) throw(LOADER, "addFunctions", "Can not create symbol for %s.%s missing", fcn->mod, fcn->fcn); - prg = s->def; - if( prg == NULL) + mb = s->def; + if( mb == NULL) throw(LOADER, "addFunctions", "Can not create program block for %s.%s missing", fcn->mod, fcn->fcn); - sig= newInstruction(prg, fcn->mod, fcn->fcn); + sig= newInstruction(mb, fcn->mod, fcn->fcn); sig->retc = 0; - pushInstruction(prg, sig); if( fcn->unsafe) - prg->unsafeProp = 0; // unsafeProp; - // if( fcn->sealed) - // prg->sealedProp = sealedProp; - // if( fcn->inline) - // prg->inlineProp = inlineProp; + mb->unsafeProp = 0; + /* add the return variables */ + for ( a = fcn->res; a->name && a; a++){ + msg = makeArgument(mb, a, &idx); + if( msg) + return msg; + sig = pushReturn(mb, sig, idx); + if (sig == NULL) + throw(LOADER, "addFunctions", "Failed to keep argument name %s", a->name); + } + /* add the arguments */ + for ( a = fcn->args; a->name && a; a++){ + msg = makeArgument(mb, a, &idx); + if( msg) + return msg; + sig = pushArgument(mb, sig, idx); + if (sig == NULL) + throw(LOADER, "addFunctions", "Failed to keep argument name %s", a->name); + } + pushInstruction(mb, sig); insertSymbol(c, s); } return msg; @@ -201,6 +235,7 @@ malPrelude(Client c, int listing, int em int i; str msg = MAL_SUCCEED; + (void) listing; /* Add all atom definitions */ for(i = 0; i<mel_modules; i++) { if (embedded && strcmp(mel_module_name[i], "mal_mapi") == 0) /* skip mapi in the embedded version */ @@ -223,13 +258,18 @@ malPrelude(Client c, int listing, int em } /* Once we have all modules loaded, we should execute their prelude function for further initialization*/ +/* Unclear why we need it beyond running the MAL instructions */ +/* for(i = 0; i<mal_modules; i++) { - if (embedded && strcmp(mal_module_name[i], "mal_mapi") == 0) /* skip mapi in the embedded version */ + if (embedded && strcmp(mal_module_name[i], "mal_mapi") == 0) continue; - str msg = malIncludeString(c, mal_module_name[i], (str)mal_module_code[i], listing); - if (msg) - return msg; + if ( mal_module_code[i]){ + msg = malIncludeString(c, mal_module_name[i], (str)mal_module_code[i], listing); + if (msg) + return msg; + } } +*/ /* execute preludes */ for(i = 0; i<mal_modules; i++) { if (strcmp(mal_module_name[i], "sql") == 0) /* skip sql should be last to startup */ diff --git a/monetdb5/optimizer/opt_support.c b/monetdb5/optimizer/opt_support.c --- a/monetdb5/optimizer/opt_support.c +++ b/monetdb5/optimizer/opt_support.c @@ -226,19 +226,6 @@ isUnsafeFunction(InstrPtr q) return q->blk->unsafeProp; } -static inline int -isSealedFunction(InstrPtr q) -{ - InstrPtr p; - - if (q->fcn == 0 || getFunctionId(q) == 0 || q->blk == NULL) - return FALSE; - p= getInstrPtr(q->blk,0); - if( p->retc== 0) - return TRUE; - return q->blk->sealedProp; -} - /* * Instructions are unsafe if one of the arguments is also mentioned * in the result list. Alternatively, the 'unsafe' property is set @@ -490,7 +477,7 @@ isOrderDepenent(InstrPtr p) } inline int isMapOp(InstrPtr p){ - if (isUnsafeFunction(p) || isSealedFunction(p)) + if (isUnsafeFunction(p)) return 0; return getModuleId(p) && ((getModuleId(p) == malRef && getFunctionId(p) == multiplexRef) || @@ -504,7 +491,7 @@ inline int isMapOp(InstrPtr p){ } inline int isMap2Op(InstrPtr p){ - if (isUnsafeFunction(p) || isSealedFunction(p)) + if (isUnsafeFunction(p)) return 0; return getModuleId(p) && ((getModuleId(p) == malRef && getFunctionId(p) == multiplexRef) || _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list