strcat(name, "_");
strcat(name, method.name);
- DeclareMethod(method, name);
+ DeclareMethod(curExternal, method, name);
// Cast function to its type
decl = SpecDeclFromString(method.dataTypeString, specs, MkDeclaratorBrackets(MkDeclaratorPointer(MkPointer(null, null), null)));
// Need the class itself here...
strcpy(className, "__ecereClass_");
FullClassNameCat(className, _class.fullName, true);
- //MangleClassName(className);
if(!_class.symbol)
_class.symbol = FindClass(_class.fullName);
- DeclareClass(_class.symbol, className);
+ DeclareClass(curExternal, _class.symbol, className);
if(exp.identifier)
FreeIdentifier(exp.identifier);
exp.identifier._class = null;
exp.identifier.string = CopyString(name);
- DeclareMethod(method, name);
+ DeclareMethod(curExternal, method, name);
}
}
/*
switch(exp.type)
{
- case newExp: exp.call.exp = QMkExpId("ecere::com::eSystem_New"); break;
- case new0Exp: exp.call.exp = QMkExpId("ecere::com::eSystem_New0"); break;
- case renewExp: exp.call.exp = QMkExpId("ecere::com::eSystem_Renew"); break;
- case renew0Exp:exp.call.exp = QMkExpId("ecere::com::eSystem_Renew0"); break;
+ case newExp: exp.call.exp = QMkExpId("ecere::com::eSystem_New"); DeclareFunctionUtil(curExternal, "eSystem_New"); break;
+ case new0Exp: exp.call.exp = QMkExpId("ecere::com::eSystem_New0"); DeclareFunctionUtil(curExternal, "eSystem_New0"); break;
+ case renewExp: exp.call.exp = QMkExpId("ecere::com::eSystem_Renew"); DeclareFunctionUtil(curExternal, "eSystem_Renew"); break;
+ case renew0Exp:exp.call.exp = QMkExpId("ecere::com::eSystem_Renew0"); DeclareFunctionUtil(curExternal, "eSystem_Renew0"); break;
}
exp.call.arguments = args;
exp.type = callExp;
}
if(lastProperty && lastProperty.Get && lastProperty.Set)
{
- DeclareProperty(lastProperty, setName, getName);
+ DeclareProperty(curExternal, lastProperty, setName, getName);
// propertyClass = convertTo ? _class : ((Symbol)lastProperty.symbol)._class;
propertyClass = convertTo ? _class :
((((Symbol)lastProperty.symbol).type &&
Class c = memberExp.index.exp.expType._class.registered;
if(strcmp((c.templateClass ? c.templateClass : c).name, "Array"))
{
- exp.op.exp2 = MkExpBrackets(MkListOne(MkExpCast(MkTypeName(MkListOne(MkSpecifierName("uint64")), null), MkExpBrackets(MkListOne(exp.op.exp2)))));
+ if(exp.op.exp2 && exp.op.op == '=')
+ {
+ modifyPassAsTemplate(&exp.op.exp2.destType, true);
+ CheckTemplateTypes(exp.op.exp2);
+ }
isIndexedContainerAssignment = true;
}
ListAdd(exp.call.arguments, MkExpString(s));
delete s;
}
+ if(value.expType.isPointerType)
+ value = MkExpCast(MkTypeName(MkListOne(MkSpecifierName("intptr")), null), value);
ListAdd(exp.call.arguments, MkExpCast(MkTypeName(MkListOne(MkSpecifier(INT64)), null), value));
FreeIdentifier(id);
value.expType = memberExp.expType;
memberExp.expType.refCount++;
value.usage.usageArg = true;
+
+ if(isIndexedContainerAssignment)
+ {
+ value.op.exp1.usage.usageGet = true;
+ value.op.exp2.usage.usageGet = true;
+ modifyPassAsTemplate(&value.op.exp1.destType, false);
+ modifyPassAsTemplate(&value.op.exp2.destType, false);
+ CheckTemplateTypes(value.op.exp1);
+ CheckTemplateTypes(value.op.exp2);
+
+ modifyPassAsTemplate(&value.expType, false);
+ value.destType = value.expType;
+ value.expType.refCount++;
+ modifyPassAsTemplate(&value.destType, true);
+ CheckTemplateTypes(value);
+ }
}
else if(value)
{
if(value)
value.usage.usageArg = true;
- DeclareProperty(prop, setName, getName);
+ DeclareProperty(curExternal, prop, setName, getName);
if(memberExp.member.exp)
+ {
ProcessExpression(memberExp.member.exp);
+ CheckTemplateTypes(memberExp.member.exp);
+ }
// If get flag present
if(exp.usage.usageGet &&
strcpy(className, "__ecereClass_");
FullClassNameCat(className, exp.expType._class.string, true);
- //MangleClassName(className);
DeclareClass(exp.expType._class, className);
OldList * list = MkList();
Class _class;
+ Statement stmt;
Expression o;
+ Statement compound = MkCompoundStmt(MkListOne(MkDeclaration(MkListOne(MkSpecifier(VOID)), MkListOne(MkInitDeclarator(MkDeclaratorPointer(MkPointer(null, null), MkDeclaratorIdentifier(MkIdentifier("__ecerePtrToDelete"))),
+ MkInitializerAssignment(MkExpBrackets(args)))))), MkListOne(stmt = MkExpressionStmt(list)));
+ Expression stmtExp = MkExpExtensionCompound(compound);
for(_class = exp.expType._class.registered; _class && _class.type == noHeadClass; _class = _class.base)
{
char className[1024];
if(_class.templateClass) _class = _class.templateClass;
strcpy(className, "__ecereClass_");
FullClassNameCat(className, _class.fullName, false /*true*/);
- //MangleClassName(className);
if(!_class.symbol)
_class.symbol = FindClass(_class.fullName);
- DeclareClass(_class.symbol, className);
+ DeclareClass(curExternal, _class.symbol, className);
// Call the non virtual destructor
ListAdd(list,
QMkExpId(className),
MkIdentifier("Destructor")
),
- MkListOne(MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), QMkPtrDecl(null)), CopyExpression(args->first)))
+ MkListOne(MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), QMkPtrDecl(null)), MkExpIdentifier(MkIdentifier("__ecerePtrToDelete")) /*CopyExpression(args->first)*/))
)
),
MkExpConstant("0")
)
);
}
- ListAdd(list, MkExpCall(QMkExpId("ecere::com::eSystem_Delete"), args));
+ ListAdd(list, MkExpCall(QMkExpId("ecere::com::eSystem_Delete"), MkListOne(MkExpIdentifier(MkIdentifier("__ecerePtrToDelete"))) /*args*/));
+ DeclareFunctionUtil(curExternal, "eSystem_Delete");
o = CopyExpression(object);
ProcessExpressionType(o);
o.usage.usageGet = true;
MkExpCondition(
o,
MkListOne(
- MkExpBrackets(list)
+ //MkExpBrackets(list)
+ stmtExp
),
MkExpConstant("0")
)
ProcessExpressionType(classExp);
ProcessExpression(classExp);
args->Insert(null, CopyExpression(classExp));
- DeclareMethod(eClass_FindMethod(eSystem_FindClass(privateModule, "class"), "OnFree", privateModule), "__ecereVMethodID_class_OnFree");
+ DeclareMethod(curExternal, eClass_FindMethod(eSystem_FindClass(privateModule, "class"), "OnFree", privateModule), "__ecereVMethodID_class_OnFree");
ListAdd(exp.list, MkExpCall(
MkExpBrackets(MkListOne(MkExpCast(typeName,
MkExpIndex(MkExpPointer(classExp, MkIdentifier("_vTbl")),
}
}
else
+ {
ListAdd(exp.list, MkExpCall(QMkExpId("ecere::com::eSystem_Delete"), args));
+ DeclareFunctionUtil(curExternal, "eSystem_Delete");
+ }
//ProcessExpression(object);
derefExp.index.exp = null;
FreeExpression(derefExp);
+ // BOOSTRAP FIX
derefExp = MkExpOp(MkExpCast(MkTypeName(MkListOne(MkSpecifier(CHAR)), MkDeclaratorPointer(MkPointer(null, null), null)), indexExp), '+',
MkExpBrackets(MkListOne(MkExpOp(MkExpBrackets(indexExpIndex), '*', MkExpBrackets(MkListOne(CopyExpression(sizeExp)))))));
}
ProcessExpressionType(args->last);
ProcessExpression(args->last);
- DeclareFunctionUtil("memcpy");
+ DeclareFunctionUtil(curExternal, "memcpy");
exp.list = MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("memcpy")), args));
exp.type = bracketsExp;
MkExpBrackets(MkListOne(MkExpCondition(MkExpBrackets(MkListOne(MkExpOp(MkExpMember(CopyExpression(classExp), MkIdentifier("type")), EQ_OP, MkExpIdentifier(MkIdentifier("structClass"))))),
// array
MkListOne(
- MkExpBrackets(MkListOne(MkExpCast(MkTypeName(MkListOne(MkSpecifierName("uint64")), null), CopyExpression(exp.op.exp2))))),
+ MkExpBrackets(MkListOne(MkExpCast(MkTypeName(MkListOne(MkSpecifierName("uint64")), null), MkExpCast(MkTypeName(MkListOne(MkSpecifierName("uintptr")), null), CopyExpression(exp.op.exp2)))))),
// ((class.size == 1) ?
MkExpBrackets(MkListOne(MkExpCondition(MkExpBrackets(MkListOne(MkExpOp(CopyExpression(sizeExp), EQ_OP, MkExpConstant("1")))),
// ((class.type == structClass) ?
MkExpBrackets(MkListOne(MkExpCondition(MkExpBrackets(MkListOne(MkExpOp(MkExpMember(CopyExpression(classExp), MkIdentifier("type")), EQ_OP, MkExpIdentifier(MkIdentifier("structClass"))))),
// ((byte *)array) + (i) * class.size
- MkListOne(MkExpCast(MkTypeName(MkListOne(MkSpecifierName("uint64")), null), MkExpBrackets(MkListOne(MkExpOp(
+ MkListOne(MkExpCast(MkTypeName(MkListOne(MkSpecifierName("uint64")), null), MkExpCast(MkTypeName(MkListOne(MkSpecifierName("uintptr")), null), MkExpBrackets(MkListOne(MkExpOp(
MkExpBrackets(MkListOne(MkExpCast(MkTypeName(MkListOne(MkSpecifierName("byte")), MkDeclaratorPointer(MkPointer(null, null), null)), CopyExpression(exp.index.exp)))), '+',
- MkExpOp(MkExpBrackets(CopyList(exp.index.index, CopyExpression)), '*', CopyExpression(sizeExp))))))),
+ MkExpOp(MkExpBrackets(CopyList(exp.index.index, CopyExpression)), '*', CopyExpression(sizeExp)))))))),
// ((class.size == 1) ?
MkExpBrackets(MkListOne(MkExpCondition(MkExpBrackets(MkListOne(MkExpOp(CopyExpression(sizeExp), EQ_OP, MkExpConstant("1")))),
bool typedObject = false;
Type ellipsisDestType = null;
bool usedEllipsis = false;
+ Expression expCallExp = exp.call.exp;
+ OldList * arguments = exp.call.arguments;
+ bool handleNullVMethod = false;
+ TypeName typeName = null;
- if(exp.call.arguments)
+ if(arguments)
{
- for(e = exp.call.arguments->first; e; e = e.next)
+ for(e = arguments->first; e; e = e.next)
{
e.usage.usageGet = true;
e.usage.usageArg = true;
exp.tempCount = Max(exp.tempCount, e.tempCount);
}
}
- exp.call.exp.usage.usageGet = true;
- exp.call.exp.usage.usageCall = true;
- exp.call.exp.tempCount = exp.tempCount;
+ expCallExp.usage.usageGet = true;
+ expCallExp.usage.usageCall = true;
+ expCallExp.tempCount = exp.tempCount;
- ProcessExpression(exp.call.exp);
+ ProcessExpression(expCallExp);
- if(exp.call.exp.expType && exp.call.exp.expType.kind == methodType)
+ if(expCallExp.expType && expCallExp.expType.kind == methodType)
{
bool nullMemberExp = false;
- Expression memberExp = (exp.call.exp.type == ExpressionType::memberExp) ? exp.call.exp : null;
+ Expression memberExp = (expCallExp.type == ExpressionType::memberExp) ? expCallExp : null;
- Class _class = exp.call.exp.expType.methodClass; // For Virtual Method
- Class argClass = exp.call.exp.expType.methodClass; // Class actually passed
- Method method = exp.call.exp.expType.method;
+ Class _class = expCallExp.expType.methodClass; // For Virtual Method
+ Class argClass = expCallExp.expType.methodClass; // Class actually passed
+ Method method = expCallExp.expType.method;
if(method.type == virtualMethod)
{
char name[1024];
- TypeName typeName;
Declarator decl;
Context back;
OldList * specs = MkList();
strcat(name, "_");
strcat(name, method.name);
- DeclareMethod(method, name);
+ DeclareMethod(curExternal, method, name);
back = curContext;
// THIS SpecDeclFromString HERE SHOULD WORK WITH THE METHOD TEMPLATE PARAMETERS...
funcDecl.function.parameters->Insert(null, param);
// Testing this for any_object::
if(!method.dataType.extraParam)
+ {
funcDecl.function.parameters->Insert(null, MkTypeName(MkListOne(MkStructOrUnion(structSpecifier, MkIdentifier("__ecereNameSpace__ecere__com__Class"), null)), MkDeclaratorPointer(MkPointer(null,null), null)));
+ DeclareStruct(curExternal, "ecere::com::Class", false, true);
+ }
}
else
{
typeName = MkTypeName(specs, decl);
- // Added !exp.call.exp.expType.methodClass
if(memberExp && memberExp.member.exp.expType)
{
Type type = memberExp.member.exp.expType;
Class regClass = (type && type.kind == classType && type._class) ? type._class.registered : null;
char className[1024];
- if(!exp.call.exp.expType.methodClass && !_class && type && type.classObjectType)
+ // Added !exp.call.exp.expType.methodClass
+ if(!expCallExp.expType.methodClass && !_class && type && type.classObjectType)
strcpy(className, "class");
else
{
cl = class(int);
// To avoid declaring classes templatized after this class template (e.g. public struct Iterator<class T, class IT = int> { Container<T, IT> container; } )
- if(cl.templateClass && !_class && exp.call.exp.expType._class && !exp.call.exp.expType.methodClass &&
+ if(cl.templateClass && !_class && expCallExp.expType._class && !expCallExp.expType.methodClass &&
(type.kind == subClassType || (regClass && regClass.type == normalClass && strcmp(regClass.dataTypeString, "char *"))))
cl = cl.templateClass;
// Need the class itself here...
strcpy(className, "__ecereClass_");
FullClassNameCat(className, cl.fullName, true);
- //MangleClassName(className);
if(!cl.symbol)
cl.symbol = FindClass(cl.fullName);
- DeclareClass(cl.symbol, className);
+ DeclareClass(curExternal, cl.symbol, className);
}
- if(type && type.kind == subClassType && !_class && !exp.call.exp.expType.methodClass && memberExp)
+ if(type && type.kind == subClassType && !_class && !expCallExp.expType.methodClass && memberExp)
{
- exp.call.exp = MkExpBrackets(MkListOne(MkExpCast(typeName,
+ expCallExp = MkExpBrackets(MkListOne(MkExpCast(typeName,
MkExpIndex(MkExpPointer(CopyExpression(memberExp.member.exp), MkIdentifier("_vTbl")),
MkListOne(MkExpIdentifier(MkIdentifier(name)))))));
+
+ handleNullVMethod = true;
}
- else if(_class || exp.call.exp.expType.methodClass || !memberExp ||
+ else if(_class || expCallExp.expType.methodClass || !memberExp ||
!regClass || regClass.type != normalClass || !strcmp(regClass.dataTypeString, "char *"))
{
if(!memberExp)
- FreeExpression(exp.call.exp);
- exp.call.exp = MkExpBrackets(MkListOne(MkExpCast(typeName,
+ FreeExpression(expCallExp);
+ expCallExp = MkExpBrackets(MkListOne(MkExpCast(typeName,
MkExpIndex(MkExpPointer(MkExpIdentifier(MkIdentifier(className)), MkIdentifier("_vTbl")),
MkListOne(MkExpIdentifier(MkIdentifier(name)))))));
+
+ handleNullVMethod = true;
}
else
{
// as opposed to the File class vTbl one
// ({ Instance __internal_ClassInst = e; __internal_ClassInst ? __internal_ClassInst._vTbl : __ecereClass_...; })
- Expression c;
+ Expression vTblExp;
Context context = PushContext();
OldList * specs;
- c = MkExpExtensionCompound(MkCompoundStmt(
- MkListOne(MkDeclaration(
+ OldList * declList = MkListOne(MkDeclaration(
(specs = MkListOne(MkSpecifierName("Instance"))),
MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("__internal_ClassInst")),
- MkInitializerAssignment(CopyExpression(memberExp.member.exp)))))),
- MkListOne(MkExpressionStmt(MkListOne(MkExpCondition(
+ MkInitializerAssignment(CopyExpression(memberExp.member.exp))))));
+ OldList * stmtList = MkListOne(MkExpressionStmt(MkListOne(MkExpCondition(
MkExpIdentifier(MkIdentifier("__internal_ClassInst")),
MkListOne(MkExpPointer(MkExpIdentifier(MkIdentifier("__internal_ClassInst")), MkIdentifier("_vTbl"))),
- MkExpPointer(MkExpIdentifier(MkIdentifier(className)), MkIdentifier("_vTbl"))))))));
+ MkExpPointer(MkExpIdentifier(MkIdentifier(className)), MkIdentifier("_vTbl"))))));
+
+ vTblExp = MkExpExtensionCompound(MkCompoundStmt(declList, stmtList));
+
if(type.specConst)
specs->Insert(null, MkSpecifier(CONST));
- c.loc = exp.loc;
- c.compound.compound.context = context;
+
+ vTblExp.loc = exp.loc;
+ vTblExp.compound.compound.context = context;
PopContext(context);
- exp.call.exp = MkExpBrackets(MkListOne(MkExpCast(typeName,
- MkExpIndex(c, MkListOne(MkExpIdentifier(MkIdentifier(name)))))));
+
+ expCallExp = MkExpBrackets(MkListOne(MkExpCast(typeName,
+ MkExpIndex(vTblExp, MkListOne(MkExpIdentifier(MkIdentifier(name)))))));
+
+ handleNullVMethod = true;
}
}
}
strcat(name, method.name);
if(!memberExp)
- FreeExpression(exp.call.exp);
- exp.call.exp = MkExpIdentifier(MkIdentifier(name));
- DeclareMethod(method, name);
+ FreeExpression(expCallExp);
+ expCallExp = MkExpIdentifier(MkIdentifier(name));
+ DeclareMethod(curExternal, method, name);
if(memberExp && memberExp.expType && method.dataType)
{
- exp.call.exp.expType = method.dataType;
+ expCallExp.expType = method.dataType;
method.dataType.refCount++;
}
}
{
if(method.dataType && !method.dataType.staticMethod && !method.dataType.extraParam)
{
- if(!exp.call.arguments)
- exp.call.arguments = MkList();
+ if(!arguments)
+ arguments = MkList();
// Testing this (COMMENTED OUT TESTING, CALLING METHODS ON ENUM/UNIT ADDED & IN FRONT OF VARIABLES
/*
if(typedObject && memberExp.member.exp && memberExp.member.exp.expType)
{
bool changeReference = false;
+ bool stillAddReferenceOp = false;
Expression memberExpMemberExp = CopyExpression(memberExp.member.exp);
+ Type expType = memberExp.member.exp.expType;
+ Class c = expType.kind == classType && expType._class ? expType._class.registered : null;
// Patched so that class isn't considered SYSTEM...
if(argClass && (argClass.type == enumClass || argClass.type == unitClass || argClass.type == bitClass || argClass.type == systemClass) && strcmp(argClass.fullName, "class") &&
strcmp(argClass.fullName, "uintptr") && strcmp(argClass.fullName, "intptr"))
changeReference = true;
- if(!memberExp.member.exp.expType.classObjectType &&
- (((
- (memberExp.member.exp.expType.kind != pointerType &&
- (memberExp.member.exp.expType.kind != classType || !memberExp.member.exp.expType._class ||
- !memberExp.member.exp.expType._class.registered || memberExp.member.exp.expType._class.registered.type == structClass)))) ||
- method.dataType.byReference)) // ADDED THIS FOR OnGetDataFromString
+ if(!expType.classObjectType && ( ( (expType.kind != pointerType && (!c || c.type == structClass) ) ) || method.dataType.byReference) ) // ADDED THIS FOR OnGetDataFromString
+ {
+ if(c && (c.type == normalClass || c.type == noHeadClass))
+ stillAddReferenceOp = true;
changeReference = true;
- if(typedObject && memberExp.member.exp.expType.classObjectType && memberExp.member.exp.expType.byReference != method.dataType.byReference)
+ }
+ if(typedObject && expType.classObjectType && expType.byReference != method.dataType.byReference)
changeReference = true;
if(changeReference)
{
if(memberExp.member.exp.type == bracketsExp && memberExp.member.exp.list && memberExp.member.exp.list->count == 1 &&
((Expression)memberExp.member.exp.list->first).type == opExp && ((Expression)memberExp.member.exp.list->first).op.op == '*' && !((Expression)memberExp.member.exp.list->first).op.exp1)
{
- exp.call.arguments->Insert(null, ((Expression)memberExp.member.exp.list->first).op.exp2);
+ arguments->Insert(null, ((Expression)memberExp.member.exp.list->first).op.exp2);
((Expression)memberExp.member.exp.list->first).op.exp2 = null;
}
else if(memberExp.member.exp.type == opExp && memberExp.member.exp.op.op == '*' && !memberExp.member.exp.op.exp1)
{
- exp.call.arguments->Insert(null, memberExp.member.exp.op.exp2);
+ arguments->Insert(null, memberExp.member.exp.op.exp2);
memberExp.member.exp.op.exp2 = null;
}
- else if(!memberExp.member.exp.byReference)
+ else if(!memberExp.member.exp.byReference || stillAddReferenceOp)
{
// TESTING THIS... REUSE THIS CODE?
Expression checkedExp = memberExp.member.exp;
if(!parentExp)
nullMemberExp = true;
- newExp = (typedObject && !memberExp.member.exp.expType.classObjectType) ? checkedExp : MkExpOp(null, '&', checkedExp);
+ if(typedObject && !expType.classObjectType && !stillAddReferenceOp)
+ newExp = checkedExp;
+ else
+ {
+ newExp = MkExpOp(null, '&', checkedExp);
+ newExp.byReference = true;
+ }
if(parentExp && (parentExp.type == bracketsExp || parentExp.type == extensionExpressionExp))
{
parentExp.list->Remove(checkedExp);
{
parentExp.cast.exp = newExp;
// Add a dereference level here
- parentExp.cast.typeName.declarator = MkDeclaratorPointer(MkPointer(null, null), parentExp.cast.typeName.declarator);
+ if(newExp.expType && newExp.expType.classObjectType)
+ parentExp.cast.typeName.declarator = MkDeclaratorPointer(MkPointer(null, null), parentExp.cast.typeName.declarator);
}
- if(typedObject && !memberExp.member.exp.expType.classObjectType)
+ if(typedObject && !expType.classObjectType)
{
Type destType { refCount = 1, kind = classType, classObjectType = ClassObjectType::anyObject };
FreeType((parentExp ? parentExp : newExp).expType);
(parentExp ? parentExp : newExp).destType = destType;
if(checkedExp.expType) checkedExp.expType.refCount++;
}
- exp.call.arguments->Insert(null, parentExp ? parentExp : newExp);
+ arguments->Insert(null, parentExp ? parentExp : newExp);
}
else
{
- exp.call.arguments->Insert(null, memberExp.member.exp);
+ arguments->Insert(null, memberExp.member.exp);
nullMemberExp = true;
}
}
else
{
- exp.call.arguments->Insert(null, memberExp.member.exp);
+ arguments->Insert(null, memberExp.member.exp);
nullMemberExp = true;
}
// Need the class itself here...
strcpy(className, "__ecereClass_");
FullClassNameCat(className, cl.fullName, true);
- //MangleClassName(className);
if(!cl.symbol)
cl.symbol = FindClass(cl.fullName);
- DeclareClass(cl.symbol, className);
+ DeclareClass(curExternal, cl.symbol, className);
}
if(className[0])
if(type.specConst)
specs->Insert(null, MkSpecifier(CONST));
- exp.call.arguments->Insert(null, c);
+ arguments->Insert(null, c);
memberExpMemberExp = null; // We used this
}
else
- exp.call.arguments->Insert(null, MkExpIdentifier(MkIdentifier(className)));
+ arguments->Insert(null, MkExpIdentifier(MkIdentifier(className)));
}
}
}
else
{
- exp.call.arguments->Insert(null, memberExp.member.exp);
+ arguments->Insert(null, memberExp.member.exp);
nullMemberExp = true;
}
}
}
}
- if(exp.call.arguments)
+ if(arguments)
{
- for(e = exp.call.arguments->first; e; e = e.next)
+ for(e = arguments->first; e; e = e.next)
{
Type destType = (e.destType && e.destType.kind == ellipsisType) ? ellipsisDestType : e.destType;
//if(e.destType && e.destType.kind == classType && e.destType._class && !strcmp(e.destType._class.string, "class"))
checkedExp = e;
parentExp = exp;
- while(((checkedExp.type == bracketsExp || checkedExp.type == extensionExpressionExp || checkedExp.type == extensionCompoundExp) && checkedExp.list) || checkedExp.type == castExp)
+ while(checkedExp && (((checkedExp.type == bracketsExp || checkedExp.type == extensionExpressionExp || checkedExp.type == extensionCompoundExp) && checkedExp.list) || checkedExp.type == castExp))
{
parentExp = checkedExp;
if(checkedExp.type == bracketsExp || checkedExp.type == extensionExpressionExp || checkedExp.type == extensionCompoundExp)
{
/*
Expression newExp = e.op.exp2;
- exp.call.arguments->Insert(e.prev, newExp);
- exp.call.arguments->Remove(e);
+ arguments->Insert(e.prev, newExp);
+ arguments->Remove(e);
e.op.exp2 = null;
FreeExpContents(e);
e = newExp;
{
char size[100];
ComputeTypeSize(e.expType);
- sprintf(size, "%d", e.expType.size);
+ sprintf(size, "%d", e.expType.size); // BOOTSTRAP FIX
newExp = MkExpBrackets(MkListOne(MkExpOp(MkExpCast(MkTypeName(MkListOne(MkSpecifier(CHAR)),
MkDeclaratorPointer(MkPointer(null, null), null)), newExp), '+',
MkExpCall(MkExpIdentifier(MkIdentifier("__ENDIAN_PAD")), MkListOne(MkExpConstant(size))))));
if(parentExp.type == callExp)
{
- exp.call.arguments->Insert(e.prev, newExp);
- exp.call.arguments->Remove(e);
+ arguments->Insert(e.prev, newExp);
+ arguments->Remove(e);
e = newExp;
}
else if(parentExp.type == bracketsExp || parentExp.type == extensionExpressionExp)
PrintTypeNoConst(e.expType, typeString, false, true);
decl = SpecDeclFromString(typeString, specs, null);
newExp.destType = ProcessType(specs, decl);
+ if(newExp.destType && e.expType && e.expType.passAsTemplate)
+ {
+ Expression nbExp = GetNonBracketsExp(newExp);
+ if(nbExp.type == castExp)
+ {
+ // Because we're correcting this after the cast was added from the argument for loop at the beginning of this case block
+ // (CheckTemplateTypes() already called), we'll revert the cast to generic uint64 template type
+ FreeTypeName(nbExp.cast.typeName);
+ nbExp.cast.typeName = MkTypeName(MkListOne(MkSpecifierName("uint64")), null);
+ }
+
+ newExp.expType = newExp.destType;
+ newExp.destType.refCount++;
+ modifyPassAsTemplate(&newExp.expType, true);
+ }
curContext = context;
e.type = extensionCompoundExp;
curCompound.compound.declarations->Insert(null, MkDeclaration(specs, MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier(name)), null))));
ListAdd(stmts, MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(name)), '=', newExp))));
ListAdd(stmts, MkExpressionStmt(MkListOne(MkExpIdentifier(MkIdentifier(name)))));
+ CheckTemplateTypes(newExp);
e.compound = MkCompoundStmt(null, stmts);
}
else
// TODO: INTEGRATE THIS WITH VERSION ABOVE WHICH WAS ADDED TO ENCOMPASS OTHER CASE (*pointer)
checkedExp = e;
parentExp = exp;
- while(((checkedExp.type == bracketsExp || checkedExp.type == extensionExpressionExp || checkedExp.type == extensionCompoundExp) && checkedExp.list) || checkedExp.type == castExp)
+ while(checkedExp && (((checkedExp.type == bracketsExp || checkedExp.type == extensionExpressionExp || checkedExp.type == extensionCompoundExp) && checkedExp.list) || checkedExp.type == castExp))
{
parentExp = checkedExp;
if(checkedExp.type == bracketsExp || checkedExp.type == extensionExpressionExp || checkedExp.type == extensionCompoundExp)
else if(checkedExp.type == castExp)
checkedExp = checkedExp.cast.exp;
}
- newExp = MkExpOp(null, '&', checkedExp);
- newExp.byReference = true;
+ {
+ Expression i;
+ newExp = MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null, null), null)), (i = MkExpOp(null, '&', checkedExp)));
+ i.byReference = true;
+ newExp.byReference = true;
+ }
if(parentExp.type == callExp)
{
- exp.call.arguments->Insert(e.prev, newExp);
- exp.call.arguments->Remove(e);
+ arguments->Insert(e.prev, newExp);
+ arguments->Remove(e);
e = newExp;
}
else if(parentExp.type == bracketsExp || parentExp.type == extensionExpressionExp)
{
strcpy(className, "__ecereClass_");
FullClassNameCat(className, _class.fullName, true);
- //MangleClassName(className);
if(!_class.symbol)
_class.symbol = FindClass(_class.fullName);
- DeclareClass(_class.symbol, className);
+ DeclareClass(curExternal, _class.symbol, className);
}
if(_class.type == normalClass && destType.byReference == false && strcmp(_class.dataTypeString, "char *"))
((Expression)e.list->first).cast.exp.op.exp2 &&
((Expression)e.list->first).cast.exp.op.exp2.type == extensionInitializerExp)
{
- exp.call.arguments->Insert(e.prev, MkExpIdentifier(MkIdentifier(className)));
+ arguments->Insert(e.prev, MkExpIdentifier(MkIdentifier(className)));
}
else
{
if(type.specConst)
specs->Insert(null, MkSpecifier(CONST));
- exp.call.arguments->Insert(e.prev, c);
+ arguments->Insert(e.prev, c);
}
}
else
- exp.call.arguments->Insert(e.prev, MkExpIdentifier(MkIdentifier(className)));
+ arguments->Insert(e.prev, MkExpIdentifier(MkIdentifier(className)));
}
}
}
if(ellipsisDestType)
{
if(usedEllipsis ||
- (exp.call.exp.expType && exp.call.exp.expType.kind == functionType && exp.call.exp.expType.params.last &&
- ((Type)exp.call.exp.expType.params.last).kind == ellipsisType))
+ (expCallExp.expType && expCallExp.expType.kind == functionType && expCallExp.expType.params.last &&
+ ((Type)expCallExp.expType.params.last).kind == ellipsisType))
+ {
+ arguments->Insert(arguments->last, MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null, null),null)),MkExpConstant("0")));
+ }
+ }
+ }
+
+ if(handleNullVMethod)
+ {
+ Expression compoundExp;
+ Context context = PushContext();
+ OldList * declList = MkList();
+ OldList * stmtList = MkList();
+ TypeName castTypeName;
+ OldList * specs = MkList();
+ Specifier spec;
+
+ for(spec = typeName.qualifiers ? typeName.qualifiers->first : null; spec; spec = spec.next)
+ {
+ if(spec.type != extendedSpecifier)
+ specs->Add(CopySpecifier(spec));
+ }
+
+ if(typeName.declarator.type == pointerDeclarator)
+ {
+ Pointer p = typeName.declarator.pointer.pointer.pointer;
+ castTypeName = MkTypeName(specs, CopyDeclarator(typeName.declarator.declarator.declarator.declarator));
+ while(p)
{
- exp.call.arguments->Insert(exp.call.arguments->last, MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null, null),null)),MkExpConstant("0")));
+ Pointer pp;
+ for(pp = castTypeName.declarator.pointer.pointer; pp.pointer; pp = pp.pointer);
+ pp.pointer = MkPointer(null, null);
+ pp.qualifiers = CopyList(p.qualifiers, CopySpecifier);
+ p = p.pointer;
}
}
+ else
+ castTypeName = MkTypeName(specs, CopyDeclarator(typeName.declarator.declarator.declarator.declarator));
+
+ compoundExp = MkExpExtensionCompound(MkCompoundStmt(declList, stmtList));
+
+ declList->Add(MkDeclaration(CopyList(typeName.qualifiers, CopySpecifier),
+ MkListOne(MkInitDeclarator(PlugDeclarator(CopyDeclarator(typeName.declarator), MkDeclaratorIdentifier(MkIdentifier("__internal_VirtualMethod"))), null))));
+
+ stmtList->Add(MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier("__internal_VirtualMethod")), '=', expCallExp))));
+ stmtList->Add(MkExpressionStmt(MkListOne(MkExpCondition(
+ MkExpIdentifier(MkIdentifier("__internal_VirtualMethod")),
+ MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("__internal_VirtualMethod")), arguments)), MkExpCast(castTypeName, MkExpConstant("1"))))));
+
+ compoundExp.loc = exp.loc;
+ compoundExp.compound.compound.context = context;
+ PopContext(context);
+
+ exp.type = bracketsExp;
+ exp.list = MkListOne(compoundExp);
+ }
+ else
+ {
+ exp.call.exp = expCallExp;
+ exp.call.arguments = arguments;
}
break;
}
ProcessExpression(exp.member.exp);
// TEST: exp.tempCount = exp.member.exp.tempCount;
- DeclareProperty(prop, setName, getName);
+ DeclareProperty(curExternal, prop, setName, getName);
//propertyClass = convertTo ? _class : ((Symbol)prop.symbol)._class;
propertyClass = convertTo ? _class :
((((Symbol)prop.symbol).type && ((Symbol)prop.symbol).type.kind == classType) ? ((Symbol)prop.symbol).type._class.registered : ((Symbol)prop.symbol)._class);
-
if(propertyClass && propertyClass.type == bitClass)
{
// Bit classes shouldn't have properties except for conversions...
className[0] = 0;
FullClassNameCat(className, propertyClass.fullName, false); //true);
+ DeclareStruct(curExternal, propertyClass.fullName, false, true);
//ListAdd(specs, MkSpecifierName(className));
ListAdd(specs, MkStructOrUnion(structSpecifier, MkIdentifier(className), null));
else
exp.cast.typeName = QMkType("uint64", null);
exp.cast.exp = MkExpCall(MkExpIdentifier(MkIdentifier("ecere::com::eClass_GetProperty")), args);
+ if(exp.expType.isPointerType)
+ exp.cast.exp = MkExpCast(MkTypeName(MkListOne(MkSpecifierName("uintptr")), null), exp.cast.exp);
ListAdd(args, classExp);
{
// Need the class itself here...
strcpy(className, "__ecereClass_");
FullClassNameCat(className, _class.fullName, true);
- //MangleClassName(className);
if(!_class.symbol)
_class.symbol = FindClass(_class.fullName);
- DeclareClass(_class.symbol, className);
+ DeclareClass(curExternal, _class.symbol, className);
FreeExpression(exp.member.exp);
exp.index.exp = MkExpPointer(MkExpIdentifier(MkIdentifier(className)), MkIdentifier("_vTbl"));
exp.index.exp = MkExpPointer(exp.member.exp, MkIdentifier("_vTbl"));
}
exp.index.index = MkListOne(QMkExpId(name));
- DeclareMethod(method, name);
+ DeclareMethod(curExternal, method, name);
}
else
{
strcat(name, "_");
strcat(name, method.name);
exp.identifier = MkIdentifier(name);
- DeclareMethod(method, name);
+ DeclareMethod(curExternal, method, name);
}
}
}
// TEST: exp.tempCount = exp.member.exp.tempCount;
if(type.kind == classType && type._class && type._class.registered)
- DeclareStruct(type._class.registered.fullName, false);
+ DeclareStruct(curExternal, type._class.registered.fullName, false, true);
// TESTING THIS NOHEAD STUFF...
if(_class.type == noHeadClass)
char className[1024];
strcpy(className, "__ecereClass_");
FullClassNameCat(className, member._class.fullName, true);
- //MangleClassName(className);
// classExp = QMkExpId(className);
if(!member._class.symbol)
member._class.symbol = FindClass(member._class.fullName);
- DeclareClass(member._class.symbol, className);
- DeclareStruct(member._class.fullName, false);
+ DeclareClass(curExternal, member._class.symbol, className);
+ DeclareStruct(curExternal, member._class.fullName, false, true);
structName[0] = 0;
FullClassNameCat(structName, member._class.fullName, false);
compound = MkCompoundStmt(
MkListOne(MkDeclaration(MkListOne(MkSpecifier(CHAR)), MkListOne(MkInitDeclarator(
MkDeclaratorPointer(MkPointer(null, null), MkDeclaratorIdentifier(MkIdentifier(ecereTemp))),
- MkInitializerAssignment(QBrackets(exp.member.exp)))))), null);
+ MkInitializerAssignment(MkExpCast(MkTypeName(MkListOne(MkSpecifier(CHAR)), MkDeclaratorPointer(MkPointer(null, null), null)), QBrackets(exp.member.exp))))))), null);
if(member._class.fixed)
{
- if(member._class.templateClass ? member._class.templateClass.offset : member._class.offset)
+ Class c = member._class.templateClass ? member._class.templateClass : member._class;
+ if(c.offset)
{
- char string[256];
- sprintf(string, "%d", member._class.templateClass ? member._class.templateClass.offset : member._class.offset);
- e = QBrackets(MkExpOp(QMkExpId(ecereTemp), '+', MkExpConstant(string)));
+ Expression se;
+
+ if(c.offset == c.base.structSize)
+ {
+ se = MkExpClassSize(MkSpecifierName(c.base.fullName));
+ ProcessExpressionType(se);
+ se.isConstant = false;
+ }
+ else
+ {
+ char string[256];
+ sprintf(string, "%d", c.offset);
+ se = MkExpConstant(string);
+ }
+ e = QBrackets(MkExpOp(QMkExpId(ecereTemp), '+', se));
}
else
e = QMkExpId(ecereTemp);
// if(class.fixed)
if(member._class.fixed)
{
- if(member._class.templateClass ? member._class.templateClass.offset : member._class.offset)
+ Class c = member._class.templateClass ? member._class.templateClass : member._class;
+ if(c.offset)
{
- char string[256];
- sprintf(string, "%d", member._class.templateClass ? member._class.templateClass.offset : member._class.offset);
- e = QBrackets(QBrackets(MkExpOp(bytePtr, '+', MkExpConstant(string))));
+ Expression se;
+
+ if(c.offset == c.base.structSize)
+ {
+ se = MkExpClassSize(MkSpecifierName(c.base.fullName));
+ ProcessExpressionType(se);
+ se.isConstant = false;
+ }
+ else
+ {
+ char string[256];
+ sprintf(string, "%d", c.offset);
+ se = MkExpConstant(string);
+ }
+
+ e = QBrackets(QBrackets(MkExpOp(bytePtr, '+', se)));
}
else
e = bytePtr;
strcpy(className, "__ecereClass_");
FullClassNameCat(className, string, true); // TODO: Verify this
- //MangleClassName(className);
- DeclareClass(classSym, className);
+
+ DeclareClass(curExternal, classSym, className);
delete string;
FreeList(exp._classExp.specifiers, FreeSpecifier);
if((!exp.expType || exp.expType.kind != templateType || nbExp.type != castExp) && !exp.usage.usageRef &&
(!exp.destType || (!exp.destType.truth && (exp.destType.kind != templateType || (exp.destType.templateParameter && (exp.destType.templateParameter.dataTypeString || exp.destType.templateParameter.dataType))))) &&
(exp.usage.usageDelete || exp.usage.usageGet || exp.usage.usageArg) &&
- (!exp.destType || (!exp.destType.passAsTemplate && exp.expType && (exp.expType.kind != pointerType || exp.destType.kind == pointerType) && (exp.destType.kind != pointerType || exp.expType.kind == pointerType))) &&
+ (!exp.destType || (!exp.destType.passAsTemplate && exp.expType && (exp.expType.kind != pointerType || (exp.destType.kind == pointerType || exp.destType.kind == intPtrType)) && ((exp.destType.kind != pointerType && exp.destType.kind != intPtrType) || exp.expType.kind == pointerType))) &&
!inner.needCast && inner.type != opExp)
{
- Expression e = CopyExpContents(exp);
+ Expression e = MoveExpContents(exp);
Declarator decl;
OldList * specs = MkList();
char typeString[1024];
+ bool castingToDest = false;
+ bool pointerCastExp = false;
typeString[0] = '\0';
if(exp.usage.usageDelete)
strcpy(typeString, "void *");
else
- PrintType(exp.expType, typeString, false, false);
+ {
+ if(exp.expType.kind == templateType && exp.expType.templateParameter && exp.expType.templateParameter.dataTypeString)
+ strcpy(typeString, exp.expType.templateParameter.dataTypeString);
+ else
+ PrintType(exp.expType, typeString, false, false);
+ }
decl = SpecDeclFromString(typeString, specs, null);
specs = CopyList(exp.destType.templateParameter.dataType.specifiers, CopySpecifier);
decl = CopyDeclarator(exp.destType.templateParameter.dataType.decl);
}
+
+ castingToDest = true;
}
e.destType = exp.destType;
exp.destType.refCount++;
exp.type = bracketsExp;
+
+ {
+ Specifier spec = specs ? specs->first : null;
+ TemplateParameter tp = (spec && spec.type == templateTypeSpecifier) ? spec.templateParameter : null;
+ Type type = castingToDest ? exp.destType : exp.expType;
+ bool specsDeclPointer = (spec.type == nameSpecifier && strcmp(spec.name, "uint64")) ||
+ (decl && decl.type == pointerDeclarator) ||
+ (tp && tp.dataType &&
+ ( (tp.dataType.decl && tp.dataType.decl.type == pointerDeclarator) ||
+ (tp.dataType.specifiers && ((Specifier)tp.dataType.specifiers->first).type == nameSpecifier && strcmp(((Specifier)tp.dataType.specifiers->first).name, "uint64")) ) );
+ pointerCastExp = type ? ((type.kind == templateType && specsDeclPointer) || type.isPointerType) : specsDeclPointer;
+ }
+
+ if(pointerCastExp)
+ {
+ e = MkExpCast(MkTypeName(MkListOne(MkSpecifierName("uintptr")), null), MkExpBrackets(MkListOne(e)));
+ e.needTemplateCast = 2;
+ }
exp.list = MkListOne(MkExpCast(MkTypeName(specs, decl), MkExpBrackets(MkListOne(e))));
+ if(exp.destType && pointerCastExp == (exp.destType.passAsTemplate ||
+ (!exp.destType.isPointerType || (exp.destType.kind == templateType && (!exp.destType.templateParameter || (!exp.destType.templateParameter.dataType && !exp.destType.templateParameter.dataTypeString))))))
+ exp.list = MkListOne(MkExpCast(MkTypeName(MkListOne(MkSpecifierName("uintptr")), decl), MkExpBrackets(exp.list)));
exp.needTemplateCast = 2;
}
}