Changeset: 3ad12a3e2e69 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3ad12a3e2e69
Modified Files:
monetdb5/mal/mal_resolve.c
monetdb5/mal/mal_resolve.h
monetdb5/modules/mal/manifold.c
monetdb5/optimizer/opt_generator.c
monetdb5/optimizer/opt_matpack.c
monetdb5/optimizer/opt_pipes.c
monetdb5/optimizer/opt_postfix.c
monetdb5/optimizer/opt_remap.c
Branch: gdk_tracer
Log Message:
more getPC fixes
diffs (truncated from 414 to 300 lines):
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
@@ -31,7 +31,7 @@ static int typeKind(MalBlkPtr mb, InstrP
* Beware that polymorphic functions may produce type-incorrect clones.
* This piece of code may be shared by the separate binder
*/
-#define bindFunction(s, p, mb)
\
+#define bindFunction(s, p, idx, mb)
\
do {
\
if (p->token == ASSIGNsymbol) {
\
switch (getSignature(s)->token) {
\
@@ -39,7 +39,7 @@ static int typeKind(MalBlkPtr mb, InstrP
p->token = CMDcall;
\
p->fcn = getSignature(s)->fcn; /* C
implementation mandatory */ \
if (p->fcn == NULL) {
\
- if(!silent) mb->errors =
createMalException(mb, getPC(mb, p), TYPE, \
+ if(!silent) mb->errors =
createMalException(mb, idx, TYPE, \
"object code for command %s.%s missing", \
p->modname, p->fcnname); \
p->typechk = TYPE_UNKNOWN;
\
@@ -60,7 +60,7 @@ static int typeKind(MalBlkPtr mb, InstrP
p->fcn = getSignature(s)->fcn; /* C
implementation optional */ \
break;
\
default: {
\
- if(!silent) mb->errors =
createMalException(mb, getPC(mb, p), MAL, \
+ if(!silent) mb->errors =
createMalException(mb, idx, MAL, \
"MALresolve: unexpected token type"); \
goto wrapup;
\
}
\
@@ -86,7 +86,7 @@ static int typeKind(MalBlkPtr mb, InstrP
} while (0)
static malType
-findFunctionType(Module scope, MalBlkPtr mb, InstrPtr p, int silent)
+findFunctionType(Module scope, MalBlkPtr mb, InstrPtr p, int idx, int silent)
{
Module m;
Symbol s;
@@ -358,13 +358,13 @@ findFunctionType(Module scope, MalBlkPtr
* Also mark all variables that are subject to garbage control.
* Beware, this is not yet effectuated in the interpreter.
*/
- debugInstruction(MAL_RESOLVE, mb, 0, p, getPC(mb, p),
LIST_MAL_DEBUG);
+ debugInstruction(MAL_RESOLVE, mb, 0, p, idx, LIST_MAL_DEBUG);
p->typechk = TYPE_RESOLVED;
for (i = 0; i < p->retc; i++) {
int ts = returntype[i];
if (isVarConstant(mb, getArg(p, i))) {
- if(!silent) { mb->errors =
createMalException(mb, getPC(mb, p), TYPE, "Assignment to constant"); }
+ if(!silent) { mb->errors =
createMalException(mb, idx, TYPE, "Assignment to constant"); }
p->typechk = TYPE_UNKNOWN;
goto wrapup;
}
@@ -423,7 +423,7 @@ findFunctionType(Module scope, MalBlkPtr
goto wrapup;
}
\
*/
- bindFunction(s, p, mb);
+ bindFunction(s, p, idx, mb);
if (returntype != returns)
GDKfree(returntype);
@@ -480,7 +480,7 @@ resolveType(int dsttype, int srctype)
* because they may be resolved as part of the calling sequence.
*/
static void
-typeMismatch(MalBlkPtr mb, InstrPtr p, int lhs, int rhs, int silent)
+typeMismatch(MalBlkPtr mb, InstrPtr p, int idx, int lhs, int rhs, int silent)
{
str n1;
str n2;
@@ -488,7 +488,7 @@ typeMismatch(MalBlkPtr mb, InstrPtr p, i
if (!silent) {
n1 = getTypeName(lhs);
n2 = getTypeName(rhs);
- mb->errors = createMalException(mb, getPC(mb, p), TYPE, "type
mismatch %s := %s", n1, n2);
+ mb->errors = createMalException(mb, idx, TYPE, "type mismatch
%s := %s", n1, n2);
GDKfree(n1);
GDKfree(n2);
}
@@ -508,7 +508,7 @@ typeMismatch(MalBlkPtr mb, InstrPtr p, i
* to assignment.
*/
void
-typeChecker(Module scope, MalBlkPtr mb, InstrPtr p, int silent)
+typeChecker(Module scope, MalBlkPtr mb, InstrPtr p, int idx, int silent)
{
int s1 = -1, i, k;
Module m = 0;
@@ -533,7 +533,7 @@ typeChecker(Module scope, MalBlkPtr mb,
}
if (getFunctionId(p) && getModuleId(p)) {
m = findModule(scope, getModuleId(p));
- s1 = findFunctionType(m, mb, p, silent);
+ s1 = findFunctionType(m, mb, p, idx, silent);
if (s1 >= 0)
return;
@@ -553,14 +553,14 @@ typeChecker(Module scope, MalBlkPtr mb,
if (!silent) {
char *errsig;
if (!malLibraryEnabled(p->modname)) {
- mb->errors = createMalException(mb,
getPC(mb, p), TYPE,
+ mb->errors = createMalException(mb,
idx, TYPE,
"'%s%s%s' library error in: %s",
(getModuleId(p) ? getModuleId(p) : ""),
(getModuleId(p) ? "." : ""),
getFunctionId(p), malLibraryHowToEnable(p->modname));
} else {
- errsig = instruction2str(mb,0,p,
getPC(mb, p), (LIST_MAL_NAME | LIST_MAL_TYPE | LIST_MAL_VALUE));
- mb->errors = createMalException(mb,
getPC(mb, p), TYPE,
+ errsig = instruction2str(mb,0,p, idx,
(LIST_MAL_NAME | LIST_MAL_TYPE | LIST_MAL_VALUE));
+ mb->errors = createMalException(mb,
idx, TYPE,
"'%s%s%s' undefined in: %s",
(getModuleId(p) ? getModuleId(p) : ""),
(getModuleId(p) ? "." : ""),
@@ -584,7 +584,7 @@ typeChecker(Module scope, MalBlkPtr mb,
}
if (p->retc >= 1 && p->argc > p->retc && p->argc != 2 * p->retc) {
if (!silent){
- mb->errors = createMalException(mb, getPC(mb, p),
TYPE, "Multiple assignment mismatch");
+ mb->errors = createMalException(mb, idx, TYPE,
"Multiple assignment mismatch");
}
p->typechk = TYPE_RESOLVED;
} else
@@ -596,7 +596,7 @@ typeChecker(Module scope, MalBlkPtr mb,
if (rhs != TYPE_void) {
s1 = resolveType(lhs, rhs);
if (s1 == -1) {
- typeMismatch(mb, p, lhs, rhs, silent);
+ typeMismatch(mb, p, idx, lhs, rhs, silent);
return;
}
} else {
@@ -660,7 +660,7 @@ chkTypes(Module s, MalBlkPtr mb, int sil
p = getInstrPtr(mb, i);
assert (p != NULL);
if (p->typechk != TYPE_RESOLVED)
- typeChecker(s, mb, p, silent);
+ typeChecker(s, mb, p, i, silent);
if (mb->errors)
return;
}
@@ -675,7 +675,7 @@ chkInstruction(Module s, MalBlkPtr mb, I
{
if( mb->errors == MAL_SUCCEED){
p->typechk = TYPE_UNKNOWN;
- typeChecker(s, mb, p, TRUE);
+ typeChecker(s, mb, p, getPC(mb, p), TRUE);
}
return mb->errors != MAL_SUCCEED;
}
diff --git a/monetdb5/mal/mal_resolve.h b/monetdb5/mal/mal_resolve.h
--- a/monetdb5/mal/mal_resolve.h
+++ b/monetdb5/mal/mal_resolve.h
@@ -19,7 +19,7 @@
mal_export void chkProgram(Module s, MalBlkPtr mb);
mal_export int chkInstruction(Module s, MalBlkPtr mb, InstrPtr p);
mal_export void chkTypes(Module s, MalBlkPtr mb, int silent);
-mal_export void typeChecker(Module scope, MalBlkPtr mb, InstrPtr p, int
silent);
+mal_export void typeChecker(Module scope, MalBlkPtr mb, InstrPtr p, int p_idx,
int silent);
/*
* @- Type resolution algorithm.
diff --git a/monetdb5/modules/mal/manifold.c b/monetdb5/modules/mal/manifold.c
--- a/monetdb5/modules/mal/manifold.c
+++ b/monetdb5/modules/mal/manifold.c
@@ -233,7 +233,7 @@ MANIFOLDtypecheck(Client cntxt, MalBlkPt
debugInstruction(MAL_MANIFOLD, nmb, 0, q, getPC(nmb, q), LIST_MAL_ALL);
// Localize the underlying scalar operator
- typeChecker(cntxt->usermodule, nmb, q, TRUE);
+ typeChecker(cntxt->usermodule, nmb, q, getPC(nmb, q), TRUE);
if (nmb->errors || q->fcn == NULL || q->token != CMDcall ||
(checkprops && q->blk && q->blk->unsafeProp) )
fcn = NULL;
diff --git a/monetdb5/optimizer/opt_generator.c
b/monetdb5/optimizer/opt_generator.c
--- a/monetdb5/optimizer/opt_generator.c
+++ b/monetdb5/optimizer/opt_generator.c
@@ -15,15 +15,15 @@
* Series generating module for integer, decimal, real, double and timestamps.
*/
-#define errorCheck(P,MOD,I) \
+#define errorCheck(P,IDX,MOD,I) \
setModuleId(P, generatorRef);\
-typeChecker(cntxt->usermodule, mb, P, TRUE);\
+typeChecker(cntxt->usermodule, mb, P, IDX, TRUE);\
if(P->typechk == TYPE_UNKNOWN){\
setModuleId(P,MOD);\
- typeChecker(cntxt->usermodule, mb, P, TRUE);\
+ typeChecker(cntxt->usermodule, mb, P, IDX, TRUE);\
setModuleId(series[I], generatorRef);\
setFunctionId(series[I], seriesRef);\
- typeChecker(cntxt->usermodule, mb, series[I], TRUE);\
+ typeChecker(cntxt->usermodule, mb, series[I], I, TRUE);\
}\
pushInstruction(mb,P);
@@ -33,20 +33,20 @@ pushInstruction(mb,P);
q= newInstruction(0,calcRef, TPE##Ref);\
setDestVar(q, newTmpVariable(mb, TYPE_##TPE));\
addArgument(mb,q,getArg(series[k],1));\
- typeChecker(cntxt->usermodule, mb, q, TRUE);\
+ typeChecker(cntxt->usermodule, mb, q, 0, TRUE);\
p = addArgument(mb,p, getArg(q,0));\
pushInstruction(mb,q);\
q= newInstruction(0,calcRef,TPE##Ref);\
setDestVar(q, newTmpVariable(mb, TYPE_##TPE));\
addArgument(mb,q,getArg(series[k],2));\
pushInstruction(mb,q);\
- typeChecker(cntxt->usermodule, mb, q, TRUE);\
+ typeChecker(cntxt->usermodule, mb, q, 0, TRUE);\
p = addArgument(mb,p, getArg(q,0));\
if( p->argc == 4){\
q= newInstruction(0,calcRef,TPE##Ref);\
setDestVar(q, newTmpVariable(mb, TYPE_##TPE));\
addArgument(mb,q,getArg(series[k],3));\
- typeChecker(cntxt->usermodule, mb, q, TRUE);\
+ typeChecker(cntxt->usermodule, mb, q, 0, TRUE);\
p = addArgument(mb,p, getArg(q,0));\
pushInstruction(mb,q);\
}\
@@ -110,14 +110,14 @@ OPTgeneratorImplementation(Client cntxt,
series[getArg(p,0)] = p;
setModuleId(p, generatorRef);
setFunctionId(p, parametersRef);
- typeChecker(cntxt->usermodule, mb, p, TRUE);
+ typeChecker(cntxt->usermodule, mb, p, i, TRUE);
pushInstruction(mb,p);
} else if ( getModuleId(p) == algebraRef && getFunctionId(p) ==
selectRef && series[getArg(p,1)]){
- errorCheck(p,algebraRef,getArg(p,1));
+ errorCheck(p,i, algebraRef,getArg(p,1));
} else if ( getModuleId(p) == algebraRef && getFunctionId(p) ==
thetaselectRef && series[getArg(p,1)]){
- errorCheck(p,algebraRef,getArg(p,1));
+ errorCheck(p,i,algebraRef,getArg(p,1));
} else if ( getModuleId(p) == algebraRef && getFunctionId(p) ==
projectionRef && series[getArg(p,2)]){
- errorCheck(p,algebraRef,getArg(p,2));
+ errorCheck(p,i,algebraRef,getArg(p,2));
} else if ( getModuleId(p) == sqlRef && getFunctionId(p) ==
putName("exportValue") && isaBatType(getArgType(mb,p,0)) ){
// interface expects scalar type only, not expressable
in MAL signature
mb->errors=createException(MAL, "generate_series",
SQLSTATE(42000) "internal error, generate_series is a table producing
function");
@@ -141,13 +141,15 @@ OPTgeneratorImplementation(Client cntxt,
if( series[getArg(p,k)]){
m = getModuleId(p);
setModuleId(p, generatorRef);
- typeChecker(cntxt->usermodule, mb, p, TRUE);
+ typeChecker(cntxt->usermodule, mb, p, i, TRUE);
if(p->typechk == TYPE_UNKNOWN){
setModuleId(p,m);
- typeChecker(cntxt->usermodule, mb, p,
TRUE);
- setModuleId(series[getArg(p,k)],
generatorRef);
- setFunctionId(series[getArg(p,k)],
seriesRef);
- typeChecker(cntxt->usermodule, mb,
series[getArg(p,k)], TRUE);
+ typeChecker(cntxt->usermodule, mb, p,
i, TRUE);
+
+ InstrPtr r = series[getArg(p,k)];
+ setModuleId(r, generatorRef);
+ setFunctionId(r, seriesRef);
+ typeChecker(cntxt->usermodule, mb, r,
getPC(mb,r), TRUE);
}
}
pushInstruction(mb,p);
diff --git a/monetdb5/optimizer/opt_matpack.c b/monetdb5/optimizer/opt_matpack.c
--- a/monetdb5/optimizer/opt_matpack.c
+++ b/monetdb5/optimizer/opt_matpack.c
@@ -51,7 +51,7 @@ OPTmatpackImplementation(Client cntxt, M
v = getArg(q,0);
q = pushInt(mb,q, p->argc - p->retc);
pushInstruction(mb,q);
- typeChecker(cntxt->usermodule,mb,q,TRUE);
+ typeChecker(cntxt->usermodule,mb,q, mb->stop-1, TRUE);
for ( j = 2; j < p->argc; j++) {
q = newInstruction(0, matRef, packIncrementRef);
@@ -60,7 +60,7 @@ OPTmatpackImplementation(Client cntxt, M
setDestVar(q, newTmpVariable(mb,
getVarType(mb,v)));
v = getArg(q,0);
pushInstruction(mb,q);
- typeChecker(cntxt->usermodule,mb,q,TRUE);
+ typeChecker(cntxt->usermodule,mb,q, mb->stop-1,
TRUE);
}
getArg(q,0) = getArg(p,0);
freeInstruction(p);
diff --git a/monetdb5/optimizer/opt_pipes.c b/monetdb5/optimizer/opt_pipes.c
--- a/monetdb5/optimizer/opt_pipes.c
+++ b/monetdb5/optimizer/opt_pipes.c
@@ -541,7 +541,7 @@ addOptimizerPipe(Client cntxt, MalBlkPtr
throw(MAL, "optimizer.addOptimizerPipe",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
for (k = 0; k < p->argc; k++)
getArg(p, k) = cloneVariable(mb, pipes[i].mb,
getArg(p, k));
- typeChecker(cntxt->usermodule, mb, p, FALSE);
+ typeChecker(cntxt->usermodule, mb, p, j, FALSE);
pushInstruction(mb, p);
}
}
diff --git a/monetdb5/optimizer/opt_postfix.c b/monetdb5/optimizer/opt_postfix.c
--- a/monetdb5/optimizer/opt_postfix.c
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list