Support namespaces / modules in bif. Checkpoint.

(now actually commiting all the files)

This change is actually two-fold:
a) bif's now accept module XYZ; statements and module::ID for
   function, const, event, enum, etc. declartation
b) Added C++-namespaces to variables, functions, etc. that are declared
   in bif but accessed from C++
   This required some (lightweight) re-factoring of the C++ codes.
   Note, event's don't have their own C++ namespace yet, since this
   would require a rather huge re-factoring.

Compiles and passes test suite.
New namespace feature not tested yet.
Documentation to follow.
This commit is contained in:
Gregor Maier 2011-02-11 09:37:23 -08:00
parent 86fdd1dcf3
commit f79ea244fa
31 changed files with 332 additions and 228 deletions

View file

@ -11,42 +11,6 @@
static scope_list scopes;
static Scope* top_scope;
// Returns it without trailing "::".
string extract_module_name(const char* name)
{
string module_name = name;
string::size_type pos = module_name.rfind("::");
if ( pos == string::npos )
return string(GLOBAL_MODULE_NAME);
module_name.erase(pos);
return module_name;
}
string normalized_module_name(const char* module_name)
{
int mod_len;
if ( (mod_len = strlen(module_name)) >= 2 &&
! strcmp(module_name + mod_len - 2, "::") )
mod_len -= 2;
return string(module_name, mod_len);
}
string make_full_var_name(const char* module_name, const char* var_name)
{
if ( ! module_name || streq(module_name, GLOBAL_MODULE_NAME) ||
strstr(var_name, "::") )
return string(var_name);
string full_name = normalized_module_name(module_name);
full_name += "::";
full_name += var_name;
return full_name;
}
Scope::Scope(ID* id)
{