Changeset: fe1dc03aa268 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fe1dc03aa268
Modified Files:
monetdb5/mal/mal_instruction.h
monetdb5/mal/mal_namespace.c
monetdb5/mal/mal_prelude.c
Branch: default
Log Message:
Check that module and function names in instructions went through putName.
With this, we can always use simple comparison of the module/function
name with the *Ref variables (which happens in a lot of places already).
diffs (77 lines):
diff --git a/monetdb5/mal/mal_instruction.h b/monetdb5/mal/mal_instruction.h
--- a/monetdb5/mal/mal_instruction.h
+++ b/monetdb5/mal/mal_instruction.h
@@ -29,11 +29,29 @@
* arguments. Access to module and function name are cast in macros to
* prepare for separate name space management. */
#define getModuleId(P) ((P)->modname)
-#define setModuleId(P,S) (P)->modname= S
+#ifdef NDEBUG
+#define setModuleId(P,S) do { (P)->modname = (S); } while (0)
+#else
+static inline void
+setModuleId(InstrPtr p, const char *s)
+{
+ assert(s == getName(s));
+ p->modname = s;
+}
+#endif
#define setModuleScope(P,S) do {(P)->modname= (S)==NULL?NULL: (S)->name;}
while (0)
-#define getFunctionId(P) (P)->fcnname
-#define setFunctionId(P,S) (P)->fcnname= S
+#define getFunctionId(P) ((P)->fcnname)
+#ifdef NDEBUG
+#define setFunctionId(P,S) do { (P)->fcnname = (S); } while (0)
+#else
+static inline void
+setFunctionId(InstrPtr p, const char *s)
+{
+ assert(s == getName(s));
+ p->fcnname = s;
+}
+#endif
#define garbageControl(P) ((P)->gc & GARBAGECONTROL)
#define getInstrPtr(M,I) (M)->stmt[I]
diff --git a/monetdb5/mal/mal_namespace.c b/monetdb5/mal/mal_namespace.c
--- a/monetdb5/mal/mal_namespace.c
+++ b/monetdb5/mal/mal_namespace.c
@@ -138,7 +138,7 @@ static const char *findName(const char *
}
const char *getName(const char *nme) {
- return findName(nme, strlen(nme), false);
+ return findName(nme, nme?strlen(nme):0, false);
}
const char *getNameLen(const char *nme, size_t len)
@@ -147,7 +147,7 @@ const char *getNameLen(const char *nme,
}
const char *putName(const char *nme) {
- return findName(nme, strlen(nme), true);
+ return findName(nme, nme?strlen(nme):0, true);
}
const char *putNameLen(const char *nme, size_t len)
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
@@ -241,7 +241,7 @@ addFunctions(mel_func *fcn){
/* keep the comment around, setting the static avoid freeing
the string accidentally , saving on duplicate documentation in the code. */
mb->statichelp = mb->help = fcn->comment;
- sig= newInstructionArgs(mb, fcn->mod, fcn->fcn, fcn->argc +
(fcn->retc == 0));
+ sig= newInstructionArgs(mb, mod, putName(fcn->fcn), fcn->argc +
(fcn->retc == 0));
sig->retc = 0;
sig->argc = 0;
sig->token = fcn->command?COMMANDsymbol:PATTERNsymbol;
@@ -345,6 +345,7 @@ melFunction(bool command, const char *mo
s = newSymbol(fcn, command ? COMMANDsymbol:PATTERNsymbol );
if (s == NULL)
return MEL_ERR;
+ fcn = s->name;
mb = s->def;
(void)comment;
if (fname)
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]