wip II
[sdk] / compiler / bootstrap / libec / bootstrap / pass15.c
index adb3cf9..451d813 100644 (file)
@@ -1,3 +1,4 @@
+/* Code generated from eC source file: pass15.ec */
 #if defined(__GNUC__)
 typedef long long int64;
 typedef unsigned long long uint64;
@@ -128,7 +129,7 @@ struct CodePosition
 int line;
 int charPos;
 int pos;
-unsigned int included;
+int included;
 } __attribute__ ((gcc_struct));
 
 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Location;
@@ -801,6 +802,8 @@ unsigned int keepCast : 1;
 unsigned int passAsTemplate : 1;
 unsigned int dllExport : 1;
 unsigned int attrStdcall : 1;
+unsigned int declaredWithStruct : 1;
+unsigned int typedByReference : 1;
 } __attribute__ ((gcc_struct));
 
 extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Class;
@@ -859,6 +862,8 @@ struct __ecereNameSpace__ecere__com__ClassTemplateArgument *  templateArgs;
 struct __ecereNameSpace__ecere__com__Class * templateClass;
 struct __ecereNameSpace__ecere__sys__OldList templatized;
 int numParams;
+unsigned int isInstanceClass;
+unsigned int byValueSystemClass;
 } __attribute__ ((gcc_struct));
 
 extern long long __ecereNameSpace__ecere__com__eClass_GetProperty(struct __ecereNameSpace__ecere__com__Class * _class, char *  name);
@@ -4679,7 +4684,7 @@ else if(source->_class && dest->_class && (dest->classObjectType == source->clas
 return 0x1;
 else
 {
-if(enumBaseType && dest->_class && dest->_class->registered && dest->_class->registered->type == 4 && source->_class && source->_class->registered && source->_class->registered->type != 4)
+if(enumBaseType && dest->_class && dest->_class->registered && dest->_class->registered->type == 4 && ((source->_class && source->_class->registered && source->_class->registered->type != 4) || source->kind == 8))
 {
 if(__ecereNameSpace__ecere__com__eClass_IsDerived(dest->_class->registered, source->_class->registered))
 {
@@ -6069,7 +6074,7 @@ static unsigned int FloatDiv(struct Expression * exp, struct Operand * op1, stru
 float value2 = op2->f;
 
 exp->type = 2;
-exp->string = PrintFloat(value2 ? (op1->f / value2) : (float)0);
+exp->string = PrintFloat(value2 ? (op1->f / value2) : 0);
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6084,7 +6089,7 @@ static unsigned int DoubleDiv(struct Expression * exp, struct Operand * op1, str
 double value2 = op2->d;
 
 exp->type = 2;
-exp->string = PrintDouble(value2 ? (op1->d / value2) : (double)0);
+exp->string = PrintDouble(value2 ? (op1->d / value2) : 0);
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6187,7 +6192,7 @@ return 0x1;
 static unsigned int IntNeg(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintInt(-op1->i);
+exp->string = PrintInt((-op1->i));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6200,7 +6205,7 @@ return 0x1;
 static unsigned int UIntNeg(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintUInt(-op1->ui);
+exp->string = PrintUInt((unsigned int)(-op1->ui));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6213,7 +6218,7 @@ return 0x1;
 static unsigned int ShortNeg(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintShort(-op1->s);
+exp->string = PrintShort((-op1->s));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6226,7 +6231,7 @@ return 0x1;
 static unsigned int UShortNeg(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintUShort(-op1->us);
+exp->string = PrintUShort((unsigned short)(-op1->us));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6239,7 +6244,7 @@ return 0x1;
 static unsigned int CharNeg(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintChar(-op1->c);
+exp->string = PrintChar((-op1->c));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6252,7 +6257,7 @@ return 0x1;
 static unsigned int UCharNeg(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintUChar(-op1->uc);
+exp->string = PrintUChar((unsigned char)(-op1->uc));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6265,7 +6270,7 @@ return 0x1;
 static unsigned int FloatNeg(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintFloat(-op1->f);
+exp->string = PrintFloat((float)(-op1->f));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6278,7 +6283,7 @@ return 0x1;
 static unsigned int DoubleNeg(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintDouble(-op1->d);
+exp->string = PrintDouble((double)(-op1->d));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6291,7 +6296,7 @@ return 0x1;
 static unsigned int IntInc(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintInt(++op1->i);
+exp->string = PrintInt((++op1->i));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6304,7 +6309,7 @@ return 0x1;
 static unsigned int UIntInc(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintUInt(++op1->ui);
+exp->string = PrintUInt((++op1->ui));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6317,7 +6322,7 @@ return 0x1;
 static unsigned int ShortInc(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintShort(++op1->s);
+exp->string = PrintShort((++op1->s));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6330,7 +6335,7 @@ return 0x1;
 static unsigned int UShortInc(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintUShort(++op1->us);
+exp->string = PrintUShort((++op1->us));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6343,7 +6348,7 @@ return 0x1;
 static unsigned int CharInc(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintChar(++op1->c);
+exp->string = PrintChar((++op1->c));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6356,7 +6361,7 @@ return 0x1;
 static unsigned int UCharInc(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintUChar(++op1->uc);
+exp->string = PrintUChar((++op1->uc));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6369,7 +6374,7 @@ return 0x1;
 static unsigned int FloatInc(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintFloat(++op1->f);
+exp->string = PrintFloat((float)(++op1->f));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6382,7 +6387,7 @@ return 0x1;
 static unsigned int DoubleInc(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintDouble(++op1->d);
+exp->string = PrintDouble((double)(++op1->d));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6395,7 +6400,7 @@ return 0x1;
 static unsigned int IntDec(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintInt(--op1->i);
+exp->string = PrintInt((--op1->i));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6408,7 +6413,7 @@ return 0x1;
 static unsigned int UIntDec(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintUInt(--op1->ui);
+exp->string = PrintUInt((--op1->ui));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6421,7 +6426,7 @@ return 0x1;
 static unsigned int ShortDec(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintShort(--op1->s);
+exp->string = PrintShort((--op1->s));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6434,7 +6439,7 @@ return 0x1;
 static unsigned int UShortDec(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintUShort(--op1->us);
+exp->string = PrintUShort((--op1->us));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6447,7 +6452,7 @@ return 0x1;
 static unsigned int CharDec(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintChar(--op1->c);
+exp->string = PrintChar((--op1->c));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6460,7 +6465,7 @@ return 0x1;
 static unsigned int UCharDec(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintUChar(--op1->uc);
+exp->string = PrintUChar((--op1->uc));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6473,7 +6478,7 @@ return 0x1;
 static unsigned int FloatDec(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintFloat(--op1->f);
+exp->string = PrintFloat((float)(--op1->f));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -6486,7 +6491,7 @@ return 0x1;
 static unsigned int DoubleDec(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintDouble(--op1->d);
+exp->string = PrintDouble((double)(--op1->d));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -7071,7 +7076,7 @@ static unsigned int FloatDivAsign(struct Expression * exp, struct Operand * op1,
 float value2 = op2->f;
 
 exp->type = 2;
-exp->string = PrintFloat(value2 ? (op1->f /= value2) : (float)0);
+exp->string = PrintFloat(value2 ? (op1->f /= value2) : 0);
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -7086,7 +7091,7 @@ static unsigned int DoubleDivAsign(struct Expression * exp, struct Operand * op1
 double value2 = op2->d;
 
 exp->type = 2;
-exp->string = PrintDouble(value2 ? (op1->d /= value2) : (double)0);
+exp->string = PrintDouble(value2 ? (op1->d /= value2) : 0);
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -7639,7 +7644,7 @@ return 0x1;
 static unsigned int IntBitNot(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintInt(~op1->i);
+exp->string = PrintInt((~op1->i));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -7652,7 +7657,7 @@ return 0x1;
 static unsigned int UIntBitNot(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintUInt(~op1->ui);
+exp->string = PrintUInt((unsigned int)(~op1->ui));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -7665,7 +7670,7 @@ return 0x1;
 static unsigned int ShortBitNot(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintShort(~op1->s);
+exp->string = PrintShort((short)(~op1->s));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -7678,7 +7683,7 @@ return 0x1;
 static unsigned int UShortBitNot(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintUShort(~op1->us);
+exp->string = PrintUShort((unsigned short)(~op1->us));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -7691,7 +7696,7 @@ return 0x1;
 static unsigned int CharBitNot(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintChar(~op1->c);
+exp->string = PrintChar((char)(~op1->c));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -7704,7 +7709,7 @@ return 0x1;
 static unsigned int UCharBitNot(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintUChar(~op1->uc);
+exp->string = PrintUChar((unsigned char)(~op1->uc));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -8167,7 +8172,7 @@ return 0x1;
 static unsigned int IntNot(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintInt(!op1->i);
+exp->string = PrintInt((int)(!op1->i));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -8180,7 +8185,7 @@ return 0x1;
 static unsigned int UIntNot(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintUInt(!op1->ui);
+exp->string = PrintUInt((unsigned int)(!op1->ui));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -8193,7 +8198,7 @@ return 0x1;
 static unsigned int ShortNot(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintShort(!op1->s);
+exp->string = PrintShort((short)(!op1->s));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -8206,7 +8211,7 @@ return 0x1;
 static unsigned int UShortNot(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintUShort(!op1->us);
+exp->string = PrintUShort((unsigned short)(!op1->us));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -8219,7 +8224,7 @@ return 0x1;
 static unsigned int CharNot(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintChar(!op1->c);
+exp->string = PrintChar((char)(!op1->c));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -8232,7 +8237,7 @@ return 0x1;
 static unsigned int UCharNot(struct Expression * exp, struct Operand * op1)
 {
 exp->type = 2;
-exp->string = PrintUChar(!op1->uc);
+exp->string = PrintUChar((unsigned char)(!op1->uc));
 if(!exp->expType)
 {
 exp->expType = op1->type;
@@ -9841,6 +9846,8 @@ else
 {
 dataMember = curMember;
 __ecereNameSpace__ecere__com__eClass_FindDataMemberAndOffset(_class, dataMember->name, &dataMemberOffset, privateModule, (((void *)0)), (((void *)0)));
+if(_class->type == 0)
+dataMemberOffset += _class->base->structSize;
 }
 found = 0x1;
 }
@@ -10848,6 +10855,7 @@ char className[1024];
 strcpy(className, "__ecereClass_");
 FullClassNameCat(className, classSym->string, 0x1);
 MangleClassName(className);
+DeclareClass(classSym, className);
 FreeExpContents(exp);
 exp->type = 9;
 exp->member.exp = MkExpIdentifier(MkIdentifier(className));
@@ -12275,6 +12283,10 @@ e->type = 4;
 e->op.op = '*';
 e->op.exp1 = (((void *)0));
 e->op.exp2 = MkExpCast(MkTypeName(specs, MkDeclaratorPointer(MkPointer((((void *)0)), (((void *)0))), decl)), thisExp);
+e->expType = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Type);
+CopyTypeInto(e->expType, type);
+e->expType->byReference = 0x0;
+e->expType->refCount = 1;
 }
 else
 {
@@ -12282,10 +12294,10 @@ e->type = 11;
 e->cast.typeName = MkTypeName(specs, decl);
 e->cast.exp = thisExp;
 e->byReference = 0x1;
-}
 e->expType = type;
-e->destType = destType;
 type->refCount++;
+}
+e->destType = destType;
 destType->refCount++;
 }
 }
@@ -12422,7 +12434,7 @@ if(type && (type->kind == 15 || (_class && _class->type == 4)))
 exp->isConstant = 0x1;
 if(symbol->isParam || !strcmp(id->string, "this"))
 {
-if(_class && _class->type == 1)
+if(_class && _class->type == 1 && !type->declaredWithStruct)
 exp->byReference = 0x1;
 }
 if(symbol->isIterator)
@@ -12644,6 +12656,12 @@ type->isSigned = 0x1;
 type->kind = 3;
 }
 exp->isConstant = 0x1;
+if(exp->destType && exp->destType->kind == 7)
+type->kind = 7;
+else if(exp->destType && exp->destType->kind == 6)
+type->kind = 6;
+else if(exp->destType && exp->destType->kind == 4)
+type->kind = 4;
 }
 break;
 }
@@ -12906,6 +12924,24 @@ if(exp->op.exp2->destType == dummy)
 FreeType(dummy);
 exp->op.exp2->destType = (((void *)0));
 }
+if(exp->op.op == '-' && !exp->op.exp1 && exp->op.exp2->expType && !exp->op.exp2->expType->isSigned)
+{
+type2 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Type);
+type2->refCount = 1;
+CopyTypeInto(type2, exp->op.exp2->expType);
+type2->isSigned = 0x1;
+}
+else if(exp->op.op == '~' && !exp->op.exp1 && exp->op.exp2->expType && (!exp->op.exp2->expType->isSigned || exp->op.exp2->expType->kind != 3))
+{
+type2 = __extension__ ({
+struct Type * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Type);
+
+__ecereInstance1->kind = 3, __ecereInstance1;
+});
+type2->refCount = 1;
+type2->isSigned = 0x1;
+}
+else
 type2 = exp->op.exp2->expType;
 }
 dummy->kind = 0;
@@ -13416,10 +13452,13 @@ if(exp->index.exp->expType)
 {
 struct Type * source = exp->index.exp->expType;
 
-if(source->kind == 8 && source->_class && source->_class->registered && source->_class->registered != containerClass && __ecereNameSpace__ecere__com__eClass_IsDerived(source->_class->registered, containerClass) && source->_class->registered->templateArgs)
+if(source->kind == 8 && source->_class && source->_class->registered)
 {
 struct __ecereNameSpace__ecere__com__Class * _class = source->_class->registered;
+struct __ecereNameSpace__ecere__com__Class * c = _class->templateClass ? _class->templateClass : _class;
 
+if(_class != containerClass && __ecereNameSpace__ecere__com__eClass_IsDerived(c, containerClass) && _class->templateArgs)
+{
 exp->expType = ProcessTypeString(_class->templateArgs[2].dataTypeString, 0x0);
 if(exp->index.index && (*exp->index.index).last)
 {
@@ -13427,6 +13466,7 @@ if(exp->index.index && (*exp->index.index).last)
 }
 }
 }
+}
 for(e = (*exp->index.index).first; e; e = e->next)
 {
 if(!e->next && exp->index.exp->expType && exp->index.exp->expType->kind == 12 && exp->index.exp->expType->enumClass)
@@ -13672,7 +13712,7 @@ if(functionType->extraParam && e && functionType->thisClass)
 e->destType = MkClassType(functionType->thisClass->string);
 e = e->next;
 }
-if(!functionType->staticMethod)
+if(!functionType->staticMethod && !functionType->extraParam)
 {
 if(memberExp && memberExp->member.exp && memberExp->member.exp->expType && memberExp->member.exp->expType->kind == 19 && memberExp->member.exp->expType->_class)
 {
@@ -13689,8 +13729,12 @@ type->refCount = 0;
 else if(!memberExp && (functionType->thisClass || (methodType && methodType->methodClass)))
 {
 type = MkClassType(functionType->thisClass ? functionType->thisClass->string : (methodType ? methodType->methodClass->fullName : (((void *)0))));
+type->byReference = functionType->byReference;
+type->typedByReference = functionType->typedByReference;
 if(e)
 {
+if(type->kind == 8 && (functionType && functionType->thisClass) && functionType->classObjectType == 2)
+e = e->next;
 e->destType = type;
 e = e->next;
 type = functionType->params.first;
@@ -13885,8 +13929,19 @@ case 8:
 {
 struct Type * type;
 struct Location oldyylloc = yylloc;
-unsigned int thisPtr = (exp->member.exp && exp->member.exp->type == 0 && !strcmp(exp->member.exp->identifier->string, "this"));
+unsigned int thisPtr;
+struct Expression * checkExp = exp->member.exp;
 
+while(checkExp)
+{
+if(checkExp->type == 11)
+checkExp = checkExp->cast.exp;
+else if(checkExp->type == 5)
+checkExp = checkExp->list ? (*checkExp->list).first : (((void *)0));
+else
+break;
+}
+thisPtr = (checkExp && checkExp->type == 0 && !strcmp(checkExp->identifier->string, "this"));
 exp->thisPtr = thisPtr;
 if(exp->member.member && exp->member.member->_class && exp->member.member->_class->name)
 {
@@ -16449,6 +16504,7 @@ if(typedObject && thisSymbol->type)
 {
 thisSymbol->type->classObjectType = 2;
 thisSymbol->type->byReference = type->byReference;
+thisSymbol->type->typedByReference = type->byReference;
 }
 }
 }