wip -- compiler
authorJerome St-Louis <jerome@ecere.com>
Sun, 22 Sep 2013 06:10:14 +0000 (02:10 -0400)
committerJerome St-Louis <jerome@ecere.com>
Sun, 29 Sep 2013 00:02:18 +0000 (20:02 -0400)
compiler/libec/src/ecdefs.ec
compiler/libec/src/pass15.ec
compiler/libec/src/pass2.ec
ecere/src/com/BTNode.ec

index 34456a2..db153e4 100644 (file)
@@ -1170,6 +1170,7 @@ public:
    bool dllExport:1;
    bool attrStdcall:1;
    bool declaredWithStruct:1;
+   bool typedByReference:1;      // Originally typed by reference, regardless of class type
 
    char * OnGetString(char * tempString, void * fieldData, bool * needClass)
    {
index 60d0b8b..ee7f6e7 100644 (file)
@@ -6897,7 +6897,11 @@ void ReplaceExpContents(Expression checkedExp, Expression newExp)
 
 void ApplyAnyObjectLogic(Expression e)
 {
+   char debugExpString[4096];
    Type destType = /*(e.destType && e.destType.kind == ellipsisType) ? ellipsisDestType : */e.destType;
+   debugExpString[0] = '\0';
+   PrintExpression(e, debugExpString);
+
    if(destType && (/*destType.classObjectType == ClassObjectType::typedObject || */destType.classObjectType == anyObject))
    {
       //if(e.destType && e.destType.kind == ellipsisType) usedEllipsis = true;
@@ -7184,6 +7188,11 @@ void ApplyAnyObjectLogic(Expression e)
             e.op.op = '*';
             e.op.exp1 = null;
             e.op.exp2 = MkExpCast(MkTypeName(specs, MkDeclaratorPointer(MkPointer(null, null), decl)), thisExp);
+
+            /*e.expType = { };
+            CopyTypeInto(e.expType, type);
+            e.expType.byReference = false;
+            e.expType.refCount = 1;*/
          }
          else
          {
@@ -7191,11 +7200,13 @@ void ApplyAnyObjectLogic(Expression e)
             e.cast.typeName = MkTypeName(specs, decl);
             e.cast.exp = thisExp;
             e.byReference = true;
+            /*e.expType = type;
+            type.refCount++;*/
          }
-         e.expType = type;
          e.destType = destType;
-         type.refCount++;
          destType.refCount++;
+         e.expType = type;
+         type.refCount++;
       }
    }
 }
@@ -8937,6 +8948,15 @@ void ProcessExpressionType(Expression exp)
                if(type && type.kind != ellipsisType)
                {
                   Type next = type.next;
+                  // Allow manually passing a class for typed object
+                  /*
+                  if(type.kind == classType && type.classObjectType == typedObject && e && !e.prev)
+                  {
+                     ProcessExpressionType(e);
+                     if(e.expType && (e.expType.kind == subClassType || (e.expType.kind == classType && e.expType._class && e.expType._class.registered && 
+                        eClass_IsDerived(e.expType._class.registered, eSystem_FindClass(privateModule, "ecere::com::Class")))))
+                        next = type;
+                  }*/
                   if(!type.refCount) FreeType(type);
                   type = next;
                }
@@ -9033,7 +9053,19 @@ void ProcessExpressionType(Expression exp)
       {
          Type type;
          Location oldyylloc = yylloc;
-         bool thisPtr = (exp.member.exp && exp.member.exp.type == identifierExp && !strcmp(exp.member.exp.identifier.string, "this"));
+         bool thisPtr = (exp.member.exp && exp.member.exp.type == identifierExp && !strcmp(exp.member.exp.identifier.string, "this");
+         Expression checkExp = exp.member.exp;
+         /*while(checkExp)
+         {
+            if(checkExp.type == castExp)
+               checkExp = checkExp.cast.exp;
+            else if(checkExp.type == bracketsExp)
+               checkExp = checkExp.list ? checkExp.list->first : null;
+            else
+               break;
+         }
+
+         thisPtr = (checkExp && checkExp.type == identifierExp && !strcmp(checkExp.identifier.string, "this"));*/
          exp.thisPtr = thisPtr;
 
          // DOING THIS LATER NOW...
@@ -11908,6 +11940,7 @@ static void ProcessFunction(FunctionDefinition function)
             {
                thisSymbol.type.classObjectType = ClassObjectType::typedObject;
                thisSymbol.type.byReference = type.byReference;
+               thisSymbol.type.typedByReference = type.byReference;
                /*
                thisSymbol = Symbol { string = CopyString("class") };
                function.body.compound.context.symbols.Add(thisSymbol);
index c5b58fc..1216e51 100644 (file)
@@ -2599,13 +2599,15 @@ static void ProcessExpression(Expression exp)
                else
                {
                   // If it's a this pointer, replace by precomputed shortcut
+                  //if(thisPtr && (!exp.member.exp.expType || !exp.member.exp.expType.typedByReference))
                   if(thisPtr)
                   {
                      char pointerName[1024];
 
                      strcpy(pointerName, "__ecerePointer_");
                      FullClassNameCat(pointerName, type._class.registered.fullName, false);
-                     FreeIdentifier(exp.member.exp.identifier);
+                     if(exp.member.exp.identifier)
+                        FreeIdentifier(exp.member.exp.identifier);
                      exp.member.exp.identifier = MkIdentifier(pointerName);
                   }
                   // Otherwise, access the data the hard way
index abc247a..313c9a3 100644 (file)
@@ -697,7 +697,6 @@ public:
          channel.Unserialize(right);
          if(right) { right.parent = this; }
 
-         // TODO: Precomp errors without extra brackets
          depth = ((BTNode)(this)).depthProp;
       }
       else