Minor code improvements after Lua changes.

This commit is contained in:
William S Fulton 2014-02-28 19:49:53 +00:00
commit d957d37636
3 changed files with 17 additions and 19 deletions

View file

@ -2993,7 +2993,7 @@ int Language::variableWrapper(Node *n) {
Setattr(n, "varset", "1"); Setattr(n, "varset", "1");
functionWrapper(n); functionWrapper(n);
} else { } else {
Setattr(n, "feature:immutable", "1"); SetFlag(n, "feature:immutable");
} }
/* Restore parameters */ /* Restore parameters */
Setattr(n, "sym:name", symname); Setattr(n, "sym:name", symname);
@ -3079,9 +3079,9 @@ int Language::addSymbol(const String *s, const Node *n, const_String_or_char_ptr
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Lanugage::symbolAddScope( const_String_or_char_ptr scopeName ) * Language::symbolAddScope()
* *
* Creates a scope (symbols Hash) for given name. This method is auxilary, * Creates a scope (symbols Hash) for given name. This method is auxiliary,
* you don't have to call it - addSymbols will lazily create scopes automatically. * you don't have to call it - addSymbols will lazily create scopes automatically.
* If scope with given name already exists, then do nothing. * If scope with given name already exists, then do nothing.
* Returns newly created (or already existing) scope. * Returns newly created (or already existing) scope.
@ -3089,10 +3089,10 @@ int Language::addSymbol(const String *s, const Node *n, const_String_or_char_ptr
Hash* Language::symbolAddScope(const_String_or_char_ptr scope) { Hash* Language::symbolAddScope(const_String_or_char_ptr scope) {
Hash *symbols = symbolScopeLookup(scope); Hash *symbols = symbolScopeLookup(scope);
if(!symbols) { if(!symbols) {
// Order in which to following parts are executed is important. In Lanugage // The order in which the following code is executed is important. In the Language
// constructor addScope("") is called to create a top level scope itself. // constructor addScope("") is called to create a top level scope.
// Thus we must first add symbols hash to symtab and only then add pseudo // Thus we must first add a symbols hash to symtab and only then add pseudo
// symbol to top-level scope // symbols to the top-level scope.
// New scope which has not been added by the target language - lazily created. // New scope which has not been added by the target language - lazily created.
symbols = NewHash(); symbols = NewHash();
@ -3103,14 +3103,14 @@ Hash* Language::symbolAddScope(const_String_or_char_ptr scope) {
const_String_or_char_ptr top_scope = ""; const_String_or_char_ptr top_scope = "";
Hash *topscope_symbols = Getattr(symtabs, top_scope); Hash *topscope_symbols = Getattr(symtabs, top_scope);
Hash *pseudo_symbol = NewHash(); Hash *pseudo_symbol = NewHash();
Setattr(pseudo_symbol, "sym:is_scope", "1"); Setattr(pseudo_symbol, "sym:scope", "1");
Setattr(topscope_symbols, scope, pseudo_symbol); Setattr(topscope_symbols, scope, pseudo_symbol);
} }
return symbols; return symbols;
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Lanugage::symbolSscopeLookup( const_String_or_char_ptr scope ) * Language::symbolScopeLookup()
* *
* Lookup and returns a symtable (hash) representing given scope. Hash contains * Lookup and returns a symtable (hash) representing given scope. Hash contains
* all symbols in this scope. * all symbols in this scope.
@ -3121,17 +3121,16 @@ Hash* Language::symbolScopeLookup( const_String_or_char_ptr scope ) {
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Lanugage::symbolScopeSymbolLookup( const_String_or_char_ptr scope ) * Language::symbolScopePseudoSymbolLookup()
* *
* For every scope there is a special pseudo-symbol in the top scope (""). It * For every scope there is a special pseudo-symbol in the top scope (""). It
* exists solely to detect name clashes. This pseudo symbol may contain a few properties, * exists solely to detect name clashes. This pseudo symbol may contain a few properties,
* but you can more if you need to. This is also true fro top level scope (""). * but more could be added. This is also true for the top level scope ("").
* It contains a pseudo symbol with name "" (empty). Pseudo symbol contains the * It contains a pseudo symbol with name "" (empty). Pseudo symbol contains the
* following properties: * following properties:
* sym:scope = "1" - a flag that this is scope pseudo symbol * sym:scope = "1" - a flag that this is a scope pseudo symbol
* *
* Pseudo symbols are a Hash*, not a Node* (not that there is a difference * Pseudo symbols are a Hash*, not a Node*.
* in DOH)
* There is no difference from symbolLookup() method except for signature * There is no difference from symbolLookup() method except for signature
* and return type. * and return type.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */

View file

@ -2096,9 +2096,8 @@ public:
List *to_close = NewList(); List *to_close = NewList();
while (ki.key) { while (ki.key) {
assert(ki.item); assert(ki.item);
if (Getattr(ki.item, "sym:is_scope")) { if (Getattr(ki.item, "sym:scope")) {
// We have a pseudo symbol. Lets get actuall scope for this // We have a pseudo symbol. Lets get actual scope for this pseudo symbol
// pseudo symbol
Hash *carrays_hash = rawGetCArraysHash(ki.key); Hash *carrays_hash = rawGetCArraysHash(ki.key);
assert(carrays_hash); assert(carrays_hash);
if (Getattr(carrays_hash, "lua:closed") == 0) if (Getattr(carrays_hash, "lua:closed") == 0)

View file

@ -217,8 +217,8 @@ public:
virtual void dumpSymbols(); virtual void dumpSymbols();
virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */ virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
virtual Hash* symbolAddScope(const_String_or_char_ptr scope); virtual Hash* symbolAddScope(const_String_or_char_ptr scope);
virtual Hash* symbolScopeLookup( const_String_or_char_ptr scope ); virtual Hash* symbolScopeLookup(const_String_or_char_ptr scope);
virtual Hash* symbolScopePseudoSymbolLookup( const_String_or_char_ptr scope ); virtual Hash* symbolScopePseudoSymbolLookup(const_String_or_char_ptr scope);
virtual Node *classLookup(const SwigType *s) const; /* Class lookup */ virtual Node *classLookup(const SwigType *s) const; /* Class lookup */
virtual Node *enumLookup(SwigType *s); /* Enum lookup */ virtual Node *enumLookup(SwigType *s); /* Enum lookup */
virtual int abstractClassTest(Node *n); /* Is class really abstract? */ virtual int abstractClassTest(Node *n); /* Is class really abstract? */