compiler/libec: (#439) Removed unused declID from DeclClass()
[sdk] / compiler / libec / src / dbpass.ec
index 2b76996..e0971ed 100644 (file)
@@ -34,7 +34,7 @@ static void ProcessSpecifier(Specifier spec)
                      MemberInit init;
                      for(init = def.defProperties->first; init; init = init.next)
                      {
-                        Class oldThisClass = thisClass;
+                        //Class oldThisClass = thisClass;
                         ProcessMemberInit(init);
                      }
                      break;
@@ -54,6 +54,10 @@ static void ProcessSpecifier(Specifier spec)
                         ProcessStatement(def.propertyWatch.compound);
                      }
                      break;
+                  case classPropertyValueClassDef:
+                     if(def.initializer)
+                        ProcessInitializer(def.initializer);
+                     break;
                }
             }
          }
@@ -111,7 +115,7 @@ static void ProcessExpression(Expression exp)
       {
          Expression expression;
          ProcessExpression(exp.index.exp);
-         
+
          for(expression = exp.index.index->first; expression; expression = expression.next)
          {
             ProcessExpression(expression);
@@ -121,7 +125,7 @@ static void ProcessExpression(Expression exp)
       case callExp:
       {
          ProcessExpression(exp.call.exp);
-         
+
          if(exp.call.arguments)
          {
             Expression expression;
@@ -169,7 +173,7 @@ static void ProcessExpression(Expression exp)
          sprintf(name, "__ecereDBField_%s_%s", tableName, exp.db.id.string);
          FreeExpContents(exp);
          exp.type = identifierExp;
-         exp.identifier = MkIdentifier(name);                          
+         exp.identifier = MkIdentifier(name);
          break;
       }
       case dbtableExp:
@@ -183,7 +187,7 @@ static void ProcessExpression(Expression exp)
          sprintf(name, "__ecereDBTable_%s", tableName);
          FreeExpContents(exp);
          exp.type = identifierExp;
-         exp.identifier = MkIdentifier(name);                          
+         exp.identifier = MkIdentifier(name);
          break;
       }
       case dbindexExp:
@@ -197,7 +201,7 @@ static void ProcessExpression(Expression exp)
          sprintf(name, "__ecereDBIndex_%s_%s", tableName, exp.db.id.string);
          FreeExpContents(exp);
          exp.type = identifierExp;
-         exp.identifier = MkIdentifier(name);                          
+         exp.identifier = MkIdentifier(name);
          break;
       }
       case dbopenExp:
@@ -205,25 +209,25 @@ static void ProcessExpression(Expression exp)
          if(tableStatements)
          {
             Statement databaseOpenStmt = MkCompoundStmt(MkList(), MkList());
-            Statement compound, compound2;
+            Statement compound/*, compound2*/;
             Statement ifDBStmt;
             OldList * args;
             char numIndexesString[16];
 
             databaseOpenStmt.compound.context = Context { parent = curContext };
 
-            databaseOpenStmt.compound.declarations->Add(MkDeclaration(MkListOne(MkSpecifierName("Database")), 
+            databaseOpenStmt.compound.declarations->Add(MkDeclaration(MkListOne(MkSpecifierName("Database")),
                MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("db")), null))));
 
             // bool createNow = false;
-            databaseOpenStmt.compound.declarations->Add(MkDeclaration(MkListOne(MkSpecifierName("bool")), 
-               MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("createNow")), MkInitializerAssignment(MkExpIdentifier(MkIdentifier("false")))))));
+            /*databaseOpenStmt.compound.declarations->Add(MkDeclaration(MkListOne(MkSpecifierName("bool")),
+               MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("createNow")), MkInitializerAssignment(MkExpIdentifier(MkIdentifier("false")))))));*/
 
             // static bool initialized = false;
             args = MkList();
             args->Add(MkSpecifier(STATIC));
             args->Add(MkSpecifierName("bool"));
-            databaseOpenStmt.compound.declarations->Add(MkDeclaration(args, 
+            databaseOpenStmt.compound.declarations->Add(MkDeclaration(args,
                MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("initialized")), MkInitializerAssignment(MkExpIdentifier(MkIdentifier("false")))))));
 
             // Assuming we're in a function where we can return 0 (Typically a DataBase InitSchema() or an Application constructor)
@@ -237,49 +241,49 @@ static void ProcessExpression(Expression exp)
             args = MkList();
             args->Add(CopyExpression(exp.dbopen.name));
             args->Add(MkExpIdentifier(MkIdentifier("no")));
-            databaseOpenStmt.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier("db")), '=', 
+            databaseOpenStmt.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier("db")), '=',
                MkExpCall(MkExpMember(CopyExpression(exp.dbopen.ds), MkIdentifier("OpenDatabase")), args)))));
-            
+
             /*if(!db)
             {
                db = ds.OpenDatabase("med", create);
                createNow = true;
             }
             */
-            databaseOpenStmt.compound.statements->Add(MkIfStmt(MkListOne(MkExpOp(null, '!', MkExpIdentifier(MkIdentifier("db")))), 
+            databaseOpenStmt.compound.statements->Add(MkIfStmt(MkListOne(MkExpOp(null, '!', MkExpIdentifier(MkIdentifier("db")))),
                compound = MkCompoundStmt(null, MkList()), null));
             compound.compound.context = Context { parent = databaseOpenStmt.compound.context };
-            
+
             args = MkList();
             args->Add(exp.dbopen.name);
             args->Add(MkExpIdentifier(MkIdentifier("create")));
-            compound.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier("db")), '=', 
+            compound.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier("db")), '=',
                MkExpCall(MkExpMember(exp.dbopen.ds, MkIdentifier("OpenDatabase")), args)))));
-            compound.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier("createNow")), '=', 
-               MkExpIdentifier(MkIdentifier("true"))))));
+            /*compound.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier("createNow")), '=',
+               MkExpIdentifier(MkIdentifier("true")))));*/
 
             exp.dbopen.name = null;
             exp.dbopen.ds = null;
 
             // if(db)
-            databaseOpenStmt.compound.statements->Add(MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("db"))), 
+            databaseOpenStmt.compound.statements->Add(MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("db"))),
                ifDBStmt = MkCompoundStmt(MkList(), MkList()), null));
 
             ifDBStmt.compound.context = Context { parent = databaseOpenStmt.compound.context };
 
             // FieldIndex indexes[numIndexes] = { null };
             sprintf(numIndexesString, "%d", numIndexes);
-            ifDBStmt.compound.declarations->Add(MkDeclaration(MkListOne(MkSpecifierName("FieldIndex")), MkListOne(MkInitDeclarator(MkDeclaratorArray(MkDeclaratorIdentifier(MkIdentifier("indexes")), 
+            ifDBStmt.compound.declarations->Add(MkDeclaration(MkListOne(MkSpecifierName("FieldIndex")), MkListOne(MkInitDeclarator(MkDeclaratorArray(MkDeclaratorIdentifier(MkIdentifier("indexes")),
                MkExpConstant(numIndexesString)), MkInitializerList(MkListOne(MkInitializerList(MkListOne(MkInitializerAssignment(MkExpIdentifier(MkIdentifier("null")))))))))));
-            
+
             // db.Begin();
             ifDBStmt.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpCall(MkExpMember(MkExpIdentifier(MkIdentifier("db")), MkIdentifier("Begin")), MkList()))));
 
             ifDBStmt.compound.statements->Add(compound = MkCompoundStmt(null, tableStatements));
             compound.compound.context = Context { parent = ifDBStmt.compound.context };
             /*
-            ifDBStmt.compound.statements->Add(MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("createNow"))), 
-               (compound = MkCompoundStmt(null, addFieldStatements), compound.compound.context = Context { parent = ifDBStmt.compound.context }, compound), 
+            ifDBStmt.compound.statements->Add(MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("createNow"))),
+               (compound = MkCompoundStmt(null, addFieldStatements), compound.compound.context = Context { parent = ifDBStmt.compound.context }, compound),
                (compound2 = MkCompoundStmt(null, findFieldStatements), compound2.compound.context = Context { parent = ifDBStmt.compound.context }, compound2)));
             */
             ifDBStmt.compound.statements->Add(
@@ -432,12 +436,12 @@ static void ProcessStatement(Statement stmt)
          {
             ProcessStatement(stmt.forStmt.init);
          }
-         
+
          if(stmt.forStmt.check)
          {
             ProcessStatement(stmt.forStmt.check);
          }
-         
+
          if(stmt.forStmt.increment)
          {
             for(exp = stmt.forStmt.increment->first; exp; exp = exp.next)
@@ -460,7 +464,7 @@ static void ProcessStatement(Statement stmt)
          if(stmt.expressions)
          {
             Expression exp;
-            
+
             for(exp = stmt.expressions->first; exp; exp = exp.next)
             {
                ProcessExpression(exp);
@@ -521,7 +525,7 @@ static void ProcessInitializer(Initializer initializer)
       case listInitializer:
       {
          Initializer init;
-         
+
          for(init = initializer.list->first; init; init = init.next)
          {
             ProcessInitializer(init);
@@ -575,7 +579,7 @@ static void ProcessDeclaration(Declaration decl)
             for(d = decl.declarators->first; d; d = d.next)
             {
                ProcessInitDeclarator(d);
-            }   
+            }
          }
          break;
       }
@@ -608,7 +612,7 @@ static void ProcessInstance(Instantiation inst)
       MembersInit init;
       MemberInit memberInit;
       for(init = inst.members->first; init; init = init.next)
-      {         
+      {
          if(init.type == dataMembersInit && init.dataMembers)
          {
             for(memberInit = init.dataMembers->first; memberInit; memberInit = memberInit.next)
@@ -661,6 +665,10 @@ static void ProcessClassDef(ClassDef def)
          }
          break;
       }
+      case classPropertyValueClassDef:
+         if(def.initializer)
+            ProcessInitializer(def.initializer);
+         break;
       case functionClassDef:
          ProcessClassFunction(def.function);
          break;
@@ -691,8 +699,6 @@ static void ProcessClass(ClassDefinition _class)
    }
 }
 
-static int curSymbolID = 0;
-
 static void ProcessDBTable(DBTableDef table)
 {
    OldList * rowClassDefs = MkList(), * idClassDefs = null;
@@ -704,7 +710,6 @@ static void ProcessDBTable(DBTableDef table)
    char nameField[1024];
    OldList * args;
    OldList * members;
-   int symbolID = curSymbolID; //MAXINT; //globalContext.nextID++;
    if(table.symbol)
       idClassDefs = MkList();
 
@@ -717,7 +722,7 @@ static void ProcessDBTable(DBTableDef table)
 
    sprintf(rowClassName, "Row%s", tableName);
    ChangeCh(rowClassName, ' ', '_');
-      
+
    if(!tableStatements)
    {
       tableStatements = MkList();
@@ -734,7 +739,7 @@ static void ProcessDBTable(DBTableDef table)
          MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier(tableID)), null))));
       external.declaration.declMode = table.declMode;
       ast->Insert(addAfter, external);
-  
+
       // tClasses          = db.OpenTable("Classes",        { tableRows, create });
       args = MkList();
       tableStatements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(tableID)), '=', MkExpCall(MkExpMember(MkExpIdentifier(MkIdentifier("db")), MkIdentifier("OpenTable")),
@@ -755,13 +760,12 @@ static void ProcessDBTable(DBTableDef table)
       inheritanceSpecs->Add(MkSpecifier(PRIVATE));
       inheritanceSpecs->Add(MkSpecifierName("Row"));
       PushContext();
-      _class = MkClass(DeclClass(globalContext.nextID++, rowClassName), inheritanceSpecs, rowClassDefs);
+      _class = MkClass(DeclClass(rowClassName), inheritanceSpecs, rowClassDefs);
       PopContext(curContext);
 
       def = MkClassDefDefaultProperty(MkListOne(MkMemberInitExp(MkExpIdentifier(MkIdentifier("tbl")), MkInitializerAssignment(MkExpIdentifier(MkIdentifier(tableID))))));
       rowClassDefs->Add(def);
 
-       _class.symbol.idCode = symbolID;
       _class.declMode = table.declMode;
       external = MkExternalClass(_class);
       ast->Insert(addAfter, external);
@@ -805,7 +809,7 @@ static void ProcessDBTable(DBTableDef table)
                      curContext = rowSet.compound.context = Context { parent = globalContext };
 
                      // Find(fieldSECid, middle, nil, value);
-                     rowSet.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("Find")), 
+                     rowSet.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("Find")),
                         args = MkList()))));
                      args->Add(MkExpIdentifier(MkIdentifier(fieldID)));
                      args->Add(MkExpIdentifier(MkIdentifier("middle")));
@@ -815,9 +819,9 @@ static void ProcessDBTable(DBTableDef table)
                      curContext = globalContext;
 
                      def = MkClassDefProperty(MkProperty(
-                        CopyList(entry.dataType.qualifiers, CopySpecifier), CopyDeclarator(entry.dataType.declarator), 
+                        CopyList(entry.dataType.qualifiers, CopySpecifier), CopyDeclarator(entry.dataType.declarator),
                            MkIdentifier(name), rowSet, null));
-                     def.propertyDef.symbol.id = def.propertyDef.symbol.idCode = symbolID;
+                     def.propertyDef.isDBProp = true;
                      def.memberAccess = publicAccess;
                      rowClassDefs->Add(def);
                   }
@@ -826,7 +830,7 @@ static void ProcessDBTable(DBTableDef table)
                {
                   Statement rowSet = MkCompoundStmt(MkList(), MkList()), rowGet = MkCompoundStmt(MkList(), MkList());
                   ClassDef def;
-                  
+
                   curContext = rowGet.compound.context = Context { parent = globalContext };
 
                   // *** GET ***
@@ -838,13 +842,13 @@ static void ProcessDBTable(DBTableDef table)
                   else
                   {
                      Expression exp;
-                     rowGet.compound.declarations->Add(MkDeclaration(CopyList(entry.dataType.qualifiers, CopySpecifier), 
+                     rowGet.compound.declarations->Add(MkDeclaration(CopyList(entry.dataType.qualifiers, CopySpecifier),
                         MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("d")), MkInitializerAssignment(exp = MkExpConstant("0"))))));
                      exp.destType = Type { kind = intType, refCount = 1 };
                   }
 
                   // GetData(fieldCNTid, d);
-                  rowGet.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("GetData")), 
+                  rowGet.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("GetData")),
                      args = MkList()))));
                   args->Add(MkExpIdentifier(MkIdentifier(fieldID)));
                   /*if(spec.type == nameSpecifier && spec.symbol && spec.symbol.registered && spec.symbol.registered.type == structClass)
@@ -855,7 +859,7 @@ static void ProcessDBTable(DBTableDef table)
                   // return d;
                   if(spec.type == nameSpecifier && spec.symbol && spec.symbol.registered && spec.symbol.registered.type == structClass)
                   {
-                     rowGet.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier("value")), '=', 
+                     rowGet.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier("value")), '=',
                         MkExpIdentifier(MkIdentifier("d"))))));
                   }
                   else
@@ -863,16 +867,16 @@ static void ProcessDBTable(DBTableDef table)
 
                   // *** SET ***
                   curContext = rowSet.compound.context = Context { parent = globalContext };
-                  
+
                   // SetData(fieldCNTid, value);
-                  rowSet.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("SetData")), 
+                  rowSet.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("SetData")),
                      args = MkList()))));
                   args->Add(MkExpIdentifier(MkIdentifier(fieldID)));
                   args->Add(MkExpIdentifier(MkIdentifier("value")));
 
                   curContext = globalContext;
                   def = MkClassDefProperty(MkProperty(CopyList(entry.dataType.qualifiers, CopySpecifier), entry.dataType.declarator, CopyIdentifier(entry.id), rowSet, rowGet));
-                  def.propertyDef.symbol.id = def.propertyDef.symbol.idCode = symbolID;
+                  def.propertyDef.isDBProp = true;
                   def.memberAccess = publicAccess;
                   rowClassDefs->Add(def);
                }
@@ -884,7 +888,7 @@ static void ProcessDBTable(DBTableDef table)
                      MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier(fieldID)), null))));
                   ast->Add(external);
                   external.declaration.declMode = table.declMode;
-               
+
                   // fieldCLSname      = tClasses.AddField("name", class(String), 0 );
                   args = MkList();
                   addFieldStatements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(fieldID)), '=', MkExpCall(MkExpMember(MkExpIdentifier(MkIdentifier(tableID)), MkIdentifier("FindField")),
@@ -893,7 +897,7 @@ static void ProcessDBTable(DBTableDef table)
 
                   args = MkList();
                   addFieldStatements->Add(
-                     MkIfStmt(MkListOne(MkExpOp(null, '!', MkExpIdentifier(MkIdentifier(fieldID)))), 
+                     MkIfStmt(MkListOne(MkExpOp(null, '!', MkExpIdentifier(MkIdentifier(fieldID)))),
                         MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(fieldID)), '=', MkExpCall(MkExpMember(MkExpIdentifier(MkIdentifier(tableID)), MkIdentifier("AddField")),
                      args)))), null));
                   args->Add(MkExpString(entry.name));
@@ -911,11 +915,11 @@ static void ProcessDBTable(DBTableDef table)
                if(isIndex)
                {
                   // indexes[0].field = fieldCLSid;
-                  indexStatements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIndex(MkExpIdentifier(MkIdentifier("indexes")), 
+                  indexStatements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIndex(MkExpIdentifier(MkIdentifier("indexes")),
                      MkListOne(MkExpConstant("0"))), MkIdentifier("field")),  '=', MkExpIdentifier(MkIdentifier(fieldID))))));
 
                   // indexes[0].order = ascending;
-                  indexStatements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIndex(MkExpIdentifier(MkIdentifier("indexes")), 
+                  indexStatements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIndex(MkExpIdentifier(MkIdentifier("indexes")),
                      MkListOne(MkExpConstant("0"))), MkIdentifier("order")),  '=', MkExpIdentifier(MkIdentifier("ascending"))))));
 
                   // tClasses.Index(1, indexes);
@@ -938,7 +942,6 @@ static void ProcessDBTable(DBTableDef table)
       ClassDef def;
       Expression exp;
 
-      // table.symbol.id = table.symbol.idCode = globalContext.nextID++;
       PushContext();
       _class = MkClass(table.symbol, MkListOne(MkSpecifierName("Id")), idClassDefs);
       PopContext(curContext);
@@ -955,7 +958,7 @@ static void ProcessDBTable(DBTableDef table)
          def = MkClassDefClassPropertyValue(MkIdentifier("nameField"), MkInitializerAssignment(exp = MkExpOp(null, '&', MkExpDBField(CopyString(table.name), MkIdentifier(nameField)))));
          ProcessExpression(exp);
          idClassDefs->Add(def);
-      }      
+      }
       // indexed = true;
    }
 
@@ -984,9 +987,9 @@ static void ProcessDBTable(DBTableDef table)
 
                   // *** GET ***
                   // RowContacts r { this };
-                  idGet.compound.declarations->Add(MkDeclarationInst(MkInstantiation(MkSpecifierName(rowClassName), MkExpIdentifier(MkIdentifier("r")), 
+                  idGet.compound.declarations->Add(MkDeclarationInst(MkInstantiation(MkSpecifierName(rowClassName), MkExpIdentifier(MkIdentifier("r")),
                      MkListOne(MkMembersInitList(MkListOne(MkMemberInit(null, MkInitializerAssignment(MkExpIdentifier(MkIdentifier("this"))))))))));
-                  
+
                   // Contact d = null;
                   if(spec.type == nameSpecifier && spec.symbol && spec.symbol.registered && spec.symbol.registered.type == structClass)
                   {
@@ -995,13 +998,13 @@ static void ProcessDBTable(DBTableDef table)
                   else
                   {
                      Expression exp;
-                     idGet.compound.declarations->Add(MkDeclaration(CopyList(entry.dataType.qualifiers, CopySpecifier), 
+                     idGet.compound.declarations->Add(MkDeclaration(CopyList(entry.dataType.qualifiers, CopySpecifier),
                         MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("d")), MkInitializerAssignment(exp = MkExpConstant("0"))))));
                      exp.destType = Type { kind = intType, refCount = 1 };
                   }
 
                   // r.GetData(fieldCNTid, d);
-                  idGet.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpCall(MkExpMember(MkExpIdentifier(MkIdentifier("r")), MkIdentifier("GetData")), 
+                  idGet.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpCall(MkExpMember(MkExpIdentifier(MkIdentifier("r")), MkIdentifier("GetData")),
                      args = MkList()))));
                   args->Add(MkExpIdentifier(MkIdentifier(fieldID)));
                   /*if(spec.type == nameSpecifier && spec.symbol && spec.symbol.registered && spec.symbol.registered.type == structClass)
@@ -1015,7 +1018,7 @@ static void ProcessDBTable(DBTableDef table)
                   // return d;
                   if(spec.type == nameSpecifier && spec.symbol && spec.symbol.registered && spec.symbol.registered.type == structClass)
                   {
-                     idGet.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier("value")), '=', 
+                     idGet.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier("value")), '=',
                         MkExpIdentifier(MkIdentifier("d"))))));
                   }
                   else
@@ -1023,14 +1026,14 @@ static void ProcessDBTable(DBTableDef table)
 
                   // *** SET ***
                   curContext = idSet.compound.context = Context { parent = globalContext };
-                  
+
                   // RowContacts r { this };
 
-                  idSet.compound.declarations->Add(MkDeclarationInst(MkInstantiation(MkSpecifierName(rowClassName), MkExpIdentifier(MkIdentifier("r")), 
+                  idSet.compound.declarations->Add(MkDeclarationInst(MkInstantiation(MkSpecifierName(rowClassName), MkExpIdentifier(MkIdentifier("r")),
                      MkListOne(MkMembersInitList(MkListOne(MkMemberInit(null, MkInitializerAssignment(MkExpIdentifier(MkIdentifier("this"))))))))));
 
                   // r.SetData(fieldCNTid, value);
-                  idSet.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpCall(MkExpMember(MkExpIdentifier(MkIdentifier("r")), MkIdentifier("SetData")), 
+                  idSet.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpCall(MkExpMember(MkExpIdentifier(MkIdentifier("r")), MkIdentifier("SetData")),
                      args = MkList()))));
                   args->Add(MkExpIdentifier(MkIdentifier(fieldID)));
                   args->Add(MkExpIdentifier(MkIdentifier("value")));
@@ -1039,11 +1042,11 @@ static void ProcessDBTable(DBTableDef table)
                   idSet.compound.statements->Add(MkExpressionStmt(MkListOne(MkExpOp(null, DELETE, MkExpIdentifier(MkIdentifier("r"))))));
 
                   curContext = globalContext;
-                  
+
                   def = MkClassDefProperty(MkProperty(
-                     CopyList(entry.dataType.qualifiers, CopySpecifier), CopyDeclarator(entry.dataType.declarator), 
+                     CopyList(entry.dataType.qualifiers, CopySpecifier), CopyDeclarator(entry.dataType.declarator),
                         CopyIdentifier(entry.id), idSet, idGet));
-                  def.propertyDef.symbol.id = def.propertyDef.symbol.idCode = symbolID;
+                  def.propertyDef.isDBProp = true;
                   def.memberAccess = publicAccess;
                   idClassDefs->Add(def);
                }
@@ -1094,9 +1097,9 @@ static void ProcessDBTable(DBTableDef table)
                      sprintf(num, "%d", c);
                      sprintf(fieldID, "__ecereDBField_%s_%s", tableName, item.id.string);
 
-                     indexStatements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIndex(MkExpIdentifier(MkIdentifier("indexes")), 
+                     indexStatements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIndex(MkExpIdentifier(MkIdentifier("indexes")),
                         MkListOne(MkExpConstant(num))), MkIdentifier("field")),  '=', MkExpIdentifier(MkIdentifier(fieldID))))));
-                     indexStatements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIndex(MkExpIdentifier(MkIdentifier("indexes")), 
+                     indexStatements->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIndex(MkExpIdentifier(MkIdentifier("indexes")),
                         MkListOne(MkExpConstant(num))), MkIdentifier("order")),  '=', MkExpIdentifier(MkIdentifier((item.order == ascending) ? "ascending" : "descending"))))));
                   }
                   sprintf(num, "%d", c);
@@ -1134,10 +1137,10 @@ public void ProcessDBTableDefinitions()
    if(inCompiler)
       PrePreProcessClassDefinitions();
 
-   DeclClass(0, "Field");
-   DeclClass(0, "Table");
-   DeclClass(0, "Row");
-   DeclClass(0, "Id");
+   DeclClass("Field");
+   DeclClass("Table");
+   DeclClass("Row");
+   DeclClass("Id");
    numIndexes = 0;
    if(ast != null)
    {
@@ -1145,7 +1148,6 @@ public void ProcessDBTableDefinitions()
       {
          curExternal = external;
 
-         if(external.symbol) curSymbolID = external.symbol.idCode;
          addAfter = external.prev;
          switch(external.type)
          {
@@ -1159,18 +1161,17 @@ public void ProcessDBTableDefinitions()
       {
          curExternal = external;
 
-         if(external.symbol) curSymbolID = external.symbol.idCode;
          addAfter = external.prev;
 
          switch(external.type)
          {
-            case functionExternal: 
+            case functionExternal:
                ProcessFunction(external.function);
                break;
-            case declarationExternal: 
+            case declarationExternal:
                ProcessDeclaration(external.declaration);
                break;
-            case classExternal: 
+            case classExternal:
                ProcessClass(external._class);
                break;
          }