Changeset: 2c69c3ca6e57 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/2c69c3ca6e57
Modified Files:
clients/Tests/exports.stable.out
monetdb5/mal/Tests/tst191.maltest
monetdb5/mal/mal.h
monetdb5/mal/mal_client.h
monetdb5/mal/mal_function.c
monetdb5/mal/mal_function.h
monetdb5/mal/mal_instruction.c
monetdb5/mal/mal_module.c
monetdb5/mal/mal_prelude.c
monetdb5/mal/mal_resolve.c
monetdb5/mal/mel.h
monetdb5/modules/mal/manual.c
monetdb5/optimizer/Tests/tst4006.maltest
monetdb5/optimizer/opt_macro.c
monetdb5/optimizer/opt_mergetable.c
tools/monetdbe/monetdbe.c
Branch: no_type_bat
Log Message:
cleanup. reduce use of getSignature
diffs (truncated from 612 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
@@ -975,7 +975,6 @@ str getExceptionPlace(const char *);
enum malexception getExceptionType(const char *);
int getFltConstant(MalBlkPtr mb, flt val);
Scenario getFreeScenario(void);
-Symbol getFunctionSymbol(Module scope, InstrPtr p);
int getHgeConstant(MalBlkPtr mb, hge val);
int getIntConstant(MalBlkPtr mb, int val);
int getLngConstant(MalBlkPtr mb, lng val);
diff --git a/monetdb5/mal/Tests/tst191.maltest
b/monetdb5/mal/Tests/tst191.maltest
--- a/monetdb5/mal/Tests/tst191.maltest
+++ b/monetdb5/mal/Tests/tst191.maltest
@@ -5,11 +5,11 @@ function welcome0(lim:int):str;
return (w,i);
end welcome0
-statement error
+statement ok
y:= user.welcome0(1)
query T rowsort
io.print(y)
----
-NULL
+"hello"
diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -108,14 +108,18 @@ mal_export const char *mal_version(void)
typedef int malType;
typedef void (*MALfcn)(void);
+#include "mel.h"
+
typedef struct SYMDEF {
struct SYMDEF *peer; /* where to look next */
struct SYMDEF *skip; /* skip to next different symbol */
const char *name;
int kind; /* what kind of symbol
*/
struct MALBLK *def; /* the details of the MAL fcn */
+ mel_func *func;
} *Symbol, SymRecord;
+
typedef struct VARRECORD {
char name[IDLENGTH]; /* use the space for the full name */
char kind; /* Could be either _, X
or C to stamp the variable type */
@@ -141,7 +145,7 @@ typedef struct VARRECORD {
* mal_profiler.c)
*/
-typedef struct {
+typedef struct INSTR {
bte token; /* instruction type */
bit barrier; /* flow of control modifier
takes:
BARRIER,
LEAVE, REDO, EXIT, CATCH, RAISE */
diff --git a/monetdb5/mal/mal_client.h b/monetdb5/mal/mal_client.h
--- a/monetdb5/mal/mal_client.h
+++ b/monetdb5/mal/mal_client.h
@@ -44,7 +44,6 @@ typedef struct CLIENT_INPUT {
struct CLIENT_INPUT *next;
} ClientInput;
-struct CLIENT;
typedef str (*init_client)(struct CLIENT *, const char *, const char *,
const char *);
typedef str (*exit_client)(struct CLIENT *);
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
@@ -64,28 +64,6 @@ newFunction(const char *mod, const char
return newFunctionArgs(mod, nme, kind, MAXARG);
}
-/*
- * Optimizers may be interested in the function definition
- * for obtaining properties. Rather than polution of the
- * instruction record with a scope reference, we use a lookup function until it
- * becomes a performance hindrance.
- */
-Symbol
-getFunctionSymbol(Module scope, InstrPtr p)
-{
- Module m;
- Symbol s;
-
- for (m = findModule(scope, getModuleId(p)); m; m = m->link)
- if (idcmp(m->name, getModuleId(p)) == 0) {
- s = m->space[getSymbolIndex(getFunctionId(p))];
- for (; s; s = s->peer)
- if (getSignature(s)->fcn == p->fcn)
- return s;
- }
- return 0;
-}
-
int
getPC(MalBlkPtr mb, InstrPtr p)
{
@@ -287,30 +265,21 @@ getBarrierEnvelop(MalBlkPtr mb)
static void
replaceTypeVar(MalBlkPtr mb, InstrPtr p, int v, malType t)
{
- int j, i, x, y;
-
- for (j = 0; j < mb->stop; j++) {
+ for (int j = 0; j < mb->stop; j++) {
p = getInstrPtr(mb, j);
- if (p->polymorphic)
- for (i = 0; i < p->argc; i++)
- if (isPolymorphic(x = getArgType(mb, p, i))) {
+ if (p->polymorphic) {
+ for (int i = 0; i < p->argc; i++) {
+ int x = getArgType(mb, p, i);
+ if (isPolymorphic(x) && getTypeIndex(x) == v) {
if (isaBatType(x)) {
- int tail;
- int tx;
- tail = getBatType(x);
- tx = getTypeIndex(x);
- if (v && tx == v && tail ==
TYPE_any) {
- tx = 0;
- tail = t;
- }
- y = newBatType(tail);
- setTypeIndex(y, tx);
- setArgType(mb, p, i, y);
- } else if (getTypeIndex(x) == v) {
+ int tail = newBatType(t);
+ setArgType(mb, p, i, tail);
+ } else {
setArgType(mb, p, i, t);
- } else {
}
}
+ }
+ }
}
}
@@ -319,18 +288,11 @@ replaceTypeVar(MalBlkPtr mb, InstrPtr p,
static void
insertSymbolBefore(Module scope, Symbol prg, Symbol before)
{
- InstrPtr sig;
int t;
Symbol s;
assert(strcmp(prg->name, before->name) == 0);
- sig = getSignature(prg);
- if (getModuleId(sig) && getModuleId(sig) != scope->name) {
- Module c = findModule(scope, getModuleId(sig));
- if (c)
- scope = c;
- }
- t = getSymbolIndex(getFunctionId(sig));
+ t = getSymbolIndex(prg->name);
assert(scope->space != NULL);
assert(scope->space[t] != NULL);
s = scope->space[t];
@@ -365,8 +327,7 @@ cloneFunction(Module scope, Symbol proc,
InstrPtr pp;
str msg = MAL_SUCCEED;
- new = newFunctionArgs(scope->name, proc->name,
getSignature(proc)->token,
- -1);
+ new = newFunctionArgs(scope->name, proc->name, proc->kind, -1);
if (new == NULL) {
return NULL;
}
@@ -382,12 +343,13 @@ cloneFunction(Module scope, Symbol proc,
if (isPolymorphic(v = getArgType(new->def, pp, i))) {
int t = getArgType(mb, p, i);
- if (v == TYPE_any)
+ if (v == TYPE_any) {
+ assert(0);
replaceTypeVar(new->def, pp, v, t);
+ }
if (isaBatType(v)) {
if (getTypeIndex(v))
- replaceTypeVar(new->def, pp,
getTypeIndex(v),
-
getBatType(t));
+ replaceTypeVar(new->def, pp,
getTypeIndex(v), getBatType(t));
} else
replaceTypeVar(new->def, pp, getTypeIndex(v),
t);
}
diff --git a/monetdb5/mal/mal_function.h b/monetdb5/mal/mal_function.h
--- a/monetdb5/mal/mal_function.h
+++ b/monetdb5/mal/mal_function.h
@@ -24,7 +24,6 @@ mal_export Symbol newFunctionArgs(const
int args);
mal_export int getPC(MalBlkPtr mb, InstrPtr p);
-mal_export Symbol getFunctionSymbol(Module scope, InstrPtr p);
mal_export str chkFlow(MalBlkPtr mb);
mal_export str chkDeclarations(MalBlkPtr mb);
mal_export void clrDeclarations(MalBlkPtr mb);
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
@@ -42,6 +42,7 @@ newSymbol(const char *nme, int kind)
{
Symbol cur;
+ assert(kind == COMMANDsymbol || kind == PATTERNsymbol || kind ==
FUNCTIONsymbol);
if (nme == NULL)
return NULL;
cur = (Symbol) GDKzalloc(sizeof(SymRecord));
@@ -1231,17 +1232,15 @@ destinationType(MalBlkPtr mb, InstrPtr p
* BATs can only have a polymorphic type at the tail.
*/
inline void
-setPolymorphic(InstrPtr p, int tpe, int force)
+setPolymorphic(InstrPtr p, int tpe, int force /* just any isn't polymorphic */)
{
- if (force == FALSE && tpe == TYPE_any)
+ int any = isAnyExpression(tpe) || tpe == TYPE_any, index = 0;
+ if ((force == FALSE && tpe == TYPE_any) || !any)
return;
- int any = isAnyExpression(tpe) || TYPE_any, index = 0;
- assert(any);
if (getTypeIndex(tpe) > 0)
index = getTypeIndex(tpe);
if (any && (index + 1) >= p->polymorphic)
p->polymorphic = index + 1;
- assert(p->polymorphic);
}
/* Instructions are simply appended to a MAL block. It should always succeed.
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
@@ -324,6 +324,7 @@ insertSymbol(Module scope, Symbol prg)
assert(scope);
sig = getSignature(prg);
if (getModuleId(sig) && getModuleId(sig) != scope->name) {
+ assert(0);
/* move the definition to the proper place */
/* default scope is the last resort */
c = findModule(scope, getModuleId(sig));
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
@@ -180,39 +180,21 @@ addAtom(mel_atom *atoms)
}
static str
-makeArgument(MalBlkPtr mb, const mel_arg *a, int *idx)
+makeArgument(MalBlkPtr mb, /*const*/ mel_arg *a, int *idx)
{
- int tpe = TYPE_any; //, l;
+ int tpe = TYPE_any;
- if (
-#ifdef MEL_STR
- !a->type[0]
-#else
- a->type == TYPE_any
-#endif
- ) {
+ if ( !a->type[0]) {
if (a->isbat)
tpe = newBatType(tpe);
if (a->nr > 0)
setTypeIndex(tpe, a->nr);
} else {
int mask = 0;
-#ifdef MEL_STR
- tpe = getAtomIndex(a->type, strlen(a->type), -1);
-#else
- tpe = a->type;
-#endif
+ a->typeid = tpe = getAtomIndex(a->type, strlen(a->type), -1);
if (a->isbat)
tpe = newBatType(tpe) | mask;
}
- /*
- if (a->name) {
- *idx = findVariableLength(mb, a->name, l = strlen(a->name));
- if (*idx != -1)
- throw(LOADER, __func__, "Duplicate argument name %s", a->name);
- *idx = newVariable(mb, a->name, l, tpe);
- } else
- */
*idx = newTmpVariable(mb, tpe);
if (*idx < 0) {
char *msg = mb->errors;
@@ -245,12 +227,13 @@ addFunctions(mel_func *fcn)
if (c == NULL && (c = globalModule(mod)) == NULL)
throw(LOADER, __func__, "Module %s can not be created",
fcn->mod);
- s = newSymbol(fcn->fcn, fcn->command ? COMMANDsymbol :
PATTERNsymbol);
+ s = newSymbol(fcn->fcn, (fcn->kind == FK_CMD) ? COMMANDsymbol :
PATTERNsymbol);
if (s == NULL)
throw(LOADER, __func__,
"Can not create symbol for %s.%s missing",
fcn->mod,
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]