From 8d10f93625b0b756a8f02203ddc56399e57379de Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Sun, 22 Sep 2013 02:10:14 -0400 Subject: [PATCH] wip -- compiler --- compiler/libec/src/ecdefs.ec | 1 + compiler/libec/src/pass15.ec | 39 ++++++++++++++++++++++++++++++++++++--- compiler/libec/src/pass2.ec | 4 +++- ecere/src/com/BTNode.ec | 1 - 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/compiler/libec/src/ecdefs.ec b/compiler/libec/src/ecdefs.ec index 34456a2..db153e4 100644 --- a/compiler/libec/src/ecdefs.ec +++ b/compiler/libec/src/ecdefs.ec @@ -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) { diff --git a/compiler/libec/src/pass15.ec b/compiler/libec/src/pass15.ec index 60d0b8b..ee7f6e7 100644 --- a/compiler/libec/src/pass15.ec +++ b/compiler/libec/src/pass15.ec @@ -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); diff --git a/compiler/libec/src/pass2.ec b/compiler/libec/src/pass2.ec index c5b58fc..1216e51 100644 --- a/compiler/libec/src/pass2.ec +++ b/compiler/libec/src/pass2.ec @@ -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 diff --git a/ecere/src/com/BTNode.ec b/ecere/src/com/BTNode.ec index abc247a..313c9a3 100644 --- a/ecere/src/com/BTNode.ec +++ b/ecere/src/com/BTNode.ec @@ -697,7 +697,6 @@ public: channel.Unserialize(right); if(right) { right.parent = this; } - // TODO: Precomp errors without extra brackets depth = ((BTNode)(this)).depthProp; } else -- 1.8.3.1