compiler/libec: (#307, #70) Warning on undeclared class; Overriding namespaces
[sdk] / compiler / libec / src / ast.ec
index b2c9036..6cf7333 100644 (file)
@@ -4,9 +4,9 @@ import "ecdefs"
 #include "grammar.h"
 extern char * yytext;
 
-char * defaultNameSpace;
+const char * defaultNameSpace;
 int defaultNameSpaceLen;
-public void SetDefaultNameSpace(char * s) { defaultNameSpace = s; defaultNameSpaceLen = s ? strlen(s) : 0; }
+public void SetDefaultNameSpace(const char * s) { defaultNameSpace = s; defaultNameSpaceLen = s ? strlen(s) : 0; }
 
 bool strictNameSpaces;
 public void SetStrictNameSpaces(bool b) { strictNameSpaces = b; }
@@ -18,9 +18,9 @@ public void SetDeclMode(AccessMode accessMode) { structDeclMode = declMode = acc
 AccessMode defaultDeclMode = privateAccess;
 public void SetDefaultDeclMode(AccessMode accessMode) { defaultDeclMode = accessMode; }
 
-char * currentNameSpace;
+const char * currentNameSpace;
 int currentNameSpaceLen;
-public void SetCurrentNameSpace(char * s) { currentNameSpace = s; currentNameSpaceLen = s ? strlen(s) : 0; }
+public void SetCurrentNameSpace(const char * s) { currentNameSpace = s; currentNameSpaceLen = s ? strlen(s) : 0; }
 
 #ifdef _TIMINGS
 Time findClassTotalTime;
@@ -53,7 +53,7 @@ void ListAddFront(OldList list, void * item)
       list.Insert(null, item);
 }
 
-public Identifier MkIdentifier(char * string)
+public Identifier MkIdentifier(const char * string)
 {
    Identifier id { };
    int c;
@@ -62,7 +62,7 @@ public Identifier MkIdentifier(char * string)
 
    if(string)
    {
-      char * namePart;
+      const char * namePart;
       bool gotColon = false;
       for(c = strlen(string)-1; c >= 0; c--)
          if(string[c] == ':')
@@ -210,7 +210,7 @@ Expression MkExpExtensionInitializer(TypeName typeName, Initializer initializer)
 
 public Expression MkExpIdentifier(Identifier id)
 {
-   return { type = identifierExp, identifier = id };
+   return { type = identifierExp, identifier = id, loc = yylloc };
 }
 
 public Expression MkExpDummy()
@@ -219,14 +219,19 @@ public Expression MkExpDummy()
    return exp;
 }
 
-public Expression MkExpConstant(char * string)
+public Expression MkExpConstant(const char * string)
 {
-   return { type = constantExp, constant = CopyString(string) };
+   return { type = constantExp, constant = CopyString(string), loc = yylloc };
 }
 
-Expression MkExpString(char * string)
+Expression MkExpString(const char * string)
 {
-   return { type = stringExp, string = CopyString(string) };
+   return { type = stringExp, string = CopyString(string), loc = yylloc };
+}
+
+Expression MkExpWideString(const char * string)
+{
+   return { type = stringExp, string = CopyString(string), loc = yylloc, wideString = true };
 }
 
 // TODO: String is case sensitive..
@@ -275,11 +280,12 @@ public struct ContextStringPair
 
 Map<ContextStringPair, List<Location>> intlStrings { };
 
-Expression MkExpIntlString(char * string, char * context)
+Expression MkExpIntlString(const char * string, const char * context)
 {
    if(inCompiler)
    {
       OldList * list = MkList();
+      String s;
       if(inCompiler)
       {
          ContextStringPair pair { };
@@ -303,7 +309,9 @@ Expression MkExpIntlString(char * string, char * context)
          list.Add(yylloc);
       }
       //ListAdd(list, QMkExpId("__thisModule"));
-      ListAdd(list, MkExpString(QMkString(i18nModuleName ? i18nModuleName : "")));
+      s = QMkString(i18nModuleName ? i18nModuleName : "");
+      ListAdd(list, MkExpString(s));
+      delete s;
       ListAdd(list, MkExpString(string));
       if(context)
       {
@@ -368,67 +376,67 @@ Expression MkExpIndex(Expression expression, OldList index)
 
 Expression MkExpCall(Expression expression, OldList arguments)
 {
-   return { type = callExp, call.exp = expression, call.arguments = arguments };
+   return { type = callExp, call.exp = expression, call.arguments = arguments, loc = yylloc };
 }
 
 Expression MkExpMember(Expression expression, Identifier member)
 {
-   return { type = memberExp, member.exp = expression, member.member = member };
+   return { type = memberExp, member.exp = expression, member.member = member, loc = yylloc };
 }
 
 Expression MkExpPointer(Expression expression, Identifier member)
 {
-   return { type = pointerExp, member.exp = expression, member.member = member };
+   return { type = pointerExp, member.exp = expression, member.member = member, loc = yylloc };
 }
 
 Expression MkExpTypeSize(TypeName typeName)
 {
-   return { type = typeSizeExp, typeName = typeName };
+   return { type = typeSizeExp, typeName = typeName, loc = yylloc };
 }
 
 Expression MkExpTypeAlign(TypeName typeName)
 {
-   return { type = typeAlignExp, typeName = typeName };
+   return { type = typeAlignExp, typeName = typeName, loc = yylloc };
 }
 
 Expression MkExpClassSize(Specifier _class)
 {
-   return { type = classSizeExp, _class = _class };
+   return { type = classSizeExp, _class = _class, loc = yylloc };
 }
 
 Expression MkExpCast(TypeName typeName, Expression expression)
 {
-   return { type = castExp, cast.typeName = typeName, cast.exp = expression };
+   return { type = castExp, cast.typeName = typeName, cast.exp = expression, loc = yylloc };
 }
 
 Expression MkExpCondition(Expression cond, OldList expressions, Expression elseExp)
 {
-   return { type = conditionExp, cond.cond = cond, cond.exp = expressions, cond.elseExp = elseExp };
+   return { type = conditionExp, cond.cond = cond, cond.exp = expressions, cond.elseExp = elseExp, loc = yylloc };
 }
 
 Expression MkExpRenew(Expression memExp, TypeName type, Expression size)
 {
-   return { type = renewExp, _renew.exp = memExp, _renew.typeName = type, _renew.size = size };
+   return { type = renewExp, _renew.exp = memExp, _renew.typeName = type, _renew.size = size, loc = yylloc };
 }
 
 Expression MkExpRenew0(Expression memExp, TypeName type, Expression size)
 {
-   return { type = renew0Exp, _renew.exp = memExp, _renew.typeName = type, _renew.size = size };
+   return { type = renew0Exp, _renew.exp = memExp, _renew.typeName = type, _renew.size = size, loc = yylloc };
 }
 
 Expression MkExpNew(TypeName type, Expression size)
 {
-   return { type = newExp, _new.typeName = type, _new.size = size };
+   return { type = newExp, _new.typeName = type, _new.size = size, loc = yylloc };
 }
 
 Expression MkExpNew0(TypeName type, Expression size)
 {
-   return { type = new0Exp, _new.typeName = type, _new.size = size };
+   return { type = new0Exp, _new.typeName = type, _new.size = size, loc = yylloc };
 }
 
 Expression MkExpVaArg(Expression exp, TypeName type)
 {
-   return { type = vaArgExp, vaArg.exp = exp, vaArg.typeName = type };
+   return { type = vaArgExp, vaArg.exp = exp, vaArg.typeName = type, loc = yylloc };
 }
 
 Specifier MkSpecifier(int specifier)
@@ -672,7 +680,7 @@ public TypeName MkTypeNameGuessDecl(OldList qualifiers, Declarator declarator)
          next = spec.next;
          if(gotType && !declarator && ((spec.type == nameSpecifier && spec.name) || (spec.type == baseSpecifier && gotFullType)))
          {
-            String s = null;
+            const String s = null;
             if(spec.type == nameSpecifier)
             {
                char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
@@ -761,7 +769,6 @@ Declaration MkDeclarationInst(Instantiation inst)
       string = (inst.exp.type == identifierExp) ? CopyString(inst.exp.identifier.string) : null;
       type = MkClassTypeSymbol(inst._class.symbol);
    };
-   symbol.idCode = symbol.id = curContext.nextID++;
    if(strstr(symbol.string, "::"))
       curContext.hasNameSpace = true;
    if(!(curContext.templateTypesOnly ? curContext.parent : curContext).symbols.Add((BTNode)symbol))
@@ -838,7 +845,6 @@ Declaration MkDeclaration(OldList specifiers, OldList initDeclarators)
                         string = CopyString(GetDeclId(d.declarator).string);
                         type = ProcessType(specifiers, d.declarator);
                      };
-                     type.id = type.idCode = curContext.nextID++;
 
                      if(!(curContext.templateTypesOnly ? curContext.parent : curContext).types.Add((BTNode)type))
                         excludedSymbols->Add(type);
@@ -853,10 +859,10 @@ Declaration MkDeclaration(OldList specifiers, OldList initDeclarators)
                {
                   if((spec.type == nameSpecifier && spec.name) || spec.type == baseSpecifier)
                   {
-                     String s = null;
+                     const String s = null;
                      if(spec.type == nameSpecifier)
                      {
-                        char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
+                        const char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
                         s = colon ? colon + 2 : spec.name;
                      }
                      else if(spec.type == baseSpecifier)
@@ -866,7 +872,6 @@ Declaration MkDeclaration(OldList specifiers, OldList initDeclarators)
                      if(s)
                      {
                         Symbol type { string = CopyString(s), type = ProcessType(specifiers, null) };
-                        type.id = type.idCode = curContext.nextID++;
                         decl.symbol = type;
                         decl.declarators = initDeclarators = MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier(s)), null));
                         specifiers.Remove(spec);
@@ -887,7 +892,7 @@ Declaration MkDeclaration(OldList specifiers, OldList initDeclarators)
          {
             if(gotType && initDeclarators == null && !spec.next && ((spec.type == nameSpecifier && spec.name) || spec.type == baseSpecifier))
             {
-               String s = null;
+               const String s = null;
                if(spec.type == nameSpecifier)
                {
                   char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
@@ -992,7 +997,6 @@ Declaration MkDeclaration(OldList specifiers, OldList initDeclarators)
                         symbol.type.freeExp = true;
                      }
                   }
-                  symbol.id = symbol.idCode = curContext.nextID++;
                }
                decl.symbol = d.declarator.symbol = symbol;
             }
@@ -1002,7 +1006,6 @@ Declaration MkDeclaration(OldList specifiers, OldList initDeclarators)
    else
    {
       decl.symbol = Symbol { };
-      decl.symbol.id = decl.symbol.idCode = curContext.nextID++;
       excludedSymbols->Add(decl.symbol);
    }
    return decl;
@@ -1020,10 +1023,10 @@ Declaration MkStructDeclaration(OldList specifiers, OldList declarators, Specifi
          next = spec.next;
          if(gotType && declarators == null && ((spec.type == nameSpecifier && spec.name) || spec.type == baseSpecifier))
          {
-            String s = null;
+            const String s = null;
             if(spec.type == nameSpecifier)
             {
-               char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
+               const char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
                s = colon ? colon + 2 : spec.name;
             }
             else if(spec.type == baseSpecifier)
@@ -1188,8 +1191,6 @@ void ProcessFunctionBody(FunctionDefinition func, Statement body)
                   if(!context.symbols.Add((BTNode)symbol))
                      excludedSymbols->Add(symbol);
 
-                  // TODO: Fix this, the parameters' IDs should really be smaller...
-                  symbol.id = context.nextID++;
                   param.declarator.symbol = symbol;
                }
             }
@@ -1227,7 +1228,6 @@ void ProcessFunctionBody(FunctionDefinition func, Statement body)
          id.string = CopyString(name);
       }
       symbol = Symbol { string = CopyString(id.string), type = ProcessType(func.specifiers, declarator) };
-      symbol.idCode = symbol.id = globalContext.nextID++;
       if(strstr(symbol.string, "::"))
          globalContext.hasNameSpace = true;
       if(!globalContext.symbols.Add((BTNode)symbol))
@@ -1309,7 +1309,6 @@ External MkExternalImport(char * name, ImportType importType, AccessMode importA
 External MkExternalDeclaration(Declaration declaration)
 {
    External external { type = declarationExternal, declaration = declaration, symbol = declaration ? declaration.symbol : null };
-   InitDeclarator d = (declaration && declaration.declarators) ? declaration.declarators->last : null;
    if(declaration && declaration.type == initDeclaration && declaration.specifiers)
    {
       Specifier spec;
@@ -1425,7 +1424,8 @@ void SetClassTemplateArgs(Specifier spec, OldList templateArgs)
          if(!symbol && spec.symbol)
          {
             // If class was only decl'ed, invoke DeclClass on this templated class as well
-            symbol = _DeclClass(MAXINT, templateString);
+            symbol = _DeclClass(null, templateString);
+            symbol.notYetDeclared = true;
          }
          // Add a reference to all templated class to the basic class
          if(spec.symbol)
@@ -1439,7 +1439,7 @@ void SetClassTemplateArgs(Specifier spec, OldList templateArgs)
       FreeList(templateArgs, FreeTemplateArgument);
 }
 
-Specifier _MkSpecifierName(char * name, Symbol symbol, OldList templateArgs)
+Specifier _MkSpecifierName(const char * name, Symbol symbol, OldList templateArgs)
 {
    Specifier spec { type = nameSpecifier };
 
@@ -1470,7 +1470,22 @@ Specifier _MkSpecifierName(char * name, Symbol symbol, OldList templateArgs)
          }
       }
       else if(symbol)
+      {
+         char nameSpace[1024];
+         char * c = strstr(name, symbol.string);
          spec.name = CopyString(symbol.string);
+         if(c && c >= name + 2 && c[-1] == ':' && c[-2] == ':')
+         {
+            if(c > name + 2)
+            {
+               memcpy(nameSpace, name, c - name - 2);
+               nameSpace[c-name] = 0;
+               spec.nsSpec = _MkSpecifierName(nameSpace, null, null);
+            }
+            else
+               spec.nsSpec = _MkSpecifierName(null, null, null);
+         }
+      }
       else
          spec.name = CopyString(name);
       spec.symbol = symbol;
@@ -1480,18 +1495,18 @@ Specifier _MkSpecifierName(char * name, Symbol symbol, OldList templateArgs)
    return spec;
 }
 
-public Specifier MkSpecifierName(char * name)
+public Specifier MkSpecifierName(const char * name)
 {
    return _MkSpecifierName(name, null, null);
 }
 
-public Specifier MkSpecifierNameArgs(char * name, OldList * templateArgs)
+public Specifier MkSpecifierNameArgs(const char * name, OldList * templateArgs)
 {
    return _MkSpecifierName(name, null, templateArgs);
 }
 
 /*
-Specifier MkClassName(char * string)
+Specifier MkClassName(const char * string)
 {
    return { type = SpecifierClass, name = CopyString(string) };
 }
@@ -1543,8 +1558,6 @@ void ProcessClassFunctionBody(ClassFunction func, Statement body)
                      isParam = true;
                   };
 
-                  // TODO: Fix this, the parameters' IDs should really be smaller...
-                  symbol.idCode = symbol.id = context.nextID++;
                   if(!context.symbols.Add((BTNode)symbol))
                      excludedSymbols->Add(symbol);
 
@@ -1588,7 +1601,6 @@ void ProcessClassFunctionBody(ClassFunction func, Statement body)
             symbolSpecs->Add(CopySpecifier(spec));
       }
       symbol.type = ProcessType(symbolSpecs, decl);
-      symbol.idCode = symbol.id = globalContext.nextID++;
       decl.symbol = symbol;
 
       excludedSymbols->Add(symbol);
@@ -1691,7 +1703,7 @@ ClassDef MkClassDefClassData(Declaration decl)
    return { type = classDataClassDef, decl = decl };
 }
 
-ClassDef MkClassDefDesigner(char * designer)
+ClassDef MkClassDefDesigner(const char * designer)
 {
    return { type = classDesignerClassDef, designer = CopyString(designer) };
 }
@@ -1737,12 +1749,12 @@ ClassDef MkClassDefFunction(ClassFunction function)
    return def;
 }
 
-Symbol DeclClassAddNameSpace(int symbolID, char * className)
+Symbol DeclClassAddNameSpace(Specifier _class, const char * className)
 {
    char name[1024];
    int len = 0, stringLen;
    name[0] = '\0';
-   if((currentNameSpace || defaultNameSpace) && declMode != defaultAccess && defaultDeclMode != defaultAccess)
+   if(className[0] != ':' && (currentNameSpace || defaultNameSpace) && declMode != defaultAccess && defaultDeclMode != defaultAccess && (!_class || _class.name))
    {
       if(defaultNameSpace)
       {
@@ -1763,20 +1775,30 @@ Symbol DeclClassAddNameSpace(int symbolID, char * className)
    memcpy(name + len, className, stringLen);
    len += stringLen;
    name[len] = 0;
-   return _DeclClass(symbolID, name);
+   return _DeclClass(_class, name);
 }
 
-Symbol DeclClass(int symbolID, char * name)
+Symbol DeclClass(Specifier _class, const char * name)
 {
-   if(strchr(name, ':'))
-      return _DeclClass(symbolID, name);
+   if(_class || strchr(name, ':'))
+      return _DeclClass(_class, name);
    else
-      return DeclClassAddNameSpace(symbolID, name);
+      return DeclClassAddNameSpace(_class, name);
 }
 
-Symbol _DeclClass(int symbolID, char * name)
+Symbol _DeclClass(Specifier _class, const char * name)
 {
-   Symbol symbol = FindClass(name);
+   Symbol symbol;
+   char nameBuffer[1024];
+   if(_class)
+   {
+      strcpy(nameBuffer,  _class.name ? _class.name : "");
+      strcat(nameBuffer, "::");
+      strcat(nameBuffer, name);
+      name = nameBuffer;
+   }
+
+   symbol = FindClass(name);
    if(!symbol)
    {
       /*
@@ -1792,7 +1814,7 @@ Symbol _DeclClass(int symbolID, char * name)
       symbol = Symbol
       {
          string = CopyString(name);
-         idCode = symbolID, id = symbolID;
+         notYetDeclared = true;
       };
       if(!globalContext.classes.Add((BTNode)symbol))
          excludedSymbols->Add(symbol);
@@ -1812,8 +1834,6 @@ Symbol _DeclClass(int symbolID, char * name)
             symbol.shortName = CopyString(name + start);
       }
    }
-   if(symbolID)
-      symbol.idCode = symbol.id = symbolID;
    return symbol;
 }
 
@@ -1898,7 +1918,7 @@ ClassDefinition MkClass(Symbol symbol, OldList baseSpecs, OldList definitions)
       delete symbol.ctx;
    }
    symbol.ctx = curContext;
-   classDef = { symbol = symbol, _class = MkSpecifierName /*MkClassName*/(symbol.string), baseSpecs = baseSpecs, definitions = definitions, nameLoc = symbol.nameLoc };
+   classDef = { symbol = symbol, _class = MkSpecifierName(symbol.string), baseSpecs = baseSpecs, definitions = definitions, nameLoc = symbol.nameLoc };
    curContext.classDef = classDef;
    return classDef;
 }
@@ -1939,30 +1959,27 @@ PropertyDef MkProperty(OldList specs, Declarator decl, Identifier id, Statement
       string = CopyString(id.string);
       type = type;
    };
-   symbol.idCode = symbol.id = globalContext.nextID++;
    excludedSymbols->Add(symbol);
-   globalContext.nextID++;
-   globalContext.nextID++;
    prop.symbol = symbol;
    return prop;
 }
 
 ClassDef MkClassDefProperty(PropertyDef propertyDef)
 {
-   return { type = propertyClassDef, propertyDef = propertyDef };
+   return { type = propertyClassDef, propertyDef = propertyDef, loc = yylloc };
 }
 
 ClassDef MkClassDefClassProperty(PropertyDef propertyDef)
 {
-   return { type = classPropertyClassDef, propertyDef = propertyDef };
+   return { type = classPropertyClassDef, propertyDef = propertyDef, loc = yylloc };
 }
 
 ClassDef MkClassDefClassPropertyValue(Identifier id, Initializer initializer)
 {
-   return { type = classPropertyValueClassDef, id = id, initializer = initializer };
+   return { type = classPropertyValueClassDef, id = id, initializer = initializer, loc = yylloc };
 }
 
-int CheckType(char * text)
+int CheckType(const char * text)
 {
 #ifdef _TIMINGS
    Time startTime = GetTime();
@@ -2011,10 +2028,10 @@ void PopContext(Context ctx)
    curContext = ctx.parent;
 }
 
-Symbol FindType(Context ctx, char * name)
+Symbol FindType(Context ctx, const char * name)
 {
    Symbol type = null;
-   if(curContext)
+   if(ctx)
    {
       //char output[8192];
       type = (Symbol)ctx.types.FindString(name);
@@ -2029,7 +2046,19 @@ Symbol FindType(Context ctx, char * name)
    return type;
 }
 
-TemplatedType FindTemplateTypeParameter(Context ctx, char * name)
+Symbol FindStruct(Context ctx, const char * name)
+{
+   Symbol type = null;
+   if(ctx)
+   {
+      type = (Symbol)ctx.structSymbols.FindString(name);
+      if(!type && ctx.parent)
+         type = FindStruct(ctx.parent, name);
+   }
+   return type;
+}
+
+TemplatedType FindTemplateTypeParameter(Context ctx, const char * name)
 {
    TemplatedType templatedType = null;
    if(curContext)
@@ -2101,9 +2130,9 @@ static char * GetFullClassName(Class c, char * name)
 }
 */
 
-public Symbol FindClass(char * name)
+public Symbol FindClass(const char * name)
 {
-#ifdef _DEBUG
+#ifdef _TIMINGS
    Time startTime = GetTime();
 #endif
    Symbol cl = null;
@@ -2196,8 +2225,7 @@ public Symbol FindClass(char * name)
             {
                string = CopyString(name);
                registered = _class;
-               id = MAXINT;
-               idCode = MAXINT;
+               notYetDeclared = true;
                imported = true;
             };
             _class.symbol = cl;
@@ -2222,17 +2250,18 @@ void CopyTypeInto(Type type, Type src)
 {
    type = *src;
    type.name = CopyString(src.name);
+   type.typeName = CopyString(src.typeName);
    type.refCount = 1;
 
    if(src.kind == enumType)
    {
-      NamedLink member;
+      NamedLink64 member;
 
       type.members.Clear();
       // This must have been a mistake: member = **type**.members.first
       for(member = src.members.first; member; member = member.next)
       {
-         type.members.Add(NamedLink { name = CopyString(member.name), data = member.data });
+         type.members.Add(NamedLink64 { name = CopyString(member.name), data = member.data });
       }
       type.enumName = CopyString(src.enumName);
    }
@@ -2259,7 +2288,6 @@ void CopyTypeInto(Type type, Type src)
          if(type.arraySizeExp)
             type.arraySizeExp = CopyExpression(type.arraySizeExp);
       }
-
    }
 }
 
@@ -2278,7 +2306,6 @@ static Type ProcessTypeSpecs(OldList specs, bool assumeEllipsis, bool keepTypeNa
             ExtDecl extDecl = spec.extDecl;
             if(extDecl.type == extDeclString)
             {
-               String s = spec.extDecl.s;
                if(!strcmp(spec.extDecl.s, "__declspec(dllexport)") || !strcmp(spec.extDecl.s, "dllexport"))
                   specType.dllExport = true;
                else if(!strcmp(spec.extDecl.s, "__declspec(stdcall)") || !strcmp(spec.extDecl.s, "stdcall"))
@@ -2407,12 +2434,11 @@ static Type ProcessTypeSpecs(OldList specs, bool assumeEllipsis, bool keepTypeNa
             if(spec.list)
             {
                Enumerator e;
-               int nextValue = 0;
                for(e = spec.list->first; e; e = e.next)
                {
-                  NamedLink i { name = CopyString(e.id.string) };
+                  NamedLink64 i { name = CopyString(e.id.string) };
                   if(e.exp && e.exp.type == constantExp && e.exp.constant)
-                     i.data = (void *)strtol(e.exp.constant, null, 0);
+                     i.data = strtoll(e.exp.constant, null, 0);
                   specType.members.Add(i);
                }
             }
@@ -2455,12 +2481,12 @@ static Type ProcessTypeSpecs(OldList specs, bool assumeEllipsis, bool keepTypeNa
 
                      if(symbol.type.kind == enumType)
                      {
-                        NamedLink member;
+                        NamedLink64 member;
 
                         specType.members.Clear();
                         for(member = symbol.type.members.first; member; member = member.next)
                         {
-                           NamedLink item { name = CopyString(member.name), data = member.data };
+                           NamedLink64 item { name = CopyString(member.name), data = member.data };
                            specType.members.Add(item);
                         }
                      }
@@ -2525,7 +2551,7 @@ static Type ProcessTypeSpecs(OldList specs, bool assumeEllipsis, bool keepTypeNa
          }
          else if(spec.type == subClassSpecifier)
          {
-            specType.kind = specType.kind = subClassType;
+            specType.kind = subClassType;
             specType._class = spec._class.symbol;
          }
       }
@@ -2726,7 +2752,7 @@ public Type ProcessType(OldList specs, Declarator decl)
    return ProcessTypeDecls(specs, decl, null);
 }
 
-public Type ProcessTypeString(char * string, bool staticMethod)
+public Type ProcessTypeString(const char * string, bool staticMethod)
 {
    OldList * specs = MkList();
    Declarator decl = SpecDeclFromString(string, specs, null);
@@ -2753,7 +2779,7 @@ Type MkClassTypeSymbol(Symbol symbol)
    return null;
 }
 
-public Type MkClassType(char * name)
+public Type MkClassType(const char * name)
 {
    if(name)
    {
@@ -2872,7 +2898,7 @@ Expression MkExpArray(OldList * expressions)
    return { type = arrayExp, list = expressions };
 }
 
-Expression GetTemplateArgExpByName(char * paramName, Class curClass, TemplateParameterType tplType)
+Expression GetTemplateArgExpByName(const char * paramName, Class curClass, TemplateParameterType tplType)
 {
    Expression argExp = null;
    Class _class = curClass ? curClass : ((curExternal && curExternal.type == functionExternal && curExternal.function) ? curExternal.function._class : null);
@@ -2904,13 +2930,11 @@ Expression GetTemplateArgExpByName(char * paramName, Class curClass, TemplatePar
       {
          char idString[32];
          char className[1024];
-         Expression classExp;
 
          sprintf(idString, "%d", id);
          strcpy(className, "__ecereClass_");
          FullClassNameCat(className, _class.fullName, true);
-         MangleClassName(className);
-         DeclareClass(FindClass(_class.fullName), className);
+         DeclareClass(curExternal, FindClass(_class.fullName), className);
 
          argExp = MkExpIndex((/*pointer ? MkExpPointer : */MkExpMember)
                (MkExpMember(MkExpIdentifier(MkIdentifier("this")), MkIdentifier("_class")) /*MkExpIdentifier(MkIdentifier(className))*/,
@@ -2925,7 +2949,7 @@ Expression GetTemplateArgExp(TemplateParameter param, Class curClass, bool point
    return param.identifier ? GetTemplateArgExpByName(param.identifier.string, curClass, type) : null;
 }
 
-/*char * CreateMsgID(char * string, char * context)
+/*char * CreateMsgID(const char * string, const char * context)
 {
    int lenString = strlen(string), lenContext = strlen(context);
    char * msgid = new char[lenString + lenContext + 20];
@@ -2940,8 +2964,8 @@ public void OutputIntlStrings()
 {
    if(intlStrings.count)
    {
-      char * srcFile = GetSourceFile();
-      char * objFile = GetOutputFile();
+      const char * srcFile = GetSourceFile();
+      const char * objFile = GetOutputFile();
       char srcFileFixed[MAX_LOCATION];
       char potFile[MAX_LOCATION];
       File f;
@@ -2949,11 +2973,12 @@ public void OutputIntlStrings()
       f = FileOpen(potFile, write);
       if(f)
       {
-         char * filePrefix = "";
+         const char * filePrefix = "";
          if(!(srcFile[0] && (srcFile[1] == ':' || srcFile[0] == '/')))
-            filePrefix = "./"; //(GetRuntimePlatform() == win32) ? ".\\" : "./";
+            filePrefix = "./"; //(__runtimePlatform == win32) ? ".\\" : "./";
          // GetSystemPathBuffer(srcFileFixed, srcFile);
          GetSlashPathBuffer(srcFileFixed, srcFile);
+
          for(s : intlStrings)
          {
             // TOFIX: (#654) ContextStringPair * pair = &s;