i18n: (#858) Handling localization for libraries within static executables
[sdk] / compiler / libec / src / ast.ec
index a758930..4d5e08f 100644 (file)
@@ -12,7 +12,9 @@ bool strictNameSpaces;
 public void SetStrictNameSpaces(bool b) { strictNameSpaces = b; }
 
 AccessMode declMode = privateAccess;
-public void SetDeclMode(AccessMode accessMode) { declMode = accessMode; }
+AccessMode structDeclMode = privateAccess;
+
+public void SetDeclMode(AccessMode accessMode) { structDeclMode = declMode = accessMode; }
 AccessMode defaultDeclMode = privateAccess;
 public void SetDefaultDeclMode(AccessMode accessMode) { defaultDeclMode = accessMode; }
 
@@ -55,7 +57,7 @@ public Identifier MkIdentifier(char * string)
 {
    Identifier id { };
    int c;
-   
+
    id._class = null; // Default class...
 
    if(string)
@@ -81,7 +83,7 @@ public Identifier MkIdentifier(char * string)
          // TODO: Do these better, keep in string?
          if(!strcmp(name, "typed_object"))
          {
-            id._class = MkSpecifierName("class");
+            id._class = MkSpecifierName("typed_object"); //"class");
             id.string = CopyString(namePart);
          }
          else if(!strcmp(name, "property"))
@@ -119,7 +121,7 @@ public Identifier MkIdentifier(char * string)
                else
                   id.string = CopyString(string);
             }
-         }         
+         }
       }
       else if(gotColon)
       {
@@ -271,7 +273,7 @@ public struct ContextStringPair
    }
 };
 
-Map<ContextStringPair, List<Location> > intlStrings { };
+Map<ContextStringPair, List<Location>> intlStrings { };
 
 Expression MkExpIntlString(char * string, char * context)
 {
@@ -298,7 +300,8 @@ Expression MkExpIntlString(char * string, char * context)
       }
       list.Add(yylloc);
    }
-   ListAdd(list, QMkExpId("__thisModule"));
+   //ListAdd(list, QMkExpId("__thisModule"));
+   ListAdd(list, MkExpString(QMkString(i18nModuleName ? i18nModuleName : "")));
    ListAdd(list, MkExpString(string));
    if(context)
    {
@@ -421,7 +424,12 @@ Expression MkExpVaArg(Expression exp, TypeName type)
 
 Specifier MkSpecifier(int specifier)
 {
-   return { type = baseSpecifier, specifier = specifier };
+   if(specifier == _BOOL && (declMode != defaultAccess && defaultDeclMode != defaultAccess))
+      return MkSpecifierName("bool");
+   else if(specifier == _BOOL || specifier == BOOL)
+      return { type = baseSpecifier, specifier = specifier };
+   else
+      return { type = baseSpecifier, specifier = specifier };
 }
 
 Specifier MkSpecifierTypeOf(Expression expression)
@@ -441,7 +449,7 @@ Specifier MkSpecifierExtended(ExtDecl extDecl)
 
 Specifier MkEnum(Identifier id, OldList list)
 {
-   Specifier spec 
+   Specifier spec
    {
       type = enumSpecifier;
       id = id;
@@ -482,9 +490,9 @@ Specifier MkStructOrUnion(SpecifierType type, Identifier id, OldList definitions
 {
    Specifier spec { type = type, id = id };
    if(id && FindType(curContext, id.string))
-      declMode = defaultAccess;
+      structDeclMode = defaultAccess;
    spec.definitions = definitions;
-   if(definitions && id && !declMode)
+   if(definitions && id && structDeclMode == defaultAccess)
    {
       OldList specs { };
       Symbol symbol;
@@ -608,19 +616,51 @@ InitDeclarator MkInitDeclarator(Declarator declarator, Initializer initializer)
 
 public TypeName MkTypeName(OldList qualifiers, Declarator declarator)
 {
+   if(qualifiers != null)
+   {
+      Declarator parentDecl = declarator;
+      Declarator decl = declarator;
+      while(decl && decl.type == arrayDeclarator)
+         decl = decl.declarator;
+      if(decl && decl.type == identifierDeclarator && decl.identifier.string && CheckType(decl.identifier.string) == TYPE_NAME)
+      {
+         Specifier spec;
+         // Check if we're missing a real type specifier here
+         for(spec = qualifiers.first; spec; spec = spec.next)
+         {
+            if(spec.type == baseSpecifier)
+            {
+               if(spec.specifier == CONST || spec.specifier == VOLATILE ||
+                  spec.specifier == EXTERN || spec.specifier == STATIC ||
+                  spec.specifier == AUTO || spec.specifier == REGISTER)
+                  continue;
+               break;
+            }
+            else if(spec.type != extendedSpecifier)
+               break;
+         }
+         if(!spec)
+         {
+            // This is actually a type
+            ListAdd(qualifiers, MkSpecifierName(decl.identifier.string));
+            FreeDeclarator(decl);
+            parentDecl.declarator = null;
+         }
+      }
+   }
    return { qualifiers = qualifiers, declarator = declarator };
 }
 
 public TypeName MkTypeNameGuessDecl(OldList qualifiers, Declarator declarator)
 {
-   TypeName typeName { qualifiers = qualifiers, declarator = declarator };
    if(qualifiers != null)
    {
       bool gotType = false;
       bool gotFullType = false;
-      Specifier spec;
-      for(spec = qualifiers.first; spec; spec = spec.next)
+      Specifier spec, next;
+      for(spec = qualifiers.first; spec; spec = next)
       {
+         next = spec.next;
          if(gotType && !declarator && ((spec.type == nameSpecifier && spec.name) || (spec.type == baseSpecifier && gotFullType)))
          {
             String s = null;
@@ -635,20 +675,33 @@ public TypeName MkTypeNameGuessDecl(OldList qualifiers, Declarator declarator)
             }
             if(s)
             {
-               typeName.declarator = declarator = MkDeclaratorIdentifier(MkIdentifier(CopyString(s)));
+               declarator = MkDeclaratorIdentifier(MkIdentifier(s));
                qualifiers.Remove(spec);
                FreeSpecifier(spec);
+               spec = null;
             }
          }
-         if(spec.type != extendedSpecifier)
+         if(spec && spec.type != extendedSpecifier)
          {
-            if(spec.type != baseSpecifier || (spec.specifier != UNSIGNED && spec.specifier != SIGNED && spec.specifier != LONG))
+            if(spec.type == baseSpecifier)
+            {
+               if(spec.specifier == CONST || spec.specifier == VOLATILE ||
+                  spec.specifier == EXTERN || spec.specifier == STATIC ||
+                  spec.specifier == AUTO || spec.specifier == REGISTER)
+                  continue;
+               else if(spec.specifier != UNSIGNED && spec.specifier != SIGNED && spec.specifier != LONG)
+                  gotFullType = true;
+               gotType = true;
+            }
+            else
+            {
                gotFullType = true;
-            gotType = true;
+               gotType = true;
+            }
          }
       }
    }
-   return typeName;
+   return { qualifiers = qualifiers, declarator = declarator };
 }
 
 public Identifier GetDeclId(Declarator decl)
@@ -753,19 +806,20 @@ Declaration MkDeclaration(OldList specifiers, OldList initDeclarators)
 {
    Declaration decl { type = initDeclaration, declarators = initDeclarators, specifiers = specifiers, loc = yylloc };
    bool variable = true;
-   
+
    if(specifiers != null)
    {
       bool gotType = false;
-      Specifier spec;
-      for(spec = specifiers.first; spec; spec = spec.next)
+      Specifier spec, next;
+      for(spec = specifiers.first; spec; spec = next)
       {
+         next = spec.next;
          if(spec.type == baseSpecifier && spec.specifier == TYPEDEF)
          {
             if(initDeclarators != null)
             {
                InitDeclarator d;
-         
+
                for(d = initDeclarators.first; d; d = d.next)
                {
                   if(GetDeclId(d.declarator).string)
@@ -805,7 +859,7 @@ Declaration MkDeclaration(OldList specifiers, OldList initDeclarators)
                         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(CopyString(s))), null));
+                        decl.declarators = initDeclarators = MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier(s)), null));
                         specifiers.Remove(spec);
                         FreeSpecifier(spec);
                         if(!(curContext.templateTypesOnly ? curContext.parent : curContext).types.Add((BTNode)type))
@@ -817,7 +871,7 @@ Declaration MkDeclaration(OldList specifiers, OldList initDeclarators)
             variable = false;
             break;
          }
-         else if(spec.type == baseSpecifier && 
+         else if(spec.type == baseSpecifier &&
             (spec.specifier == STRUCT || spec.specifier == UNION))
             variable = false;
          else
@@ -836,13 +890,14 @@ Declaration MkDeclaration(OldList specifiers, OldList initDeclarators)
                }
                if(s)
                {
-                  decl.declarators = initDeclarators = MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier(CopyString(s))), null));
+                  decl.declarators = initDeclarators = MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier(s)), null));
                   specifiers.Remove(spec);
                   FreeSpecifier(spec);
+                  spec = null;
                }
             }
          }
-         if(spec.type != extendedSpecifier)
+         if(spec && spec.type != extendedSpecifier)
             gotType = true;
       }
    }
@@ -883,7 +938,7 @@ Declaration MkDeclaration(OldList specifiers, OldList initDeclarators)
                   delete id.string;
                   id.string = CopyString(name);
                }
-               
+
                // Avoid memory leaks on duplicated symbols (BinaryTree::Add Would Fail)
                symbol = (Symbol)(curContext.templateTypesOnly ? curContext.parent : curContext).symbols.FindString(id.string);
                if(!symbol)
@@ -950,9 +1005,10 @@ Declaration MkStructDeclaration(OldList specifiers, OldList declarators, Specifi
    if(specifiers != null)
    {
       bool gotType = false;
-      Specifier spec;
-      for(spec = specifiers.first; spec; spec = spec.next)
+      Specifier spec, next;
+      for(spec = specifiers.first; spec; spec = next)
       {
+         next = spec.next;
          if(gotType && declarators == null && ((spec.type == nameSpecifier && spec.name) || spec.type == baseSpecifier))
          {
             String s = null;
@@ -967,12 +1023,13 @@ Declaration MkStructDeclaration(OldList specifiers, OldList declarators, Specifi
             }
             if(s)
             {
-               decl.declarators = declarators = MkListOne(MkDeclaratorIdentifier(MkIdentifier(CopyString(s))));
+               decl.declarators = declarators = MkListOne(MkStructDeclarator(MkDeclaratorIdentifier(MkIdentifier(s)), null));
                specifiers.Remove(spec);
                FreeSpecifier(spec);
+               spec = null;
             }
          }
-         if(spec.type != extendedSpecifier)
+         if(spec && spec.type != extendedSpecifier)
             gotType = true;
       }
    }
@@ -1059,6 +1116,35 @@ Statement MkReturnStmt(OldList exp)
 
 FunctionDefinition MkFunction(OldList specifiers, Declarator declarator, OldList declarationList)
 {
+   return _MkFunction(specifiers, declarator, declarationList, true);
+}
+
+FunctionDefinition _MkFunction(OldList specifiers, Declarator declarator, OldList declarationList, bool errorOnOmit)
+{
+   if(errorOnOmit)
+   {
+      Declarator funcDecl = GetFuncDecl(declarator);
+      if(funcDecl && funcDecl.function.parameters)
+      {
+         TypeName tn;
+         for(tn = funcDecl.function.parameters->first; tn; tn = tn.next)
+         {
+            if(tn.qualifiers || tn.declarator)
+            {
+               Identifier declID = tn.declarator ? GetDeclId(tn.declarator) : null;
+               if(!declID)
+               {
+                  // Check for (void)
+                  Specifier spec = tn.qualifiers ? tn.qualifiers->first : null;
+                  if(!tn.declarator && !tn.prev && !tn.next && spec && !spec.next && spec.type == baseSpecifier && spec.specifier == VOID);
+                  else
+                     Compiler_Error("parameter name omitted\n");
+                  break;
+               }
+            }
+         }
+      }
+   }
    return { specifiers = specifiers, declarator = declarator, declarations = declarationList };
 }
 
@@ -1176,7 +1262,7 @@ External MkExternalFunction(FunctionDefinition function)
       for(spec = function.specifiers->first; spec; spec = spec.next)
          if(spec.type == baseSpecifier && spec.specifier == STATIC)
          {
-            declMode = staticAccess;
+            structDeclMode = declMode = staticAccess;
             break;
          }
    }
@@ -1221,12 +1307,12 @@ External MkExternalDeclaration(Declaration declaration)
       for(spec = declaration.specifiers->first; spec; spec = spec.next)
          if(spec.type == baseSpecifier && spec.specifier == TYPEDEF)
          {
-            declMode = defaultAccess;
+            structDeclMode = declMode = defaultAccess;
             break;
          }
          else if(spec.type == baseSpecifier && spec.specifier == STATIC)
          {
-            declMode = staticAccess;
+            structDeclMode = declMode = staticAccess;
             break;
          }
    }
@@ -1282,7 +1368,7 @@ void SetClassTemplateArgs(Specifier spec, OldList templateArgs)
                   fileInput = backFileInput;
                   if(fileInput)
                   {
-                     fileInput.Seek(yylloc.start.pos, start); 
+                     fileInput.Seek(yylloc.start.pos, start);
                      resetScannerPos(&yylloc.start);
                      yychar = -2;
                   }
@@ -1375,7 +1461,7 @@ Specifier _MkSpecifierName(char * name, Symbol symbol, OldList templateArgs)
          }
       }
       else if(symbol)
-         spec.name = CopyString(symbol.string);   
+         spec.name = CopyString(symbol.string);
       else
          spec.name = CopyString(name);
       spec.symbol = symbol;
@@ -1462,7 +1548,7 @@ void ProcessClassFunctionBody(ClassFunction func, Statement body)
 
       symbol = Symbol
       {
-         
+
       };
 
       {
@@ -1564,7 +1650,7 @@ Instantiation MkInstantiationNamed(OldList specs, Expression exp, OldList member
          }
 
       FreeList(specs, FreeSpecifier);
-         
+
       if(!spec)
       {
          Compiler_Error($"Expecting class specifier\n");
@@ -1689,7 +1775,7 @@ Symbol _DeclClass(int symbolID, char * name)
       for(classContext = curContext; classContext && !classContext.classDef; classContext = classContext.parent);
       if(classContext)
       {
-         
+
       }
       */
       if(name[0] == ':' && name[1] == ':')
@@ -1732,9 +1818,9 @@ void SetupBaseSpecs(Symbol symbol, OldList baseSpecs)
       strcpy(name, ((Specifier)baseSpecs.first).name);
       tpl = strchr(name, '<');
       if(tpl) *tpl = 0;
-      
+
       baseClass = FindClass(name);
-      if(baseClass.ctx)
+      if(baseClass && baseClass.ctx)
       {
          TemplatedType copy;
          for(copy = (TemplatedType)baseClass.ctx.templateTypes.first; copy; copy = (TemplatedType)copy.next)
@@ -1744,7 +1830,7 @@ void SetupBaseSpecs(Symbol symbol, OldList baseSpecs)
                delete type;
          }
       }
-      else if(baseClass.registered)
+      else if(baseClass && baseClass.registered)
       {
          Class sClass;
          for(sClass = baseClass.registered; sClass; sClass = sClass.base)
@@ -1763,7 +1849,7 @@ void SetupBaseSpecs(Symbol symbol, OldList baseSpecs)
                   {
                      p.param = param = TemplateParameter
                      {
-                        identifier = MkIdentifier(p.name), type = p.type, 
+                        identifier = MkIdentifier(p.name), type = p.type,
                         dataTypeString = p.dataTypeString /*, dataType = { specs, decl }*/
                      };
                   }
@@ -1833,7 +1919,7 @@ PropertyDef MkProperty(OldList specs, Declarator decl, Identifier id, Statement
    {
       char typeString[1024];
       typeString[0] = '\0';
-      PrintType(type, typeString, false, true);
+      PrintTypeNoConst(type, typeString, false, true);
       id = MkIdentifier(typeString);
       prop.conversion = true;
    }
@@ -1949,7 +2035,7 @@ TemplatedType FindTemplateTypeParameter(Context ctx, char * name)
 bool ModuleAccess(Module searchIn, Module searchFor)
 {
    SubModule subModule;
-   
+
    if(searchFor == searchIn)
       return true;
 
@@ -1974,8 +2060,8 @@ ModuleImport FindModule(Module moduleToFind)
          break;
    if(!module)
    {
-      module = ModuleImport 
-      { 
+      module = ModuleImport
+      {
          name = CopyString(moduleToFind.name), importType = moduleToFind.importType,
          importAccess = ModuleAccess(privateModule, moduleToFind) ? publicAccess : privateAccess
       };
@@ -1992,7 +2078,7 @@ static void GetFullClassNameSpace(NameSpace * ns, char * name)
    {
       GetFullClassNameSpace(ns->parent, name);
       strcat(name, ns->name);
-      strcat(name, "::");      
+      strcat(name, "::");
    }
 }
 
@@ -2076,7 +2162,7 @@ public Symbol FindClass(char * name)
          }
          */
          if(cl.shortName && !strcmp(cl.shortName, name))
-            break;            
+            break;
       }
 #ifdef _TIMINGS
       findClassIgnoreNSTotalTime += GetTime() - startTime;
@@ -2127,7 +2213,6 @@ void CopyTypeInto(Type type, Type src)
 {
    type = *src;
    type.name = CopyString(src.name);
-   type.enumName = CopyString(src.enumName);
    type.refCount = 1;
 
    if(src.kind == enumType)
@@ -2140,6 +2225,7 @@ void CopyTypeInto(Type type, Type src)
       {
          type.members.Add(NamedLink { name = CopyString(member.name), data = member.data });
       }
+      type.enumName = CopyString(src.enumName);
    }
    else if(src.kind == structType || src.kind == unionType)
    {
@@ -2147,6 +2233,7 @@ void CopyTypeInto(Type type, Type src)
       // Tricky stuff... will be removed from list only when ref count reaches 0
       for(member = type.members.first; member; member = member.next)
          member.refCount++;
+      type.enumName = CopyString(src.enumName);
    }
    else if(src.kind == functionType)
    {
@@ -2167,661 +2254,465 @@ void CopyTypeInto(Type type, Type src)
    }
 }
 
-public Type ProcessType(OldList specs, Declarator decl)
+static Type ProcessTypeSpecs(OldList specs, bool assumeEllipsis, bool keepTypeName)
 {
-   Type type = null;
-   bool isTypedef = false;
-   if(!specs || specs.first)
+   Type specType { refCount = 1, kind = intType, isSigned = true };
+   if(specs != null)
    {
-      Declarator funcDecl = GetFuncDecl(decl);
-      Type specType { };
-      bool dllExport = false;
-
-      specType.kind = intType;
-      specType.isSigned = true;   
-      specType.refCount = 1;
-
-      type = Type { refCount = 1 };
-
-      while(decl && (decl.type == structDeclarator || decl.type == extendedDeclarator || decl.type == extendedDeclaratorEnd))
+      bool isTypedef = false;
+      Specifier spec;
+      bool isLong = false;
+      for(spec = specs.first; spec; spec = spec.next)
       {
-         if(decl.type == structDeclarator && decl.structDecl.exp)
+         if(spec.type == extendedSpecifier)
          {
-            ProcessExpressionType(decl.structDecl.exp);
-            ComputeExpression(decl.structDecl.exp);
-            if(decl.structDecl.exp.type == constantExp)
-               specType.bitFieldCount = strtoul(decl.structDecl.exp.constant, null, 0);
+            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"))
+                  specType.attrStdcall = true;
+            }
+            else if(extDecl.type == extDeclAttrib)
+            {
+               OldList * attribs = extDecl.attr.attribs;
+               if(attribs)
+               {
+                  Attribute attr;
+                  for(attr = attribs->first; attr; attr = attr.next)
+                  {
+                     String s = attr.attr;
+                     if(s)
+                     {
+                        if(!strcmp(s, "dllexport"))
+                           specType.dllExport = true;
+                        else if(!strcmp(s, "stdcall"))
+                           specType.attrStdcall = true;
+                     }
+                  }
+               }
+               specType.keepCast = true;
+            }
          }
-         if((decl.type == extendedDeclarator || decl.type == extendedDeclaratorEnd) && decl.extended.extended && decl.extended.extended.type == extDeclString &&
-            decl.extended.extended.s && (!strcmp(decl.extended.extended.s, "__declspec(dllexport)") || !strcmp(decl.extended.extended.s, "dllexport")))
+
+         if(spec.specifier != CONST && (specType.kind == structType || specType.kind == unionType))
          {
-            dllExport = true;
+            FreeType(specType);
+            specType = { kind = intType, isSigned = true, refCount = 1 };
          }
-         if((decl.type == extendedDeclarator || decl.type == extendedDeclaratorEnd) && decl.extended.extended && decl.extended.extended.type == extDeclAttrib)
+
+         if(isTypedef && keepTypeName)
          {
-            specType.keepCast = true;
+            specType.kind = dummyType;
+            return specType;
          }
-         decl = decl.declarator;
-      }
-
-      // If we'll be using the specType
-      if(funcDecl || !decl || decl.type == identifierDeclarator)
-      {
-         Specifier spec;
-         if(specs != null)
+         else if(spec.type == baseSpecifier)
          {
-            bool isLong = false;
-            for(spec = specs.first; spec; spec = spec.next)
+            if(spec.specifier == TYPEDEF)
+               isTypedef = true;
+            else if(spec.specifier == VOID) specType.kind = voidType;
+            else if(spec.specifier == CHAR) specType.kind = charType;
+            else if(spec.specifier == INT) { if(specType.kind != shortType && specType.kind != longType && !isLong) specType.kind = intType; }
+            else if(spec.specifier == _BOOL || spec.specifier == BOOL)
+               specType.kind = _BoolType;
+            else if(spec.specifier == UINT) { if(specType.kind != shortType && specType.kind != longType) specType.kind = intType; specType.isSigned = false; }
+            else if(spec.specifier == INT64) specType.kind = int64Type;
+            else if(spec.specifier == VALIST)
+               specType.kind = vaListType;
+            else if(spec.specifier == SHORT) specType.kind = shortType;
+            else if(spec.specifier == LONG)
+            {
+               if(isLong || (targetBits == 64 && targetPlatform != win32))
+                  specType.kind = int64Type;
+               else
+                  specType.kind = intType;
+               isLong = true;
+            }
+            else if(spec.specifier == FLOAT) specType.kind = floatType;
+            else if(spec.specifier == DOUBLE) specType.kind = doubleType;
+            else if(spec.specifier == SIGNED) specType.isSigned = true;
+            else if(spec.specifier == UNSIGNED) specType.isSigned = false;
+            else if(spec.specifier == CONST)
+               specType.constant = true;
+            else if(spec.specifier == TYPED_OBJECT || spec.specifier == ANY_OBJECT || spec.specifier == CLASS)
             {
-               if(spec.type == extendedSpecifier && spec.extDecl && spec.extDecl.type == extDeclString && spec.extDecl.s && (!strcmp(spec.extDecl.s, "__declspec(dllexport)") || !strcmp(spec.extDecl.s, "dllexport")))
+               switch(spec.specifier)
                {
-                  dllExport = true;
+                  case TYPED_OBJECT:   specType.classObjectType = typedObject;   break;
+                  case ANY_OBJECT:     specType.classObjectType = anyObject;     break;
+                  case CLASS:          specType.classObjectType = classPointer;  break;
                }
-               if(spec.type == extendedSpecifier && spec.extDecl.type == extDeclAttrib)
+               specType.kind = classType;
+               specType._class = FindClass("class");
+            }
+            else if(spec.specifier == THISCLASS)
+               specType.kind = thisClassType;
+         }
+         else if(spec.type == nameSpecifier)
+         {
+            if(spec.name && (!strcmp(spec.name, "intptr") || !strcmp(spec.name, "uintptr")))
+            {
+               specType.kind = intPtrType;
+               if(!strcmp(spec.name, "uintptr"))
+                  specType.isSigned = false;
+            }
+            else if(spec.name && (!strcmp(spec.name, "uintsize") || !strcmp(spec.name, "intsize")))
+            {
+               specType.kind = intSizeType;
+               if(!strcmp(spec.name, "uintsize"))
+                  specType.isSigned = false;
+            }
+            else
+            {
+               Symbol symbol = spec.name ? FindType(curContext, spec.name) : null;
+               if(symbol && symbol.type)
                {
-                  specType.keepCast = true;
-               }
+                  // Free Type Contents:
+                  Type dummy { };
+                  *dummy = *specType;
+                  FreeType(dummy);
 
-               if(spec.specifier != CONST && (specType.kind == structType || specType.kind == unionType))
+                  CopyTypeInto(specType, symbol.type);
+                  specType.typeName = CopyString(symbol.type.name);
+               }
+               else if(!isTypedef) // !specType.kind)    // TESTING THIS FOR enum / typedef problem
                {
-                  FreeType(specType);
-                  specType = { kind = intType, isSigned = true, refCount = 1 };
+                  // key.sym enum values need FindClass:
+                  specType._class = spec.name ? FindClass(spec.name) : null;
+                  specType.kind = classType;
+                  if(!specType._class)
+                     specType.kind = intType;
                }
+            }
+         }
+         else if(spec.type == enumSpecifier)
+         {
+            specType.kind = enumType;
+            specType.enumName = spec.id ? CopyString(spec.id.string) : null;
 
-               if(spec.type == baseSpecifier)
+            if(spec.list)
+            {
+               Enumerator e;
+               int nextValue = 0;
+               for(e = spec.list->first; e; e = e.next)
                {
-                  if(spec.specifier == TYPEDEF) isTypedef = true;
-                  else if(spec.specifier == VOID) specType.kind = voidType;
-                  else if(spec.specifier == CHAR) specType.kind = charType;
-                  else if(spec.specifier == INT) { if(specType.kind != shortType && specType.kind != longType) specType.kind = intType; }
-                  else if(spec.specifier == UINT) { if(specType.kind != shortType && specType.kind != longType) specType.kind = intType; specType.isSigned = false; }
-                  else if(spec.specifier == INT64) specType.kind = int64Type;
-                  else if(spec.specifier == VALIST) 
-                     specType.kind = vaListType;
-                  else if(spec.specifier == SHORT) specType.kind = shortType;
-                  else if(spec.specifier == LONG) 
-                  {
-                     if(isLong)
-                        specType.kind = int64Type;
-                     else
-                        specType.kind = intType;
-                     isLong = true;
-                     // specType.kind = longType;
-                  }
-                  else if(spec.specifier == FLOAT) specType.kind = floatType;
-                  else if(spec.specifier == DOUBLE) specType.kind = doubleType;
-                  else if(spec.specifier == SIGNED) specType.isSigned = true;
-                  else if(spec.specifier == UNSIGNED) specType.isSigned = false;
-                  else if(spec.specifier == CONST) specType.constant = true;
-                  else if(spec.specifier == TYPED_OBJECT) 
-                  { 
-                     specType.classObjectType = typedObject; specType.kind = classType; specType._class = FindClass("class"); 
-                  }
-                  else if(spec.specifier == ANY_OBJECT) 
-                  { 
-                     specType.classObjectType = anyObject; specType.kind = classType; specType._class = FindClass("class"); 
-                  }
-                  else if(spec.specifier == CLASS)
-                  {
-                     specType.classObjectType = classPointer; specType.kind = classType; specType._class = FindClass("class");
-                  }
-                  else if(spec.specifier == THISCLASS)
-                     specType.kind = thisClassType;
+                  // TOFIX: NamedItem i { } causes cryptic error, bad .c!
+                  NamedLink i { name = CopyString(e.id.string) };
+                  specType.members.Add(i);
                }
-               else if(spec.type == nameSpecifier)
+            }
+         }
+         else if(spec.type == templateTypeSpecifier)
+         {
+            specType.kind = templateType;
+            specType.templateParameter = spec.templateParameter;
+         }
+         else if(spec.type == structSpecifier || spec.type == unionSpecifier)
+         {
+            Symbol _class = spec.id ? FindClass(spec.id.string) : null;
+            if(_class)
+            {
+               specType.declaredWithStruct = true;
+               if(!_class.registered || _class.registered.type != structClass)
+                  specType.directClassAccess = true;     // TODO: Need to clarify what 'directClassAccess' is about
+               specType._class = _class;
+               specType.kind = classType;
+               break;
+            }
+            specType.members.Clear();
+            if(spec.type == structSpecifier)
+               specType.kind = structType;
+            else if(spec.type == unionSpecifier)
+               specType.kind = unionType;
+            if(spec.id)
+            {
+               // TESTING THIS HERE... Had 0 type size
+               if(!spec.definitions && !isTypedef)
                {
-                  if(spec.name && (!strcmp(spec.name, "intptr") || !strcmp(spec.name, "uintptr")))
-                  {
-                     specType.kind = intPtrType;
-                     if(!strcmp(spec.name, "uintptr"))
-                        specType.isSigned = false;
-                  }
-                  else if(spec.name && (!strcmp(spec.name, "uintsize") || !strcmp(spec.name, "intsize")))
-                  {
-                     specType.kind = intSizeType;
-                     if(!strcmp(spec.name, "uintsize"))
-                        specType.isSigned = false;
-                  }
-                  else
+                  Symbol symbol = spec.id.string ? FindSymbol(spec.id.string, curContext, globalContext, true, false) : null;
+                  if(symbol && symbol.type)
                   {
-                     Symbol symbol = spec.name ? FindType(curContext, spec.name) : null;
-                     if(symbol && symbol.type)
+                     specType = *symbol.type;
+                     specType.name = CopyString(symbol.type.name);
+                     specType.typeName = CopyString(spec.name);
+                     specType.enumName = CopyString(symbol.type.enumName);
+                     specType.refCount = 1;
+
+                     if(symbol.type.kind == enumType)
                      {
-                        // Free Type Contents:
-                        Type dummy { };
-                        *dummy = *specType;
-                        FreeType(dummy);
+                        NamedLink member;
 
-                        CopyTypeInto(specType, symbol.type);
-                        specType.typeName = CopyString(symbol.type.name);
+                        specType.members.Clear();
+                        for(member = symbol.type.members.first; member; member = member.next)
+                        {
+                           NamedLink item { name = CopyString(member.name), data = member.data };
+                           specType.members.Add(item);
+                        }
                      }
-                     else if(!isTypedef) // !specType.kind)    // TESTING THIS FOR enum / typedef problem
+                     else if(symbol.type.kind == structType || symbol.type.kind == unionType)
                      {
-                        // key.sym enum values need FindClass:
-                        specType._class = spec.name ? FindClass(spec.name) : null;
-                        // specType._class = spec.symbol; 
-                        specType.kind = classType;
-                        if(!specType._class)
-                           specType.kind = intType;
+                        Type member;
+                        // Tricky stuff... will be removed from list only when ref count reaches 0
+                        for(member = specType.members.first; member; member = member.next)
+                           member.refCount++;
                      }
-                  }
-               }
-               else if(spec.type == enumSpecifier)
-               {
-
-                  specType.kind = enumType;
-                  specType.enumName = spec.id ? CopyString(spec.id.string) : null;
-
-                  if(spec.list)
-                  {
-                     Enumerator e;
-                     int nextValue = 0;
-                     for(e = spec.list->first; e; e = e.next)
+                     else if(symbol.type.kind == functionType)
                      {
-                        // TOFIX: NamedItem i { } causes cryptic error, bad .c!
-                        NamedLink i { name = CopyString(e.id.string) };
-                        specType.members.Add(i);
-                        /*
-                        if(e.exp && ComputeExpression(e.exp), e.exp.isConstant && e.exp.expType.kind == intType)
-                           value.data = (void *) nextValue = strtol(e.exp.string, null, 0);
-                        else
-                           value.data = (void *)nextValue++;
-                        */
+                        Type param;
+                        specType.returnType.refCount++;
+                        for(param = specType.params.first; param; param = param.next)
+                           param.refCount++;
                      }
-                  }
-                  /*
-                  if(spec.list)
-                  {
-                     Declaration decl;
-                     for(enumerator = spec.list->first; enumerator; enumerator = enumerator.next)
-                        if(decl.declarators)
-                        {
-                           Declarator d;
-                           for(d = decl.declarators.first; d; d = d.next)
-                           {
-                              Type memberType = ProcessType(decl.specifiers, d);
-                              specType.members.Add(memberType);
-                           }
-                        }
-                        else if(decl.specifiers)
+                     else if(symbol.type.kind == pointerType || symbol.type.kind == arrayType)
+                     {
+                        specType.type.refCount++;
+                        if(symbol.type.kind == arrayType)
                         {
-                           Type memberType = ProcessType(decl.specifiers, null);
-                           specType.members.Add(memberType);
+                           if(specType.arraySizeExp)
+                              specType.arraySizeExp = CopyExpression(specType.arraySizeExp);
                         }
+
+                     }
                   }
-                  */
-               }
-               else if(spec.type == templateTypeSpecifier)
-               {
-                  /*
-                  printf("spec %x\n", spec);
-                  printf("template param %x\n", spec.templateParameter);
-                  printf("identifier %x\n", spec.templateParameter.identifier);
-                  printf("string %x\n", spec.templateParameter.identifier.string);
-                  */
-                  specType.kind = templateType;
-                  specType.templateParameter = spec.templateParameter;
+                  else
+                     specType.enumName = CopyString(spec.id.string);
                }
-               else if(spec.type == structSpecifier || spec.type == unionSpecifier)
+               else
+                  specType.enumName = CopyString(spec.id.string);
+            }
+
+            if(spec.definitions)
+            {
+               ClassDef def;
+               for(def = spec.definitions->first; def; def = def.next)
                {
-                  Symbol _class = spec.id ? FindClass(spec.id.string) : null;
-                  if(_class)
-                  {
-                     if(!_class.registered || _class.registered.type != structClass)
-                        specType.directClassAccess = true;
-                     specType._class = _class;
-                     specType.kind = classType;
-                     break;
-                  }
-                  if(spec.type == structSpecifier)
-                     specType.kind = structType;
-                  else if(spec.type == unionSpecifier)
-                     specType.kind = unionType;
-                  if(spec.id)
+                  if(def.type == declarationClassDef && def.decl.type == structDeclaration)
                   {
-                     // TESTING THIS HERE... Had 0 type size 
-                     if(!spec.definitions && !isTypedef)
+                     Declaration decl = def.decl;
+                     if(decl.declarators)
                      {
-                        Symbol symbol = spec.id.string ? FindSymbol(spec.id.string, curContext, globalContext, true, false) : null;
-                        if(symbol && symbol.type)
+                        Declarator d;
+                        for(d = decl.declarators->first; d; d = d.next)
                         {
-                           specType = *symbol.type;
-                           specType.name = CopyString(symbol.type.name);
-                           specType.typeName = CopyString(spec.name);
-                           specType.enumName = CopyString(symbol.type.enumName);
-                           specType.refCount = 1;
-
-                           if(symbol.type.kind == enumType)
-                           {
-                              NamedLink member;
-
-                              specType.members.Clear();
-                              for(member = symbol.type.members.first; member; member = member.next)
-                              {
-                                 NamedLink item { name = CopyString(member.name), data = member.data };
-                                 specType.members.Add(item);
-                              }
-                           }
-                           else if(symbol.type.kind == structType || symbol.type.kind == unionType)
-                           {
-                              Type member;
-                              // Tricky stuff... will be removed from list only when ref count reaches 0
-                              for(member = specType.members.first; member; member = member.next)
-                                 member.refCount++;
-                           }
-                           else if(symbol.type.kind == functionType)
-                           {
-                              Type param;
-                              specType.returnType.refCount++;
-                              for(param = specType.params.first; param; param = param.next)
-                                 param.refCount++;
-                           }
-                           else if(symbol.type.kind == pointerType || symbol.type.kind == arrayType)
-                           {
-                              specType.type.refCount++;
-                              if(symbol.type.kind == arrayType)
-                              {
-                                 if(specType.arraySizeExp)
-                                    specType.arraySizeExp = CopyExpression(specType.arraySizeExp);
-                              }
-
-                           }
+                           Type memberType = ProcessType(decl.specifiers, d);
+                           specType.members.Add(memberType);
                         }
-                        else
-                           specType.enumName = CopyString(spec.id.string);
                      }
-                     else
-                        specType.enumName = CopyString(spec.id.string);
-                  }
-
-                  if(spec.definitions)
-                  {
-                     ClassDef def;
-                     for(def = spec.definitions->first; def; def = def.next)
+                     else if(decl.specifiers)
                      {
-                        if(def.type == declarationClassDef && def.decl.type == structDeclaration)
-                        {
-                           Declaration decl = def.decl;
-                           if(decl.declarators)
-                           {
-                              Declarator d;
-                              for(d = decl.declarators->first; d; d = d.next)
-                              {
-                                 Type memberType = ProcessType(decl.specifiers, d);
-                                 specType.members.Add(memberType);
-                              }
-                           }
-                           else if(decl.specifiers)
-                           {
-                              Type memberType = ProcessType(decl.specifiers, null);
-                              specType.members.Add(memberType);
-                           }
-                        }
+                        Type memberType = ProcessType(decl.specifiers, null);
+                        specType.members.Add(memberType);
                      }
                   }
-                  break;
-               }
-               else if(spec.type == subClassSpecifier)
-               {
-                  specType.kind = specType.kind = subClassType;
-                  specType._class = spec._class.symbol; // FindClass(spec._class.name);
-               }
-               /*
-               else if(spec.type == classSpecifier)
-               {
-                  specType._class = FindClass(spec.name);
-                  specType.kind = classType;
                }
-               */
             }
+            break;
+         }
+         else if(spec.type == subClassSpecifier)
+         {
+            specType.kind = specType.kind = subClassType;
+            specType._class = spec._class.symbol;
          }
-         else if(!decl)
-            specType.kind = ellipsisType;
       }
+   }
+   else if(assumeEllipsis)
+      specType.kind = ellipsisType;
+   return specType;
+}
 
-      if(funcDecl)
+static Type ProcessTypeDecls(OldList specs, Declarator decl, Type parentType)
+{
+   Type type = parentType;
+   Declarator subDecl = decl ? decl.declarator : null;
+   if(!parentType)
+      type = ProcessTypeSpecs(specs, decl == null, (decl && decl.type == extendedDeclaratorEnd) ? true : false);
+   if(decl)
+   {
+      switch(decl.type)
       {
-         Declarator d = funcDecl.declarator;
-         Type funcType { };
-         TypeName param;
-
-         funcType.kind = functionType;
-         funcType.refCount = 1;
-         if(funcDecl.function.parameters)
+         case bracketsDeclarator: break;
+         case extendedDeclarator:
+         case extendedDeclaratorEnd:
          {
-            for(param = funcDecl.function.parameters->first; param; param = param.next)
+            ExtDecl extDecl = decl.extended.extended;
+            if(extDecl)
             {
-               /*
-               if(param.typedObject)
+               switch(extDecl.type)
                {
-                  Type typedObjectType
+                  case extDeclString:
                   {
-                     refCount = 1;
-                     byReference = param.byReference;
-                     kind = TypeTypedObject;
-                  };
-                  funcType.params.Add(typedObjectType);
+                     String s = extDecl.s;
+                     if(s)
+                     {
+                        if(!strcmp(s, "__declspec(dllexport)") || !strcmp(s, "dllexport"))
+                           type.dllExport = true;
+                        else if(!strcmp(s, "__declspec(stdcall)") || !strcmp(s, "stdcall"))
+                           type.attrStdcall = true;
+                     }
+                     break;
+                  }
+                  case extDeclAttrib:
+                  {
+                     OldList * attribs = extDecl.attr.attribs;
+                     if(attribs)
+                     {
+                        Attribute attr;
+                        for(attr = attribs->first; attr; attr = attr.next)
+                        {
+                           String s = attr.attr;
+                           if(s)
+                           {
+                              if(!strcmp(s, "dllexport"))
+                                 type.dllExport = true;
+                              else if(!strcmp(s, "stdcall"))
+                                 type.attrStdcall = true;
+                           }
+                        }
+                     }
+                     type.keepCast = true;
+                     break;
+                  }
                }
-               else*/
-                  funcType.params.Add(ProcessType(param.qualifiers, param.declarator));
             }
+            break;
          }
-
-         // Function returning a pointer...
-         if(decl.type == pointerDeclarator)
+         case structDeclarator:
          {
-            Pointer pointer = decl.pointer.pointer;
-            Type ptrType { };
-            funcType.returnType = ptrType;
-            funcType.returnType.refCount = 1;
-            while(pointer)
+            Expression exp = decl.structDecl.exp;
+            if(exp)
             {
-               ptrType.kind = pointerType;
-               pointer = pointer.pointer;
-               if(pointer)
-               {
-                  ptrType.type = Type { refCount = 1 };
-                  ptrType = ptrType.type;
-               }
+               ProcessExpressionType(exp);
+               ComputeExpression(exp);
+               if(exp.type == constantExp)
+                  type.bitFieldCount = (uint)strtoul(exp.constant, null, 0);
             }
-            ptrType.type = Type { refCount = 1 };
-            *ptrType.type = specType;
-         }
-         else
-         {
-            funcType.returnType = Type { refCount = 1 };
-            *funcType.returnType = specType;
+            break;
          }
-
-         // TESTING: Added extendedDeclarator here
-         while(d && (d.type == bracketsDeclarator || d.type == extendedDeclarator || d.type == extendedDeclaratorEnd))
+         case functionDeclarator:
          {
-            if((d.type == extendedDeclarator || d.type == extendedDeclaratorEnd) && d.extended.extended && d.extended.extended.type == extDeclString &&
-               d.extended.extended.s && (!strcmp(d.extended.extended.s, "__declspec(dllexport)") || !strcmp(d.extended.extended.s, "dllexport")))
+            type = { refCount = 1, kind = functionType, returnType = type, dllExport = type.dllExport, attrStdcall = type.attrStdcall };
+            if(decl.function.parameters)
             {
-               dllExport = true;            
+               TypeName param;
+               for(param = decl.function.parameters->first; param; param = param.next)
+                  type.params.Add(ProcessType(param.qualifiers, param.declarator));
             }
-            d = d.declarator;
+            break;
          }
-
-         funcType.dllExport = dllExport;
-
-         if(d && d.type == pointerDeclarator)
+         case arrayDeclarator:
          {
-            Type ptrType;
-            Identifier id;
-
-            if(d.declarator && d.declarator.type == arrayDeclarator)
+            type = { refCount = 1, kind = arrayType, arraySizeExp = CopyExpression(decl.array.exp), freeExp = true, type = type, dllExport = type.dllExport, attrStdcall = type.attrStdcall };
+            if(decl.array.enumClass)
+               type.enumClass = decl.array.enumClass.symbol;
+            break;
+         }
+         case pointerDeclarator:
+         {
+            Pointer pointer = decl.pointer.pointer;
+            while(pointer)
             {
-               // Arrays of pointers to functions (extremely tricky :()
-               Pointer pointer = d.pointer.pointer;
-
-               // TO WORK ON: Fixed the order for the array...
-               type.kind = arrayType;
-               type.arraySizeExp = CopyExpression(d.declarator.array.exp);
-               type.freeExp = true;
-               if(d.declarator.array.enumClass)
-                  type.enumClass = d.declarator.array.enumClass.symbol; // FindClass(d.declarator.array.enumClass.name);
-               if(d.declarator.declarator && d.declarator.declarator.type == arrayDeclarator)
-               {
-                  Type tmpType = type;
-                  Type inType;
-                  type = ProcessType(null, d.declarator.declarator);
-                  inType = type.type;
-                  type.type = tmpType;
-                  tmpType.type = inType;
-               }
+               OldList * qualifiers = pointer.qualifiers;
+               if(type.classObjectType)
+                  type.byReference = true;
                else
-                  type.type = ProcessType(null, d.declarator.declarator);
-
-               for(ptrType = type.type; ptrType && ptrType.kind && ptrType.type; ptrType = ptrType.type);
-
-               while(pointer)
-               {
-                  ptrType.kind = pointerType;
-                  pointer = pointer.pointer;
-                  if(pointer)
-                  {
-                     ptrType.type = Type { refCount = 1 };
-                     ptrType = ptrType.type;
-                  }
-               }
-               ptrType.type = ProcessType(specs, null);
-            }
-            else
-            {
-               // WARNING: Not caring if this declarator contains a declarator between
-               //          the pointer and the function other than brackets (like in the case of array of pointers to functions)...
-               // *********** Could it ever go in here???  Yes: void (* converters_table[10]) (); ***********
-               Pointer pointer = d.pointer.pointer;
-
-               ptrType = type;
-               while(pointer)
-               {
-                  ptrType.kind = pointerType;
-                  ptrType.type = Type { refCount = 1 };
-                  pointer = pointer.pointer;
-                  if(pointer)
-                     ptrType = ptrType.type;
-               }
-            }
-
-            *ptrType.type = funcType;
-            id = GetDeclId(d);
-            if(id)
-            {
-               if(id._class && !id._class.name)
-                  ptrType.type.staticMethod =  true;
-               else 
+                  type = { refCount = 1, kind = pointerType, type = type, dllExport = type.dllExport, attrStdcall = type.attrStdcall };
+               if(qualifiers)
                {
-                  // TODO : Ensure classSym has been resolved here... (Is this gonna cause problems? Supposed to do this later...)
-                  if(!id.classSym)
+                  Specifier spec;
+                  for(spec = qualifiers->first; spec; spec = spec.next)
                   {
-                     if(id._class && id._class.name)
-                     {
-                        id.classSym = id._class.symbol; // FindClass(id._class.name);
-                        /* TODO: Name Space Fix ups
-                        if(!id.classSym)
-                           id.nameSpace = eSystem_FindNameSpace(privateModule, id._class.name);
-                        */
-                     }
-                  }
-
-                  ptrType.type.thisClass = id.classSym;
-                  if(ptrType.type.thisClass && strcmp(ptrType.type.thisClass.string, "class"))
-                     ptrType.type.extraParam = true;
-                  else if(id._class && id._class.name && !strcmp(id._class.name, "any_object"))
-                  {
-                     ptrType.type.extraParam = true;
-                     ptrType.type.thisClass = FindClass("class");
+                     if(spec.type == baseSpecifier && spec.specifier == CONST)
+                        type.constant = true;
                   }
                }
-
-               type.name = CopyString(id.string);
+               pointer = pointer.pointer;
             }
+            break;
          }
-         else if(!d || d.type == identifierDeclarator)
+         case identifierDeclarator:
          {
-
-            *type = funcType;
-            if(d)
+            Identifier id = decl.identifier;
+            Specifier _class = id._class;
+            delete type.name;
+            type.name = CopyString(id.string);
+            if(_class)
             {
-               if(d.identifier._class && d.identifier._class.type == templateTypeSpecifier)
+               if(_class.type == templateTypeSpecifier)
                {
-                  type.thisClassTemplate = d.identifier._class.templateParameter;
+                  type.thisClassTemplate = _class.templateParameter;
                   type.extraParam = true;
                }
                else
                {
-                  if(d.identifier._class && !d.identifier._class.name)
+                  String name = _class.name;
+                  if(!name)
                      type.staticMethod = true;
                   else
                   {
-                     if(d.identifier._class && d.identifier._class.name && d.identifier._class.name[strlen(d.identifier._class.name)-1] == '&')
+                     if(!id.classSym)
+                        id.classSym = _class.symbol; // FindClass(_class.name);
+                     /* TODO: Name Space Fix ups
+                        id.nameSpace = eSystem_FindNameSpace(privateModule, _class.name);
+                     */
+
+                     if(name[strlen(name)-1] == '&')
                      {
                         type.thisClass = FindClass("class");
                         type.byReference = true;
                      }
                      else
-                        type.thisClass = d.identifier._class ? d.identifier._class.symbol /*FindClass(d.identifier._class.name)*/ : null;
+                        type.thisClass = _class.symbol;
+
                      if(type.thisClass && strcmp(type.thisClass.string, "class"))
+                        type.extraParam = true;
+                     else if(!strcmp(name, "any_object"))
                      {
                         type.extraParam = true;
+                        type.thisClass = FindClass("class");
                      }
-                     else if(d.identifier._class && d.identifier._class.name && !strcmp(d.identifier._class.name, "any_object"))
+                     else if(!strcmp(name, "class"))
                      {
-                        type.extraParam = true;
                         type.thisClass = FindClass("class");
+                        type.classObjectType = classPointer;   // This is used for class properties
                      }
-                     else if(d.identifier._class && d.identifier._class.name && !strcmp(d.identifier._class.name, "class"))
+                     else if(!strcmp(name, "typed_object") || !strcmp(name, "typed_object&"))
                      {
-                        //type.extraParam = true;
                         type.thisClass = FindClass("class");
-                        type.classObjectType = classPointer;
+                        type.classObjectType = typedObject;
                      }
                   }
                }
-               type.name = CopyString(d.identifier.string);
             }
+            break;
          }
-         delete funcType;
-      }
-      else if(decl && decl.type == pointerDeclarator)
-      {
-         if(decl.declarator && decl.declarator.type == arrayDeclarator)
-         {
-            // Arrays of pointers (tricky :))
-            Identifier id;
-            Pointer pointer = decl.pointer.pointer;
-            Type ptrType;
-
-            // TO WORK ON: Fixed the order for the array...
-            type.kind = arrayType;
-            type.arraySizeExp = CopyExpression(decl.declarator.array.exp);
-            type.freeExp = true;
-            if(decl.declarator.array.enumClass)
-               type.enumClass = decl.declarator.array.enumClass.symbol; // FindClass(decl.declarator.array.enumClass.name);
-            if(decl.declarator.declarator && decl.declarator.declarator.type == arrayDeclarator)
-            {
-               Type tmpType = type;
-               Type inType;
-               type = ProcessType(null, decl.declarator.declarator);
-               inType = type.type;
-               type.type = tmpType;
-               tmpType.type = inType;
-            }
-            else
-               type.type = ProcessType(null, decl.declarator.declarator);
-            /*
-            type.type = ProcessType(null, decl.declarator.declarator);
-            type.kind = arrayType;
-            type.arraySizeExp = CopyExpression(decl.declarator.array.exp);
-            type.arraySizeExp.freeExp = true;
-            if(decl.array.enumClass)
-               type.enumClass = FindClass(decl.array.enumClass.name);
-            */
-
-            for(ptrType = type.type; ptrType && ptrType.kind && ptrType.type; ptrType = ptrType.type);
-
-            while(pointer)
-            {
-               ptrType.kind = pointerType;
-               pointer = pointer.pointer;
-               if(pointer)
-               {
-                  ptrType.type = Type { refCount = 1 };
-                  ptrType = ptrType.type;
-               }
-            }
-            ptrType.type = ProcessType(specs, null);
-            id = GetDeclId(decl);
-            if(id) type.name = CopyString(id.string);
-         }
-         else
-         {
-            Identifier id;
-            Pointer pointer = decl.pointer.pointer;
-            Type ptrType = type;
-
-            if(type.classObjectType)
-            {
-               type.byReference = true;
-            }
-            else
-            {
-               while(pointer)
-               {
-                  ptrType.kind = pointerType;
-                  pointer = pointer.pointer;
-                  if(pointer)
-                  {
-                     ptrType.type = Type { refCount = 1 };
-                     ptrType = ptrType.type;
-                  }
-               }
-               ptrType.type = ProcessType(specs, decl.declarator);
-
-               if(type.type.classObjectType)
-               {
-                  Type subType = type.type;
-                  type.classObjectType = subType.classObjectType;
-                  type.kind = subType.kind;
-                  type._class = subType._class;
-                  type.byReference = true;
-
-                  FreeType(subType);
-               }
-               id = GetDeclId(decl);
-               if(id) type.name = CopyString(id.string);
-            }
-         }
-      }
-      else if(decl && decl.type == arrayDeclarator)
-      {
-         Identifier id;
-
-         type.kind = arrayType;
-         
-         type.arraySizeExp = CopyExpression(decl.array.exp);
-         type.freeExp = true;
-         if(decl.array.enumClass)
-            type.enumClass = decl.array.enumClass.symbol; // FindClass(decl.array.enumClass.name);
-         id = GetDeclId(decl);
-
-         // TO WORK ON: Fixed the order for the array...
-         if(decl.declarator && decl.declarator.type == arrayDeclarator)
-         {
-            Type tmpType = type;
-            Type inType;
-            type = ProcessType(specs, decl.declarator);
-            inType = type.type;
-            type.type = tmpType;
-            tmpType.type = inType;
-         }
-         else
-            type.type = ProcessType(specs, decl.declarator);
-
-         if(id)
-         {
-            delete type.name;
-            type.name = CopyString(id.string);
-         }
+         default:
+            PrintLn("Unhandled Declarator Type: ", decl.type);
       }
-      else
+   }
+   if(subDecl)
+   {
+      Type curType = type;
+      type = ProcessTypeDecls(null, subDecl, type);
+      if(curType && type.kind != functionType)
       {
-         if(!decl || decl.type == identifierDeclarator)
-         {
-            *type = specType;
-            delete type.name;
-            type.name = decl ? CopyString(decl.identifier.string) : null;
-
-         }   
+         curType.thisClassTemplate = type.thisClassTemplate;
+         curType.extraParam = type.extraParam;
+         curType.staticMethod = type.staticMethod;
+         curType.thisClass = type.thisClass;
+         curType.byReference = type.byReference;
+         curType.classObjectType = type.classObjectType;
       }
-      delete specType;
    }
    return type;
 }
 
+public Type ProcessType(OldList specs, Declarator decl)
+{
+   return ProcessTypeDecls(specs, decl, null);
+}
+
 public Type ProcessTypeString(char * string, bool staticMethod)
 {
    OldList * specs = MkList();
@@ -2865,15 +2756,15 @@ public Type MkClassType(char * name)
    return null;
 }
 
-AsmField MkAsmField(char * command, Expression expression)
+AsmField MkAsmField(char * command, Expression expression, Identifier symbolic)
 {
-   return { command = command, expression = expression };
+   return { command = command, expression = expression, symbolic = symbolic };
 }
 
 Statement MkAsmStmt(Specifier spec, char * statements, OldList inputFields, OldList outputFields, OldList clobberedFields)
 {
-   return { type = asmStmt, asmStmt.spec = spec, asmStmt.statements = statements, 
-      asmStmt.inputFields = inputFields, asmStmt.outputFields = outputFields, 
+   return { type = asmStmt, asmStmt.spec = spec, asmStmt.statements = statements,
+      asmStmt.inputFields = inputFields, asmStmt.outputFields = outputFields,
       asmStmt.clobberedFields = clobberedFields };
 }
 
@@ -3001,7 +2892,7 @@ 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);
@@ -3009,11 +2900,11 @@ Expression GetTemplateArgExpByName(char * paramName, Class curClass, TemplatePar
          DeclareClass(FindClass(_class.fullName), className);
 
          argExp = MkExpIndex((/*pointer ? MkExpPointer : */MkExpMember)
-               (MkExpMember(MkExpIdentifier(MkIdentifier("this")), MkIdentifier("_class")) /*MkExpIdentifier(MkIdentifier(className))*/, 
+               (MkExpMember(MkExpIdentifier(MkIdentifier("this")), MkIdentifier("_class")) /*MkExpIdentifier(MkIdentifier(className))*/,
                MkIdentifier("templateArgs")), MkListOne(MkExpConstant(idString)));
       }
    }
-   return argExp; 
+   return argExp;
 }
 
 Expression GetTemplateArgExp(TemplateParameter param, Class curClass, bool pointer)
@@ -3070,6 +2961,7 @@ public void OutputIntlStrings()
 
 default extern OldList * ast;
 default extern int yyparse ();
+default extern int yylex ();
 
 public void SetAST(OldList * list) { ast = list; }
 public OldList * GetAST() { return ast; }
@@ -3077,3 +2969,13 @@ public void ParseEc()
 {
    yyparse();
 }
+
+public int LexEc()
+{
+   return yylex();
+}
+
+public const char * GetYYText()
+{
+   return yytext;
+}