compiler/libec: Prioritizing enum values over globals
authorJerome St-Louis <jerome@ecere.com>
Sun, 13 Jul 2014 23:36:03 +0000 (19:36 -0400)
committerJerome St-Louis <jerome@ecere.com>
Sun, 13 Jul 2014 23:36:03 +0000 (19:36 -0400)
- Fixes errors with minor()/major() functions with ErrorLevel definitions on Android

compiler/bootstrap/libec/bootstrap/pass15.c
compiler/libec/src/pass15.ec

index 969e712..ca5c035 100644 (file)
@@ -15767,8 +15767,13 @@ break;
 }
 else
 {
-struct Symbol * symbol = FindSymbol(id->string, curContext, topContext, 0, id->_class && id->_class->__anon1.__anon1.name == (((void *)0)));
+struct Symbol * symbol = (((void *)0));
+unsigned int findInGlobal = 0;
 
+if(!topContext->parent && exp->destType && exp->destType->kind == 8 && exp->destType->__anon1._class && exp->destType->__anon1._class->__anon1.registered && exp->destType->__anon1._class->__anon1.registered->type == 4)
+findInGlobal = 1;
+else
+symbol = FindSymbol(id->string, curContext, topContext, 0, id->_class && id->_class->__anon1.__anon1.name == (((void *)0)));
 if(!symbol)
 {
 if(exp->destType && CheckExpressionType(exp, exp->destType, 0, 0))
@@ -15792,6 +15797,8 @@ break;
 symbol = FindSymbol(id->string, topContext->parent, globalContext, 0, id->_class && id->_class->__anon1.__anon1.name == (((void *)0)));
 }
 }
+if(findInGlobal)
+symbol = FindSymbol(id->string, curContext, topContext, 0, id->_class && id->_class->__anon1.__anon1.name == (((void *)0)));
 if(symbol)
 {
 struct Type * type = symbol->type;
index 2c584d9..b39a9bb 100644 (file)
@@ -7830,7 +7830,13 @@ void ProcessExpressionType(Expression exp)
          }
          else
          {
-            Symbol symbol = FindSymbol(id.string, curContext, topContext /*exp.destType ? topContext : globalContext*/, false, id._class && id._class.name == null);
+            Symbol symbol = null;
+            bool findInGlobal = false;
+            if(!topContext.parent && exp.destType && exp.destType.kind == classType && exp.destType._class && exp.destType._class.registered && exp.destType._class.registered.type == enumClass)
+               findInGlobal = true;  // In global context, look at enum values first
+            else
+               symbol = FindSymbol(id.string, curContext, topContext /*exp.destType ? topContext : globalContext*/, false, id._class && id._class.name == null);
+
             // Enums should be resolved here (Special pass in opExp to fix identifiers not seen as enum on the first pass)
             if(!symbol/* && exp.destType*/)
             {
@@ -7856,6 +7862,8 @@ void ProcessExpressionType(Expression exp)
                   symbol = FindSymbol(id.string, topContext.parent, globalContext, false, id._class && id._class.name == null);
                }
             }
+            if(findInGlobal)
+               symbol = FindSymbol(id.string, curContext, topContext, false, id._class && id._class.name == null);
 
             // If we manage to resolve this symbol
             if(symbol)