Changeset: 7d79d019346d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7d79d019346d
Modified Files:
        monetdb5/mal/mal.h
        monetdb5/mal/mal_atom.c
        monetdb5/mal/mal_function.c
        monetdb5/mal/mal_module.c
        monetdb5/mal/mal_parser.c
        monetdb5/mal/mal_prelude.c
        monetdb5/mal/mal_private.h
        monetdb5/mal/mal_resolve.c
        monetdb5/mal/mal_session.c
        monetdb5/mal/mel.h
        monetdb5/optimizer/opt_evaluate.c
        monetdb5/optimizer/opt_support.c
        sql/backends/monet5/sql.c
Branch: no_type_bat
Log Message:

cleanup continues, pattern's and commands are now stored only as mel_func, no 
longer as MalBlk.


diffs (truncated from 1033 to 300 lines):

diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -151,8 +151,10 @@ typedef struct INSTR {
                                                                   BARRIER, 
LEAVE, REDO, EXIT, CATCH, RAISE */
        bit typechk;                            /* type check status */
        bte gc;                                         /* garbage control 
flags */
-       bte polymorphic;                        /* complex type analysis */
-       bit varargs;                            /* variable number of arguments 
*/
+       bte polymorphic:3,                      /* complex type analysis */
+               varargs:2,                              /* variable number of 
arguments */
+               inlineProp:1,                   /* inline property */
+               unsafeProp:1;                           /* unsafe property */
        int jump;                                       /* controlflow program 
counter */
        int pc;                                         /* location in MAL plan 
for profiler */
        MALfcn fcn;                                     /* resolved function 
address */
diff --git a/monetdb5/mal/mal_atom.c b/monetdb5/mal/mal_atom.c
--- a/monetdb5/mal/mal_atom.c
+++ b/monetdb5/mal/mal_atom.c
@@ -27,117 +27,95 @@
 #include "mal_exception.h"
 #include "mal_private.h"
 
-static void
-setAtomName(InstrPtr pci)
-{
-       char buf[FILENAME_MAX];
-       snprintf(buf, FILENAME_MAX, "#%s", getFunctionId(pci));
-       setFunctionId(pci, putName(buf));
-}
-
 str
-malAtomProperty(MalBlkPtr mb, InstrPtr pci)
+malAtomProperty(mel_func *f)
 {
        const char *name;
        int tpe;
-       (void) mb;                                      /* fool compilers */
-       assert(pci != 0);
-       name = getFunctionId(pci);
-       tpe = getAtomIndex(getModuleId(pci), strlen(getModuleId(pci)), 
TYPE_any);
+       assert(f != 0);
+       name = f->fcn;
+       tpe = getAtomIndex(f->mod, strlen(f->mod), TYPE_any);
        if (tpe < 0 || tpe >= GDKatomcnt || tpe >= MAXATOMS)
                return MAL_SUCCEED;
-       assert(pci->fcn != NULL);
+       assert(f->imp != NULL);
        switch (name[0]) {
        case 'd':
-               if (idcmp("del", name) == 0 && pci->argc == 1) {
-                       BATatoms[tpe].atomDel = (void (*)(Heap *, var_t *)) 
pci->fcn;
-                       setAtomName(pci);
+               if (idcmp("del", name) == 0 && f->argc == 1) {
+                       BATatoms[tpe].atomDel = (void (*)(Heap *, var_t *)) 
f->imp;
                        return MAL_SUCCEED;
                }
                break;
        case 'c':
-               if (idcmp("cmp", name) == 0 && pci->argc == 1) {
-                       BATatoms[tpe].atomCmp = (int (*)(const void *, const 
void *)) pci->fcn;
+               if (idcmp("cmp", name) == 0 && f->argc == 1) {
+                       BATatoms[tpe].atomCmp = (int (*)(const void *, const 
void *)) f->imp;
                        BATatoms[tpe].linear = true;
-                       setAtomName(pci);
                        return MAL_SUCCEED;
                }
                break;
        case 'f':
-               if (idcmp("fromstr", name) == 0 && pci->argc == 1) {
-                       BATatoms[tpe].atomFromStr = (ssize_t (*)(const char *, 
size_t *, ptr *, bool)) pci->fcn;
-                       setAtomName(pci);
+               if (idcmp("fromstr", name) == 0 && f->argc == 1) {
+                       BATatoms[tpe].atomFromStr = (ssize_t (*)(const char *, 
size_t *, ptr *, bool)) f->imp;
                        return MAL_SUCCEED;
                }
                break;
        case 'h':
-               if (idcmp("heap", name) == 0 && pci->argc == 1) {
+               if (idcmp("heap", name) == 0 && f->argc == 1) {
                        /* heap function makes an atom varsized */
                        BATatoms[tpe].size = sizeof(var_t);
                        assert_shift_width(ATOMelmshift(ATOMsize(tpe)), 
ATOMsize(tpe));
-                       BATatoms[tpe].atomHeap = (gdk_return (*)(Heap *, 
size_t)) pci->fcn;
-                       setAtomName(pci);
+                       BATatoms[tpe].atomHeap = (gdk_return (*)(Heap *, 
size_t)) f->imp;
                        return MAL_SUCCEED;
                }
-               if (idcmp("hash", name) == 0 && pci->argc == 1) {
-                       BATatoms[tpe].atomHash = (BUN (*)(const void *)) 
pci->fcn;
-                       setAtomName(pci);
+               if (idcmp("hash", name) == 0 && f->argc == 1) {
+                       BATatoms[tpe].atomHash = (BUN (*)(const void *)) f->imp;
                        return MAL_SUCCEED;
                }
                break;
        case 'l':
-               if (idcmp("length", name) == 0 && pci->argc == 1) {
-                       BATatoms[tpe].atomLen = (size_t (*)(const void *)) 
pci->fcn;
-                       setAtomName(pci);
+               if (idcmp("length", name) == 0 && f->argc == 1) {
+                       BATatoms[tpe].atomLen = (size_t (*)(const void *)) 
f->imp;
                        return MAL_SUCCEED;
                }
                break;
        case 'n':
-               if (idcmp("null", name) == 0 && pci->argc == 1) {
-                       const void *atmnull = ((const void *(*)(void)) 
pci->fcn)();
+               if (idcmp("null", name) == 0 && f->argc == 1) {
+                       const void *atmnull = ((const void *(*)(void)) 
f->imp)();
 
                        BATatoms[tpe].atomNull = atmnull;
-                       setAtomName(pci);
                        return MAL_SUCCEED;
                }
-               if (idcmp("nequal", name) == 0 && pci->argc == 1) {
-                       BATatoms[tpe].atomCmp = (int (*)(const void *, const 
void *)) pci->fcn;
-                       setAtomName(pci);
+               if (idcmp("nequal", name) == 0 && f->argc == 1) {
+                       BATatoms[tpe].atomCmp = (int (*)(const void *, const 
void *)) f->imp;
                        return MAL_SUCCEED;
                }
                break;
        case 'p':
-               if (idcmp("put", name) == 0 && pci->argc == 1) {
-                       BATatoms[tpe].atomPut = (var_t (*)(BAT *, var_t *, 
const void *)) pci->fcn;
-                       setAtomName(pci);
+               if (idcmp("put", name) == 0 && f->argc == 1) {
+                       BATatoms[tpe].atomPut = (var_t (*)(BAT *, var_t *, 
const void *)) f->imp;
                        return MAL_SUCCEED;
                }
                break;
        case 's':
-               if (idcmp("storage", name) == 0 && pci->argc == 1) {
-                       BATatoms[tpe].storage = (*(int (*)(void)) pci->fcn) ();
-                       setAtomName(pci);
+               if (idcmp("storage", name) == 0 && f->argc == 1) {
+                       BATatoms[tpe].storage = (*(int (*)(void)) f->imp) ();
                        return MAL_SUCCEED;
                }
                break;
        case 't':
-               if (idcmp("tostr", name) == 0 && pci->argc == 1) {
-                       BATatoms[tpe].atomToStr = (ssize_t (*)(str *, size_t *, 
const void *, bool)) pci->fcn;
-                       setAtomName(pci);
+               if (idcmp("tostr", name) == 0 && f->argc == 1) {
+                       BATatoms[tpe].atomToStr = (ssize_t (*)(str *, size_t *, 
const void *, bool)) f->imp;
                        return MAL_SUCCEED;
                }
                break;
        case 'r':
-               if (idcmp("read", name) == 0 && pci->argc == 1) {
-                       BATatoms[tpe].atomRead = (void *(*)(void *, size_t *, 
stream *, size_t)) pci->fcn;
-                       setAtomName(pci);
+               if (idcmp("read", name) == 0 && f->argc == 1) {
+                       BATatoms[tpe].atomRead = (void *(*)(void *, size_t *, 
stream *, size_t)) f->imp;
                        return MAL_SUCCEED;
                }
                break;
        case 'w':
-               if (idcmp("write", name) == 0 && pci->argc == 1) {
-                       BATatoms[tpe].atomWrite = (gdk_return (*)(const void *, 
stream *, size_t)) pci->fcn;
-                       setAtomName(pci);
+               if (idcmp("write", name) == 0 && f->argc == 1) {
+                       BATatoms[tpe].atomWrite = (gdk_return (*)(const void *, 
stream *, size_t)) f->imp;
                        return MAL_SUCCEED;
                }
                break;
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
@@ -24,8 +24,6 @@ Symbol
 newFunctionArgs(const char *mod, const char *nme, int kind, int args)
 {
        Symbol s;
-       InstrPtr p;
-       int varid;
 
        if (mod == NULL || nme == NULL)
                return NULL;
@@ -34,25 +32,27 @@ newFunctionArgs(const char *mod, const c
        if (s == NULL)
                return NULL;
 
-       varid = newVariable(s->def, nme, strlen(nme), TYPE_any);
-       if (varid < 0) {
-               freeSymbol(s);
-               return NULL;
-       }
-
-       if (args > 0) {
-               p = newInstructionArgs(NULL, mod, nme, args);
-               if (p == NULL) {
+       if (kind == FUNCTIONsymbol) {
+               int varid = newVariable(s->def, nme, strlen(nme), TYPE_any);
+               if (varid < 0) {
                        freeSymbol(s);
                        return NULL;
                }
-               p->token = kind;
-               p->barrier = 0;
-               setDestVar(p, varid);
-               pushInstruction(s->def, p);
-               if (s->def->errors) {
-                       freeSymbol(s);
-                       return NULL;
+
+               if (args > 0) {
+                       InstrPtr p = newInstructionArgs(NULL, mod, nme, args);
+                       if (p == NULL) {
+                               freeSymbol(s);
+                               return NULL;
+                       }
+                       p->token = kind;
+                       p->barrier = 0;
+                       setDestVar(p, varid);
+                       pushInstruction(s->def, p);
+                       if (s->def->errors) {
+                               freeSymbol(s);
+                               return NULL;
+                       }
                }
        }
        return s;
diff --git a/monetdb5/mal/mal_module.c b/monetdb5/mal/mal_module.c
--- a/monetdb5/mal/mal_module.c
+++ b/monetdb5/mal/mal_module.c
@@ -44,11 +44,18 @@ findFunctionImplementation(const char *c
                                Symbol s;
                                if ((s = moduleIndex[i]->space[j]) != NULL) {
                                        do {
-                                               if (s->def &&
-                                                       strcmp(s->def->binding, 
cname) == 0 &&
-                                                       s->def->stmt 
&&s->def->stmt[0] &&
-                                                       s->def->stmt[0]->fcn) {
-                                                       return 
s->def->stmt[0]->fcn;
+                                               if (s->kind != FUNCTIONsymbol) {
+                                                       if (s->func && 
s->func->cname &&
+                                                               
strcmp(s->func->cname, cname) == 0)
+                                                               return 
s->func->imp;
+                                               } else {
+                                                       if (s->def &&
+                                                               
strcmp(s->def->binding, cname) == 0 &&
+                                                               s->def->stmt 
&&s->def->stmt[0] &&
+                                                               
s->def->stmt[0]->fcn) {
+                                                               assert(0);
+                                                               return 
s->def->stmt[0]->fcn;
+                                                       }
                                                }
                                        } while ((s = s->peer) != NULL);
                                }
@@ -288,7 +295,7 @@ freeModule(Module m)
        if (m == NULL)
                return;
        if ((s = findSymbolInModule(m, "epilogue")) != NULL) {
-               if (s->kind == COMMANDsymbol && s->func->argc == 1) {
+               if (s->kind == COMMANDsymbol && s->func->argc <= 1 /* zero or 
one arg */) {
                        int status = 0;
                        str ret = MAL_SUCCEED;
 
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
@@ -1217,7 +1217,7 @@ parseInclude(Client cntxt)
  * of return values so that we can allocate enough space in the
  * instruction; returns -1 on error (missing closing parenthesis) */
 static int
-cntArgsReturns(Client cntxt)
+cntArgsReturns(Client cntxt, int *retc)
 {
        size_t yycur = cntxt->yycur;
        int cnt = 0;
@@ -1244,9 +1244,12 @@ cntArgsReturns(Client cntxt)
                advance(cntxt, 1);
                ch = currChar(cntxt);
                cnt++;
+               (*retc)++;
                while (ch != ')' && ch && !NL(ch)) {
-                       if (ch == ',')
+                       if (ch == ',') {
                                cnt++;
+                               (*retc)++;
+                       }
                        nextChar(cntxt);
                        ch = currChar(cntxt);
                }
@@ -1257,26 +1260,349 @@ cntArgsReturns(Client cntxt)
                }
        } else {
                cnt++;
+               (*retc)++;
        }
        cntxt->yycur = yycur;
        return cnt;
 }
 
+static void
+mf_destroy(mel_func *f)
+{
+       if (f) {
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to