Changeset: a5cdf5047c1b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a5cdf5047c1b
Modified Files:
monetdb5/mal/Makefile.ag
monetdb5/mal/mal_module.c
monetdb5/mal/mal_module.h
monetdb5/mal/mal_module.mx
monetdb5/mal/mal_session.c
monetdb5/mal/mal_session.h
sql/backends/monet5/sql_scenario.c
Branch: default
Log Message:
fixed MSresetClientPrg, don't zap mod/func name (solves duplicate symbol
insertion in the namespace)
Breaks ABI
diffs (truncated from 538 to 300 lines):
diff --git a/monetdb5/mal/Makefile.ag b/monetdb5/mal/Makefile.ag
--- a/monetdb5/mal/Makefile.ag
+++ b/monetdb5/mal/Makefile.ag
@@ -42,7 +42,7 @@ lib_mal = {
mal_instruction.mx \
mal_interpreter.mx \
mal_linker.c mal_linker.h \
- mal_module.mx \
+ mal_module.c mal_module.h \
mal_namespace.c mal_namespace.h \
mal_parser.mx \
mal_profiler.mx \
diff --git a/monetdb5/mal/mal_module.mx b/monetdb5/mal/mal_module.c
rename from monetdb5/mal/mal_module.mx
rename to monetdb5/mal/mal_module.c
--- a/monetdb5/mal/mal_module.mx
+++ b/monetdb5/mal/mal_module.c
@@ -1,24 +1,24 @@
-@/
-The contents of this file are subject to the MonetDB Public License
-Version 1.1 (the "License"); you may not use this file except in
-compliance with the License. You may obtain a copy of the License at
-http://www.monetdb.org/Legal/MonetDBLicense
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.monetdb.org/Legal/MonetDBLicense
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2011 MonetDB B.V.
+ * All Rights Reserved.
+ */
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is the MonetDB Database System.
-
-The Initial Developer of the Original Code is CWI.
-Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
-Copyright August 2008-2011 MonetDB B.V.
-All Rights Reserved.
-@
-
-@c
/*
+ * @f mal_module
* @a M. L. Kersten
* @+ Module Management
*
@@ -46,85 +46,6 @@ All Rights Reserved.
* anymore.
* Care should be taken not to generate many unique function names.
*/
-@h
-#ifndef _MAL_SCOPE_H_
-#define _MAL_SCOPE_H_
-#include "mal_box.h"
-#include "mal_xml.h"
-
-/* #define MAL_SCOPE_DEBUG */
-
-#define MAXSCOPE 256
-
-typedef struct SCOPEDEF {
- struct SCOPEDEF *outer; /* outer level in the scope tree */
- struct SCOPEDEF *sibling; /* module with same start */
- str name; /* index in namespace */
- int inheritance; /* set when it plays a role in
inheritance */
- Symbol *subscope; /* type dispatcher table */
- Box box; /* module related objects */
- int isAtomModule; /* atom module definition ? */
- void *dll; /* dlopen handle */
- str help; /* short description of module
functionality*/
-} *Module, ModuleRecord;
-
-
-mal_export void setModuleJump(str nme, Module cur);
-mal_export Module newModule(Module scope, str nme);
-mal_export Module fixModule(Module scope, str nme);
-mal_export void deriveModule(Module scope, str nme);
-mal_export void freeModule(Module cur);
-mal_export void freeModuleList(Module cur);
-mal_export void insertSymbol(Module scope, Symbol prg);
-mal_export void deleteSymbol(Module scope, Symbol prg);
-mal_export void setInheritanceMode(Module head,int flag);
-mal_export Module setInheritance(Module head,Module first, Module second);
-mal_export Module findModule(Module scope, str name);
-mal_export Symbol findSymbol(Module nspace, str mod, str fcn);
-mal_export int isModuleDefined(Module scope, str name);
-mal_export Symbol findSymbolInModule(Module v, str fcn);
-mal_export int findInstruction(Module scope, MalBlkPtr mb, InstrPtr
pci);
-mal_export int displayModule(stream *f, Module v, str fcn,int listing);
-mal_export void showModules(stream *f, Module v);
-mal_export void debugModule(stream *f, Module v, str nme);
-mal_export void dumpManual(stream *f, Module v, int recursive);
-mal_export void dumpManualSection(stream *f, Module v);
-mal_export void dumpManualHelp(stream *f, Module s, int recursive);
-mal_export void dumpHelpTable(stream *f, Module s, str text, int flag);
-mal_export void dumpSearchTable(stream *f, str text);
-mal_export void dumpManualOverview(stream *f, Module v, int recursive);
-mal_export void dumpManualHeader(stream *f);
-mal_export void dumpManualFooter(stream *f);
-mal_export void showModuleStatistics(stream *f,Module s); /* used in
src/mal/mal_debugger.c */
-mal_export char **getHelp(Module m, str pat, int flag);
-mal_export char **getHelpMatch(char *pat);
-mal_export void showHelp(Module m, str txt,stream *fs);
-
-#define getSubScope(N) (*(N))
-
-#endif /* _MAL_SCOPE_H_ */
-/*
- * @+ Module scope management
- * Upon system restart, the global scope is created. It is called "root" and
- * does not contain any symbol definitions. It merely functions as an anchor
- * point for the modules to be added later.
- */
-@= newscope
- assert(nme != NULL);
- cur = (Module) GDKzalloc(sizeof(ModuleRecord));
- if( cur == NULL){
- GDKerror("@1:"MAL_MALLOC_FAIL);
- } else {
- cur->name = nme;
- cur->outer = NULL;
- cur->sibling = NULL;
- cur->inheritance = TRUE;
- cur->subscope = NULL;
- cur->isAtomModule = FALSE;
- }
-
-@
-@c
#include "monetdb_config.h"
#include "mal_module.h"
#include "mal_function.h" /* for printFunction() */
@@ -157,10 +78,29 @@ void setModuleJump(str nme, Module cur){
cur->sibling= scopeJump[(int)(*nme)][(int)(*(nme+1))];
scopeJump[(int)(*nme)][(int)(*(nme+1))]= cur;
}
+
+/*
+ * @+ Module scope management
+ * Upon system restart, the global scope is created. It is called "root" and
+ * does not contain any symbol definitions. It merely functions as an anchor
+ * point for the modules to be added later.
+ */
Module newModule(Module scope, str nme){
Module cur;
+
nme = putName(nme,strlen(nme));
- @:newscope(newModule)@
+ assert(nme != NULL);
+ cur = (Module) GDKzalloc(sizeof(ModuleRecord));
+ if( cur == NULL){
+ GDKerror("newModule:"MAL_MALLOC_FAIL);
+ } else {
+ cur->name = nme;
+ cur->outer = NULL;
+ cur->sibling = NULL;
+ cur->inheritance = TRUE;
+ cur->subscope = NULL;
+ cur->isAtomModule = FALSE;
+ }
if ( cur == NULL)
return scope;
newSubScope(cur);
@@ -171,21 +111,6 @@ Module newModule(Module scope, str nme){
}
return cur;
}
-#if 0
-Module cpyModule(Module scope){
- Module nxt= NULL;
- Module cur;
- str nme;
- if( scope->outer) nxt= cpyModule(scope->outer);
- nme= GDKstrdup(scope->name);
- @:newscope(newModule)@
- if ( cur == NULL)
- return scope;
- newSubScope(cur);
- cur->outer = nxt;
- return cur;
-}
-#endif
/*
* @-
* The scope can be fixed. This is used by the parser to avoid creation of
@@ -235,27 +160,34 @@ deriveModule(Module scope, str nme){
* instructions and procedures. This forcefull action
* helps in localization of memory leakages.
*/
-static void freeSubScope(Module scope){
+static void freeSubScope(Module scope)
+{
int i;
- if(scope->subscope==0) return;
- for(i=0;i<MAXSCOPE;i++)
- if( scope->subscope[i]){
- freeSymbolList(scope->subscope[i]);
- scope->subscope[i]= NULL;
+
+ if (scope->subscope == NULL)
+ return;
+ for(i=0;i<MAXSCOPE;i++) {
+ if( scope->subscope[i]){
+ freeSymbolList(scope->subscope[i]);
+ scope->subscope[i]= NULL;
+ }
}
GDKfree(scope->subscope);
scope->subscope = 0;
}
-void freeModule(Module m){
+void freeModule(Module m)
+{
Symbol s;
- if (m==NULL) return;
+ if (m==NULL)
+ return;
if ((s=findSymbolInModule(m, "epilogue")) != NULL) {
InstrPtr pci = getInstrPtr(s->def,0);
if (pci && pci->token == COMMANDsymbol && pci->argc == 1) {
int ret = 0;
assert(pci->fcn != NULL);
+printf("epiloque!!!\n");
(*pci->fcn)(&ret);
(void)ret;
}
@@ -264,6 +196,7 @@ void freeModule(Module m){
clrModuleJump(m->name, m);
GDKfree(m);
}
+
void freeModuleList(Module s){
Module t=s;
while(s){
diff --git a/monetdb5/mal/mal_module.h b/monetdb5/mal/mal_module.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/mal/mal_module.h
@@ -0,0 +1,56 @@
+#ifndef _MAL_SCOPE_H_
+#define _MAL_SCOPE_H_
+#include "mal_box.h"
+#include "mal_xml.h"
+
+/* #define MAL_SCOPE_DEBUG */
+
+#define MAXSCOPE 256
+
+typedef struct SCOPEDEF {
+ struct SCOPEDEF *outer; /* outer level in the scope tree */
+ struct SCOPEDEF *sibling; /* module with same start */
+ str name; /* index in namespace */
+ int inheritance; /* set when it plays a role in
inheritance */
+ Symbol *subscope; /* type dispatcher table */
+ Box box; /* module related objects */
+ int isAtomModule; /* atom module definition ? */
+ void *dll; /* dlopen handle */
+ str help; /* short description of module
functionality*/
+} *Module, ModuleRecord;
+
+
+mal_export void setModuleJump(str nme, Module cur);
+mal_export Module newModule(Module scope, str nme);
+mal_export Module fixModule(Module scope, str nme);
+mal_export void deriveModule(Module scope, str nme);
+mal_export void freeModule(Module cur);
+mal_export void freeModuleList(Module cur);
+mal_export void insertSymbol(Module scope, Symbol prg);
+mal_export void deleteSymbol(Module scope, Symbol prg);
+mal_export void setInheritanceMode(Module head,int flag);
+mal_export Module setInheritance(Module head,Module first, Module second);
+mal_export Module findModule(Module scope, str name);
+mal_export Symbol findSymbol(Module nspace, str mod, str fcn);
+mal_export int isModuleDefined(Module scope, str name);
+mal_export Symbol findSymbolInModule(Module v, str fcn);
+mal_export int findInstruction(Module scope, MalBlkPtr mb, InstrPtr
pci);
+mal_export int displayModule(stream *f, Module v, str fcn,int listing);
+mal_export void showModules(stream *f, Module v);
+mal_export void debugModule(stream *f, Module v, str nme);
+mal_export void dumpManual(stream *f, Module v, int recursive);
+mal_export void dumpManualSection(stream *f, Module v);
+mal_export void dumpManualHelp(stream *f, Module s, int recursive);
+mal_export void dumpHelpTable(stream *f, Module s, str text, int flag);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list