From 54666c99a56885566285199a0604994bdca87f95 Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Wed, 2 Jul 2014 18:08:29 -0400 Subject: [PATCH 1/1] compiler/libec: Fix for thisclass related warnings in Map.ec --- compiler/bootstrap/ecere/bootstrap/Map.c | 4 ++-- compiler/bootstrap/ecp/bootstrap/ecp.c | 1 + compiler/bootstrap/ecs/bootstrap/ecs.c | 1 + compiler/bootstrap/libec/bootstrap/ast.c | 1 + compiler/bootstrap/libec/bootstrap/copy.c | 1 + compiler/bootstrap/libec/bootstrap/dbpass.c | 1 + compiler/bootstrap/libec/bootstrap/ecdefs.c | 2 ++ compiler/bootstrap/libec/bootstrap/firstPass.c | 1 + compiler/bootstrap/libec/bootstrap/freeAst.c | 1 + compiler/bootstrap/libec/bootstrap/output.c | 1 + compiler/bootstrap/libec/bootstrap/pass0.c | 1 + compiler/bootstrap/libec/bootstrap/pass1.c | 1 + compiler/bootstrap/libec/bootstrap/pass15.c | 16 +++++++++++++++- compiler/bootstrap/libec/bootstrap/pass16.c | 1 + compiler/bootstrap/libec/bootstrap/pass2.c | 1 + compiler/bootstrap/libec/bootstrap/pass3.c | 5 +++++ compiler/libec/src/ecdefs.ec | 1 + compiler/libec/src/pass15.ec | 16 +++++++++++++--- compiler/libec/src/pass3.ec | 7 +++++++ 19 files changed, 57 insertions(+), 6 deletions(-) diff --git a/compiler/bootstrap/ecere/bootstrap/Map.c b/compiler/bootstrap/ecere/bootstrap/Map.c index 471b8ce..dbe1e68 100644 --- a/compiler/bootstrap/ecere/bootstrap/Map.c +++ b/compiler/bootstrap/ecere/bootstrap/Map.c @@ -673,7 +673,7 @@ __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpa struct __ecereNameSpace__ecere__com__MapNode * __ecereMethod___ecereNameSpace__ecere__com__Map_GetAtPosition(struct __ecereNameSpace__ecere__com__Instance * this, const uint64 pos, unsigned int create) { -struct __ecereNameSpace__ecere__com__MapNode * node = ((struct __ecereNameSpace__ecere__com__MapNode *)(uintptr_t)((struct __ecereNameSpace__ecere__com__CustomAVLTree *)(((char *)this + 0 + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->root) ? __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Find((void *)(((struct __ecereNameSpace__ecere__com__MapNode *)(uintptr_t)((struct __ecereNameSpace__ecere__com__CustomAVLTree *)(((char *)this + 0 + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->root)), ((struct __ecereNameSpace__ecere__com__Instance *)(char *)this)->_class->templateArgs[5].__anon1.__anon1.dataTypeClass, pos) : (((void *)0)); +struct __ecereNameSpace__ecere__com__MapNode * node = (void *)(((struct __ecereNameSpace__ecere__com__MapNode *)(uintptr_t)((struct __ecereNameSpace__ecere__com__CustomAVLTree *)(((char *)this + 0 + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->root) ? __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Find((void *)(((struct __ecereNameSpace__ecere__com__MapNode *)(uintptr_t)((struct __ecereNameSpace__ecere__com__CustomAVLTree *)(((char *)this + 0 + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->root)), ((struct __ecereNameSpace__ecere__com__Instance *)(char *)this)->_class->templateArgs[5].__anon1.__anon1.dataTypeClass, pos) : (((void *)0))); if(!node && create) { @@ -728,7 +728,7 @@ return newNode; } else { -struct __ecereNameSpace__ecere__com__MapNode * node = ((struct __ecereNameSpace__ecere__com__MapNode *)(uintptr_t)((struct __ecereNameSpace__ecere__com__CustomAVLTree *)(((char *)this + 0 + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->root) ? __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Find((void *)(((struct __ecereNameSpace__ecere__com__MapNode *)(uintptr_t)((struct __ecereNameSpace__ecere__com__CustomAVLTree *)(((char *)this + 0 + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->root)), ((struct __ecereNameSpace__ecere__com__Instance *)(char *)this)->_class->templateArgs[5].__anon1.__anon1.dataTypeClass, (uint64)__ecereProp___ecereNameSpace__ecere__com__MapNode_Get_key(newNode)) : (((void *)0)); +struct __ecereNameSpace__ecere__com__MapNode * node = (void *)(((struct __ecereNameSpace__ecere__com__MapNode *)(uintptr_t)((struct __ecereNameSpace__ecere__com__CustomAVLTree *)(((char *)this + 0 + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->root) ? __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Find((void *)(((struct __ecereNameSpace__ecere__com__MapNode *)(uintptr_t)((struct __ecereNameSpace__ecere__com__CustomAVLTree *)(((char *)this + 0 + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->root)), ((struct __ecereNameSpace__ecere__com__Instance *)(char *)this)->_class->templateArgs[5].__anon1.__anon1.dataTypeClass, (uint64)__ecereProp___ecereNameSpace__ecere__com__MapNode_Get_key(newNode)) : (((void *)0))); if(!node) { diff --git a/compiler/bootstrap/ecp/bootstrap/ecp.c b/compiler/bootstrap/ecp/bootstrap/ecp.c index 1742796..c6701f3 100644 --- a/compiler/bootstrap/ecp/bootstrap/ecp.c +++ b/compiler/bootstrap/ecp/bootstrap/ecp.c @@ -1231,6 +1231,7 @@ int kind; unsigned int size; char * name; char * typeName; +struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int classObjectType; int alignment; unsigned int offset; diff --git a/compiler/bootstrap/ecs/bootstrap/ecs.c b/compiler/bootstrap/ecs/bootstrap/ecs.c index 63b8d19..6cec554 100644 --- a/compiler/bootstrap/ecs/bootstrap/ecs.c +++ b/compiler/bootstrap/ecs/bootstrap/ecs.c @@ -648,6 +648,7 @@ int kind; unsigned int size; char * name; char * typeName; +struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int classObjectType; int alignment; unsigned int offset; diff --git a/compiler/bootstrap/libec/bootstrap/ast.c b/compiler/bootstrap/libec/bootstrap/ast.c index eb8292a..2b18365 100644 --- a/compiler/bootstrap/libec/bootstrap/ast.c +++ b/compiler/bootstrap/libec/bootstrap/ast.c @@ -894,6 +894,7 @@ int kind; unsigned int size; char * name; char * typeName; +struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int classObjectType; int alignment; unsigned int offset; diff --git a/compiler/bootstrap/libec/bootstrap/copy.c b/compiler/bootstrap/libec/bootstrap/copy.c index 8bf2b58..e67caaf 100644 --- a/compiler/bootstrap/libec/bootstrap/copy.c +++ b/compiler/bootstrap/libec/bootstrap/copy.c @@ -672,6 +672,7 @@ int kind; unsigned int size; char * name; char * typeName; +struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int classObjectType; int alignment; unsigned int offset; diff --git a/compiler/bootstrap/libec/bootstrap/dbpass.c b/compiler/bootstrap/libec/bootstrap/dbpass.c index 7684a54..60d119e 100644 --- a/compiler/bootstrap/libec/bootstrap/dbpass.c +++ b/compiler/bootstrap/libec/bootstrap/dbpass.c @@ -747,6 +747,7 @@ int kind; unsigned int size; char * name; char * typeName; +struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int classObjectType; int alignment; unsigned int offset; diff --git a/compiler/bootstrap/libec/bootstrap/ecdefs.c b/compiler/bootstrap/libec/bootstrap/ecdefs.c index cc2b8c9..a06e84c 100644 --- a/compiler/bootstrap/libec/bootstrap/ecdefs.c +++ b/compiler/bootstrap/libec/bootstrap/ecdefs.c @@ -1049,6 +1049,7 @@ int kind; unsigned int size; char * name; char * typeName; +struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int classObjectType; int alignment; unsigned int offset; @@ -3430,6 +3431,7 @@ __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "kind", "TypeKind", 4, __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "size", "uint", 4, 4, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "name", "char *", sizeof(void *), 0xF000F000, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "typeName", "char *", sizeof(void *), 0xF000F000, 1); +__ecereNameSpace__ecere__com__eClass_AddDataMember(class, "thisClassFrom", "ecere::com::Class", sizeof(void *), 0xF000F000, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "classObjectType", "ClassObjectType", 4, 4, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "alignment", "int", 4, 4, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "offset", "uint", 4, 4, 1); diff --git a/compiler/bootstrap/libec/bootstrap/firstPass.c b/compiler/bootstrap/libec/bootstrap/firstPass.c index cca5bcb..bd24ab0 100644 --- a/compiler/bootstrap/libec/bootstrap/firstPass.c +++ b/compiler/bootstrap/libec/bootstrap/firstPass.c @@ -994,6 +994,7 @@ int kind; unsigned int size; char * name; char * typeName; +struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int classObjectType; int alignment; unsigned int offset; diff --git a/compiler/bootstrap/libec/bootstrap/freeAst.c b/compiler/bootstrap/libec/bootstrap/freeAst.c index 61daa22..c2ce274 100644 --- a/compiler/bootstrap/libec/bootstrap/freeAst.c +++ b/compiler/bootstrap/libec/bootstrap/freeAst.c @@ -1190,6 +1190,7 @@ int kind; unsigned int size; char * name; char * typeName; +struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int classObjectType; int alignment; unsigned int offset; diff --git a/compiler/bootstrap/libec/bootstrap/output.c b/compiler/bootstrap/libec/bootstrap/output.c index 14218d8..66bedca 100644 --- a/compiler/bootstrap/libec/bootstrap/output.c +++ b/compiler/bootstrap/libec/bootstrap/output.c @@ -662,6 +662,7 @@ int kind; unsigned int size; char * name; char * typeName; +struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int classObjectType; int alignment; unsigned int offset; diff --git a/compiler/bootstrap/libec/bootstrap/pass0.c b/compiler/bootstrap/libec/bootstrap/pass0.c index 5948705..e02d1ae 100644 --- a/compiler/bootstrap/libec/bootstrap/pass0.c +++ b/compiler/bootstrap/libec/bootstrap/pass0.c @@ -683,6 +683,7 @@ int kind; unsigned int size; char * name; char * typeName; +struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int classObjectType; int alignment; unsigned int offset; diff --git a/compiler/bootstrap/libec/bootstrap/pass1.c b/compiler/bootstrap/libec/bootstrap/pass1.c index 4758c11..d0adc10 100644 --- a/compiler/bootstrap/libec/bootstrap/pass1.c +++ b/compiler/bootstrap/libec/bootstrap/pass1.c @@ -1134,6 +1134,7 @@ int kind; unsigned int size; char * name; char * typeName; +struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int classObjectType; int alignment; unsigned int offset; diff --git a/compiler/bootstrap/libec/bootstrap/pass15.c b/compiler/bootstrap/libec/bootstrap/pass15.c index e402fe2..673703f 100644 --- a/compiler/bootstrap/libec/bootstrap/pass15.c +++ b/compiler/bootstrap/libec/bootstrap/pass15.c @@ -1813,6 +1813,7 @@ int kind; unsigned int size; char * name; char * typeName; +struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int classObjectType; int alignment; unsigned int offset; @@ -16801,6 +16802,19 @@ thisClassParams = 1; functionType = ProcessType(specs, decl); functionType->refCount = 0; FinishTemplatesContext(context); +{ +struct Type * p, * op; + +for(p = functionType->__anon1.__anon2.params.first, op = methodType->__anon1.__anon3.method->dataType->__anon1.__anon2.params.first; p && op; p = p->next, op = op->next) +{ +if(op->kind == 21) +p->thisClassFrom = methodType->__anon1.__anon3.method->_class; +} +} +if(methodType->__anon1.__anon3.method->dataType->__anon1.__anon2.returnType->kind == 21) +{ +functionType->__anon1.__anon2.returnType->thisClassFrom = methodType->__anon1.__anon3.method->_class; +} } FreeList(specs, (void *)(FreeSpecifier)); FreeDeclarator(decl); @@ -17417,7 +17431,7 @@ prop->_class->symbol = FindClass(prop->_class->fullName); exp->__anon1.member.exp->destType = __extension__ ({ struct Type * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Type); -__ecereInstance1->refCount = 1, __ecereInstance1->kind = 8, __ecereInstance1->__anon1._class = prop ? prop->_class->symbol : method ? method->_class->symbol : _class->symbol, __ecereInstance1; +__ecereInstance1->refCount = 1, __ecereInstance1->kind = 8, __ecereInstance1->__anon1._class = prop ? prop->_class->symbol : method ? method->_class->symbol : _class->symbol, __ecereInstance1->thisClassFrom = type ? type->thisClassFrom : (((void *)0)), __ecereInstance1; }); } if(prop) diff --git a/compiler/bootstrap/libec/bootstrap/pass16.c b/compiler/bootstrap/libec/bootstrap/pass16.c index d22c442..9dcf5e3 100644 --- a/compiler/bootstrap/libec/bootstrap/pass16.c +++ b/compiler/bootstrap/libec/bootstrap/pass16.c @@ -656,6 +656,7 @@ int kind; unsigned int size; char * name; char * typeName; +struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int classObjectType; int alignment; unsigned int offset; diff --git a/compiler/bootstrap/libec/bootstrap/pass2.c b/compiler/bootstrap/libec/bootstrap/pass2.c index 393ee95..0f0c610 100644 --- a/compiler/bootstrap/libec/bootstrap/pass2.c +++ b/compiler/bootstrap/libec/bootstrap/pass2.c @@ -998,6 +998,7 @@ int kind; unsigned int size; char * name; char * typeName; +struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int classObjectType; int alignment; unsigned int offset; diff --git a/compiler/bootstrap/libec/bootstrap/pass3.c b/compiler/bootstrap/libec/bootstrap/pass3.c index e4190c0..c43efd6 100644 --- a/compiler/bootstrap/libec/bootstrap/pass3.c +++ b/compiler/bootstrap/libec/bootstrap/pass3.c @@ -680,6 +680,7 @@ int kind; unsigned int size; char * name; char * typeName; +struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int classObjectType; int alignment; unsigned int offset; @@ -1639,6 +1640,8 @@ if(src && src->kind == 8 && src->__anon1._class) { struct __ecereNameSpace__ecere__com__Class * sc = src->__anon1._class->__anon1.registered; +if(src->thisClassFrom) +sc = src->thisClassFrom; if(sc && (sc->type == 1 || sc->type == 5)) { struct Type * dest = e->destType; @@ -1665,6 +1668,8 @@ if(!dest->passAsTemplate && dest->kind == 8 && dest->__anon1._class && dest->__a { struct __ecereNameSpace__ecere__com__Class * dc = dest->__anon1._class->__anon1.registered; +if(dest->thisClassFrom) +dc = dest->thisClassFrom; if(sc->templateClass) sc = sc->templateClass; if(dc->templateClass) diff --git a/compiler/libec/src/ecdefs.ec b/compiler/libec/src/ecdefs.ec index 33148eb..595a121 100644 --- a/compiler/libec/src/ecdefs.ec +++ b/compiler/libec/src/ecdefs.ec @@ -1406,6 +1406,7 @@ public: uint size; char * name; char * typeName; + Class thisClassFrom; ClassObjectType classObjectType; int alignment; diff --git a/compiler/libec/src/pass15.ec b/compiler/libec/src/pass15.ec index a9164fc..6fff8f6 100644 --- a/compiler/libec/src/pass15.ec +++ b/compiler/libec/src/pass15.ec @@ -9470,11 +9470,20 @@ void ProcessExpressionType(Expression exp) FinishTemplatesContext(context); // Mark parameters that were 'thisclass' - /*{ + { Type p, op; for(p = functionType.params.first, op = methodType.method.dataType.params.first; p && op; p = p.next, op = op.next) - p.wasThisClass = op.kind == thisClassType; - }*/ + { + //p.wasThisClass = op.kind == thisClassType; + if(op.kind == thisClassType) + p.thisClassFrom = methodType.method._class; + } + } + if(methodType.method.dataType.returnType.kind == thisClassType) + { + // functionType.returnType.wasThisClass = true; + functionType.returnType.thisClassFrom = methodType.method._class; + } } FreeList(specs, FreeSpecifier); @@ -10170,6 +10179,7 @@ void ProcessExpressionType(Expression exp) kind = classType; _class = prop ? prop._class.symbol : method ? method._class.symbol : _class.symbol; // wasThisClass = type ? type.wasThisClass : false; + thisClassFrom = type ? type.thisClassFrom : null; }; } diff --git a/compiler/libec/src/pass3.ec b/compiler/libec/src/pass3.ec index 8fe0348..1308387 100644 --- a/compiler/libec/src/pass3.ec +++ b/compiler/libec/src/pass3.ec @@ -473,9 +473,13 @@ static void AddPointerCast(Expression e) if(src && src.kind == classType && src._class) { Class sc = src._class.registered; + if(src.thisClassFrom) + sc = src.thisClassFrom; + if(sc && (sc.type == structClass || sc.type == noHeadClass)) { Type dest = e.destType; + if(dest && (dest.kind == templateType || dest.kind == classType)) { if(dest) dest.refCount++; @@ -496,6 +500,9 @@ static void AddPointerCast(Expression e) if(!dest.passAsTemplate && dest.kind == classType && dest._class && dest._class.registered) { Class dc = dest._class.registered; + if(dest.thisClassFrom) + dc = dest.thisClassFrom; + if(sc.templateClass) sc = sc.templateClass; if(dc.templateClass) dc = dc.templateClass; if(dc.base && sc != dc) -- 1.8.3.1