Changeset: 08c0b109e5c5 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=08c0b109e5c5
Modified Files:
monetdb5/mal/mal_dataflow.mx
monetdb5/mal/mal_parser.mx
monetdb5/modules/mal/Makefile.ag
monetdb5/modules/mal/batExtensions.mx
monetdb5/modules/mal/extensions.mx
monetdb5/modules/mal/inspect.mx
monetdb5/modules/mal/language.mx
monetdb5/modules/mal/mal_init.mal
monetdb5/modules/mal/mal_mapi.mx
monetdb5/modules/mal/manual.c
monetdb5/modules/mal/manual.mal
monetdb5/modules/mal/recycle.c
Branch: headless
Log Message:
The Mx-cleansweep continues.
diffs (truncated from 2071 to 300 lines):
diff --git a/monetdb5/mal/mal_dataflow.mx b/monetdb5/mal/mal_dataflow.mx
--- a/monetdb5/mal/mal_dataflow.mx
+++ b/monetdb5/mal/mal_dataflow.mx
@@ -18,12 +18,12 @@
@
@h
-#ifndef _MAL_INTERPRET_H
-#define _MAL_INTERPRET_H
+#ifndef _MAL_DATAFLOW_H
+#define _MAL_DATAFLOW_H
#include "mal_interpreter.h"
-/*#define DEBUG_MAL_INTERPRETER*/
+/*#define DEBUG_MAL_DATAFLOWER*/
/* #define DEBUG_FLOW */
/* #define DEBUG_FLOW2 */
/* #define DEBUG_MEMORY_CLAIM*/
@@ -31,7 +31,7 @@
mal_export str runMALdataflow( Client cntxt, MalBlkPtr mb, int startpc,
int stoppc, MalStkPtr stk, MalStkPtr env, InstrPtr pcicaller);
-#endif /* _MAL_INTERPRET_H*/
+#endif /* _MAL_DATAFLOW_H*/
@c
/* Author(s) M.L. Kersten, N. Nes
* The MAL Dataflow Driven Interpreter
diff --git a/monetdb5/mal/mal_parser.mx b/monetdb5/mal/mal_parser.mx
--- a/monetdb5/mal/mal_parser.mx
+++ b/monetdb5/mal/mal_parser.mx
@@ -780,6 +780,7 @@
}
return i+1;
}
+
/* The Parser
* The client is responsible to collect the
* input for parsing in a single string before calling the parser.
@@ -815,6 +816,189 @@
*
* An atom statement does not introduce a new module.
*/
+void
+helpInfo(Client cntxt, str *help)
+{
+ int l;
+
+ if( MALkeyword(cntxt,"comment",7)){
+ skipSpace(cntxt);
+ if( (l= stringLength(cntxt))){
+ *help = strCopy(cntxt,l);
+ if (*help )
+ advance(cntxt,l-1);
+ } else {
+ parseError(cntxt,"<string> expected\n");
+ }
+ } else
+ if (currChar(cntxt) != ';')
+ parseError(cntxt,"';' expected\n");
+ skipToEnd(cntxt);
+}
+
+void
+propList(Client cntxt, int arg)
+{
+ MalBlkPtr curBlk= cntxt->curprg->def;
+ int l;
+ if( keyphrase1(cntxt,"{")) {
+ do {
+ str pname,opname;
+ int i,lo;
+ ValRecord cst;
+
+ l = idLength(cntxt);
+ if(l==0)
+ break;
+ pname= idCopy(cntxt,l);
+ /* localize value , simplified version */
+ lo= operatorLength(cntxt);
+ if( lo > 0)
+ opname= operatorCopy(cntxt,lo);
+ else
+ opname= GDKstrdup("");
+ if ((i= cstToken(cntxt,&cst))){
+ int csttpe;
+ advance(cntxt,i);
+ if( currChar(cntxt)==':') {
+ csttpe = simpleTypeId(cntxt);
+ if ( csttpe >= 0)
+ convertConstant(csttpe,&cst);
+ else
+ parseError(cntxt,"simple type
expected\n");
+ }
+ varSetProperty(curBlk,arg, pname, opname, &cst);
+ } else {
+ varSetProperty(curBlk,arg, pname, NULL, NULL);
+ }
+ GDKfree(pname);
+ GDKfree(opname);
+ } while( keyphrase1(cntxt,","));
+ if( !keyphrase1(cntxt,"}") )
+ /* return (MalBlkPtr) */
+ parseError(cntxt,"'}' expected\n");
+ }
+}
+
+InstrPtr
+binding(Client cntxt, MalBlkPtr curBlk, InstrPtr curInstr, int flag)
+{
+ int l, varid, type;
+ l = idLength(cntxt);
+ if( l>0) {
+ varid = findVariableLength(curBlk, CURRENT(cntxt), l);
+ if( varid < 0){
+ varid = newVariable(curBlk,idCopy(cntxt,l),TYPE_any);
+ type= typeElm(cntxt,TYPE_any);
+ if( isaTypeVar(type) )
+ setPolymorphic(curInstr,type,TRUE);
+ setVarType(curBlk,varid,type);
+ propList(cntxt,varid);
+ } else
+ if(flag){
+ parseError(cntxt,"Argument defined twice\n");
+ typeElm(cntxt,getVarType(curBlk,varid));
+ propList(cntxt,varid);
+ } else {
+ advance(cntxt,l);
+ type= typeElm(cntxt,getVarType(curBlk,varid));
+ if( type != getVarType(curBlk,varid))
+ parseError(cntxt,"Incompatible argument
type\n");
+ if( isaTypeVar(type) )
+ setPolymorphic(curInstr,type,TRUE);
+ setVarType(curBlk,varid,type);
+ propList(cntxt,varid);
+ }
+ } else if( currChar(cntxt)== ':' ){
+ type= typeElm(cntxt,TYPE_any);
+ varid = newTmpVariable(curBlk,type);
+ if( isaTypeVar(type) )
+ setPolymorphic(curInstr,type,TRUE);
+ setVarType(curBlk,varid,type);
+ propList(cntxt,varid);
+ } else
+ parseError(cntxt,"argument expected\n");
+ curInstr= pushArgument(curBlk,curInstr, varid);
+ return curInstr;
+}
+
+/*
+ * At this stage the LHS part has been parsed and the destination
+ * variables have been set. Next step is to parse the expression,
+ * which starts with an operand.
+ * This code is used in both positions of the expression
+*/
+int
+term(Client cntxt, MalBlkPtr curBlk, InstrPtr curInstr, int ret)
+{
+ int i, idx, flag, free = 1;
+ ValRecord cst;
+ str v = NULL;
+ int cstidx = -1,csttpe= TYPE_any;
+
+ if( (i= cstToken(cntxt,&cst))){
+
+ cstidx = fndConstant(curBlk,&cst);
+ if( cstidx >= 0){
+ advance(cntxt,i);
+ if( currChar(cntxt)==':') {
+ csttpe =
typeElm(cntxt,getVarType(curBlk,cstidx));
+ if( csttpe<0)
+ return 3;
+ if(csttpe == getVarType(curBlk,cstidx) ){
+ setVarFixed(curBlk,cstidx);
+ } else {
+ cstidx =
defConstant(curBlk,csttpe,&cst);
+ setPolymorphic(curInstr,csttpe, FALSE);
+ setVarFixed(curBlk,cstidx);
+ free = 0;
+ }
+ } else if( cst.vtype != getVarType(curBlk,cstidx)){
+ cstidx = defConstant(curBlk,cst.vtype,&cst);
+ setPolymorphic(curInstr,cst.vtype, FALSE);
+ free = 0;
+ }
+ /* protect against leaks coming from constant reuse */
+ if (free && ATOMextern(cst.vtype) && cst.val.pval)
+ VALclear(&cst);
+ curInstr = pushArgument(curBlk,curInstr,cstidx);
+ return ret;
+ } else {
+ /* add a new constant */
+ advance(cntxt,i);
+ flag= currChar(cntxt)==':';
+ csttpe = typeElm(cntxt,cst.vtype);
+ if( csttpe<0)
+ return 3;
+ cstidx = defConstant(curBlk,csttpe,&cst);
+ setPolymorphic(curInstr,csttpe, FALSE);
+ if( flag )
+ setVarFixed(curBlk,cstidx);
+ curInstr = pushArgument(curBlk,curInstr,cstidx);
+ return ret;
+ }
+ } else if( (i= idLength(cntxt))){
+ if( (idx=findVariableLength(curBlk,CURRENT(cntxt),i)) == -1){
+ v= idCopy(cntxt,i);
+ idx = newVariable(curBlk, v, TYPE_any);
+ propList(cntxt,idx);
+ } else {
+ advance(cntxt,i);
+ propList(cntxt,idx);
+ }
+ curInstr= pushArgument(curBlk,curInstr,idx);
+ } else if (currChar(cntxt) == ':'){
+ i = typeElm(cntxt,TYPE_any);
+ if( i<0)
+ return 3;
+ setPolymorphic(curInstr,i,FALSE);
+ idx = newTypeVariable(curBlk, i );
+ propList(cntxt,idx);
+ curInstr = pushArgument(curBlk,curInstr,idx);
+ return ret;
+ }
+ return 0;
+}
str
parseAtom(Client cntxt)
{
@@ -835,7 +1019,7 @@
cntxt->nspace = fixModule(cntxt->nspace, modnme);
cntxt->nspace->isAtomModule = TRUE;
skipSpace(cntxt);
- @:helpInfo(cntxt->nspace->help) @
+ helpInfo(cntxt, &cntxt->nspace->help);
return "";
}
@@ -879,7 +1063,7 @@
advance(cntxt,l);
cntxt->nspace = fixModule(cntxt->nspace, modnme);
skipSpace(cntxt);
- @:helpInfo(cntxt->nspace->help)@
+ helpInfo(cntxt, &cntxt->nspace->help);
return "";
}
/*
@@ -969,8 +1153,16 @@
* Note, the function name could be mod.fcn, which calls for storing
* the function definition in a particular module instead of the current one.
*/
-@-
-@= fcnHeader
+MalBlkPtr
+fcnHeader(Client cntxt,int kind)
+{
+ int l,type;
+ str fnme,modnme;
+ char ch;
+ Symbol curPrg;
+ MalBlkPtr curBlk;
+ InstrPtr curInstr;
+
l = operatorLength(cntxt);
if (l == 0)
l = idLength(cntxt);
@@ -1004,7 +1196,7 @@
curBlk->flowfixed= 0;
curBlk->typefixed= 0;
curInstr = getInstrPtr(curBlk,0);
- @:propList(curInstr->argv[0])@
+ propList(cntxt,curInstr->argv[0]);
if (currChar(cntxt) != '(')
return (MalBlkPtr)parseError(cntxt, "function header '('
expected\n");
@@ -1019,7 +1211,7 @@
/* get calling parameters */
ch= currChar(cntxt);
while( ch !=')' && ch && !NL(ch)){
- @:binding(1)@
+ curInstr= binding(cntxt, curBlk, curInstr, 1);
/* the last argument may be variable length */
if( MALkeyword(cntxt,"...",3) ){
curInstr->varargs |= VARARGS;
@@ -1055,7 +1247,7 @@
setPolymorphic(curInstr,TYPE_any,TRUE);
}
- @:propList(curInstr->argv[0])@
+ propList(cntxt,curInstr->argv[0]);
} else
if( keyphrase1(cntxt,"(")){ /* deal with compound return */
int retc= curInstr->argc, i1,i2=0;
@@ -1065,9 +1257,7 @@
/* skipSpace(cntxt);*/
ch= currChar(cntxt);
while( ch !=')' && ch && !NL(ch)){
- int varid=0;
- int type= TYPE_any;
- @:binding(0)@
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list