if(func.type) func.type.refCount++;
ProcessFunctionBody(function, func.body);
external = MkExternalFunction(function);
-
+
external.symbol = func.declarator.symbol;
external.function._class = func._class;
}
//symbol.id = func.id; //symid;
symbol.id = symid;
symbol.idCode = symidCode;
-
+
if(!func.dontMangle)
{
// Normal method
Method method = func.declarator.symbol.method;
func.declarator.symbol.methodExternal = external;
- // DANGER: Added this one...
+ // DANGER: Added this one...
if(method && method.symbol)
//((Symbol)method.symbol).methodExternal = external;
{
Type methodDataType;
ProcessMethodType(method);
-
+
methodDataType = method.dataType;
// Do type checking here of type against method.dataType
}
yylloc = func.loc;
- if(!MatchTypes(type, methodDataType, null, owningClass, method._class /*owningClass*/, true, true, true, false))
+ if(!MatchTypes(type, methodDataType, null, owningClass, method._class /*owningClass*/, true, true, true, false, true))
{
#ifdef _DEBUG
// MatchTypes(type, methodDataType, null, owningClass, owningClass, true, true, true, false);
{
propSymbol.externalIsSet = external;
}
- else
+ else
{
// Constructor destructor
//symbol.type = Type { };
Method method = func.declarator.symbol.method;
if(method && method.symbol)
((Symbol)method.symbol).methodCodeExternal = null;
+ if(func.declarator.symbol && func.declarator.symbol.methodExternal == external)
+ func.declarator.symbol.methodExternal = null;
//external.function = null;
func.declarator = null;
{
globalContext /*curContext*/.symbols.Remove((BTNode)symbol);
excludedSymbols->Add(symbol);
-
+
// Testing this...
defs.Insert(after, external);
registerModuleBody.compound.context = Context { parent = globalContext };
#if 0
- ListAdd(registerModuleBody.compound.declarations,
+ ListAdd(registerModuleBody.compound.declarations,
MkDeclaration(MkListOne(MkStructOrUnion(structSpecifier, MkIdentifier("__ecereNameSpace__ecere__com__Class"), null) /*MkSpecifierName("ecere::com::Class")*/ /*MkStructOrUnion(SpecifierStruct, MkIdentifier("Class"), null)*/),
MkListOne(MkInitDeclarator(MkDeclaratorPointer(MkPointer(null,null), MkDeclaratorIdentifier(MkIdentifier("class"))), null))));
#endif
- ListAdd(registerModuleBody.compound.declarations,
+ ListAdd(registerModuleBody.compound.declarations,
MkDeclaration(MkListOne(MkSpecifierName("ecere::com::Class")),
MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("class")), null))));
specifiers = MkList();
ListAdd(specifiers, MkSpecifier(VOID));
- moduleParam = MkTypeName(MkListOne(/*MkSpecifier(VOID)*/MkSpecifierName("Module")),
- //MkDeclaratorPointer(MkPointer(null, null),
+ moduleParam = MkTypeName(MkListOne(/*MkSpecifier(VOID)*/MkSpecifierName("Module")),
+ //MkDeclaratorPointer(MkPointer(null, null),
MkDeclaratorIdentifier(MkIdentifier("module")));
GetLastDirectory(outputFile, moduleName);
// Unregister Module
if(!unregisterModuleBody && inCompiler)
- {
+ {
char registerName[1024], moduleName[MAX_FILENAME];
OldList * specifiers;
Declarator declarator;
specifiers = MkList();
ListAdd(specifiers, MkSpecifier(VOID));
- moduleParam = MkTypeName(MkListOne(/*MkSpecifier(VOID)*/ MkSpecifierName("Module")),
- //MkDeclaratorPointer(MkPointer(null, null),
+ moduleParam = MkTypeName(MkListOne(/*MkSpecifier(VOID)*/ MkSpecifierName("Module")),
+ //MkDeclaratorPointer(MkPointer(null, null),
MkDeclaratorIdentifier(MkIdentifier("module")));
GetLastDirectory(outputFile, moduleName);
}
}
-void RegisterMembersAndProperties(Class regClass, bool isMember, char * className, Statement statement)
+void RegisterMembersAndProperties(Class regClass, bool isMember, const char * className, Statement statement)
{
DataMember dataMember = isMember ? (DataMember)regClass : null;
DataMember member;
ListAdd(list, MkExpOp(MkExpIdentifier(MkIdentifier(nameM)), '=', MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null,null), null)), MkExpConstant("0"))));
// stmt = MkIfStmt(MkListOne(MkExpOp(null, '!', MkExpIdentifier(MkIdentifier(name)))), MkExpressionStmt(list), null);
stmt = MkIfStmt(MkListOne(MkExpOp(
- MkExpMember(MkExpIdentifier(MkIdentifier("module")), MkIdentifier("application")), EQ_OP,
+ MkExpMember(MkExpIdentifier(MkIdentifier("module")), MkIdentifier("application")), EQ_OP,
MkExpMember(MkExpIdentifier(MkIdentifier("__thisModule")), MkIdentifier("application")))), MkExpressionStmt(list), null);
ListAdd(registerModuleBody.compound.statements, stmt);
// Unregister 2nd property
- stmt = MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(nameM)), '=',
+ stmt = MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(nameM)), '=',
MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null,null), null)), MkExpConstant("0")))));
ListAdd(unregisterModuleBody.compound.statements, stmt);
}
// Declaration Mode
ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
-
+
stmt = MkExpressionStmt(MkListOne(
MkExpCall(MkExpIdentifier(MkIdentifier(isMember ? "eMember_AddDataMember" : "eClass_AddDataMember")), args)));
ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
break;
}
-
+
stmt = MkExpressionStmt(MkListOne(
MkExpCall(MkExpIdentifier(MkIdentifier(isMember ? "eMember_AddDataMember" : "eClass_AddDataMember")), args)));
curContext = statement.compound.context;
context = PushContext();
-
+
args = MkListOne(MkExpIdentifier(MkIdentifier((member.type == unionMember) ? "unionMember" : "structMember")));
-
+
// Declaration Mode
switch(member.memberAccess)
{
ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
break;
}
-
- compound = MkCompoundStmt(MkListOne(MkDeclaration(MkListOne(MkSpecifierName("DataMember")),
- MkListOne(MkInitDeclarator(/*MkDeclaratorPointer(MkPointer(null, null), */MkDeclaratorIdentifier(MkIdentifier(memberName))/*)*/,
+
+ compound = MkCompoundStmt(MkListOne(MkDeclaration(MkListOne(MkSpecifierName("DataMember")),
+ MkListOne(MkInitDeclarator(/*MkDeclaratorPointer(MkPointer(null, null), */MkDeclaratorIdentifier(MkIdentifier(memberName))/*)*/,
MkInitializerAssignment(MkExpCall(MkExpIdentifier(MkIdentifier("eMember_New")), args)))))), MkList());
compound.compound.context = context;
-
+
args = MkList();
// Class class / DataMember member
{
ClassDef def;
Class regClass = symbol.registered;
-
+
if(regClass)
{
classType = regClass.type;
refCount = 1;
};
e.exp.destType = destType;
-
+
// Set parsingType to avoid producing errors
parsingType = true;
ProcessExpressionType(e.exp);
destType._class = symbol;
ProcessExpressionType(e.exp);
}
- ComputeExpression(e.exp);
+ if(e.exp.type == identifierExp && e.exp.expType && e.exp.identifier && e.exp.identifier.string && e.exp.expType.kind == enumType)
+ {
+ // Resolve enums here
+ NamedLink l;
+ char * string = e.exp.identifier.string;
+ for(l = e.exp.expType.members.first; l; l = l.next)
+ {
+ if(!strcmp(l.name, string))
+ {
+ if(l.data)
+ {
+ FreeExpContents(e.exp);
+ e.exp.type = constantExp;
+ e.exp.constant = PrintUInt((uint)l.data);
+ FreeType(e.exp.expType);
+ e.exp.expType = ProcessTypeString("uint", false);
+ }
+ break;
+ }
+ }
+ }
+ else
+ ComputeExpression(e.exp);
if(e.exp.isConstant && /*e.exp.expType.kind == intType*/ e.exp.type == constantExp)
{
Operand op = GetOperand(e.exp);
}
else
// Sort of an error
- eEnum_AddValue(regClass, e.id.string);
+ eEnum_AddValue(regClass, e.id.string);
}
else
eEnum_AddValue(regClass, e.id.string);
}
+ // Fix up derivatives enums largest
+ {
+ EnumClassData baseData = regClass.data;
+ OldLink deriv;
+ for(deriv = regClass.derivatives.first; deriv; deriv = deriv.next)
+ {
+ Class c = deriv.data;
+ if(c && c.type == enumClass)
+ {
+ EnumClassData data = c.data;
+ data.largest = baseData.largest;
+ }
+ }
+ }
}
// Process all functions
ListAdd(specifiers, MkSpecifier(VOID));
ast->Insert(curExternal.prev, externalDecl);
-
- decl = MkDeclaration(specifiers,
- MkListOne(MkInitDeclarator(MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(watcherName)),
+
+ decl = MkDeclaration(specifiers,
+ MkListOne(MkInitDeclarator(MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(watcherName)),
MkListOne(MkTypeName(MkListOne(MkSpecifierName(regClass.fullName)), null))), null)));
externalDecl.declaration = decl;
if(decl.symbol && !decl.symbol.methodExternal)
decl.symbol.idCode = symbol.idCode;
}
}
-
+
propWatch.compound = null;
definitions.Insert(null, MkClassDefFunction(func));
- stmt.type = expressionStmt;
- stmt.expressions = MkList();
-
for(propID = propWatch.properties->first; propID; propID = propID.next)
{
Property prop = eClass_FindProperty(regClass, propID.string, privateModule);
// eProperty_SelfWatch(_class, name, callback);
OldList * args = MkList();
ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
- ListAdd(args, MkExpString(QMkString(propID.string)));
+ {
+ char * s = QMkString(propID.string);
+ ListAdd(args, MkExpString(s));
+ delete s;
+ }
ListAdd(args, MkExpIdentifier(MkIdentifier(watcherName)));
ListAdd(stmt.expressions, MkExpCall(MkExpIdentifier(MkIdentifier("eProperty_SelfWatch")), args));
OldList * args = MkList();
Method method;
Expression exp;
- char * registerFunction = null;
+ const char * registerFunction = null;
AccessMode inheritanceAccess = publicAccess;
CreateRegisterModuleBody();
//ListAdd(args, class.declaredStruct ? MkExpTypeSize(MkTypeName(MkListOne(
//MkSpecifierName(class.structName)), null)) : MkExpConstant("0"));
-
+
if(regClass.type == structClass || regClass.type == normalClass || regClass.type == noHeadClass)
{
// Check if we have a data member in this class
if(regClass.type == normalClass || regClass.type == noHeadClass)
{
// Constructor
- ListAdd(args, symbol.needConstructor ?
+ ListAdd(args, symbol.needConstructor ?
MkExpIdentifier(MkIdentifier(symbol.constructorName)) :
MkExpConstant("0"));
// Destructor
- ListAdd(args, symbol.needDestructor ?
+ ListAdd(args, symbol.needDestructor ?
MkExpIdentifier(MkIdentifier(symbol.destructorName)) :
MkExpConstant("0"));
}
ListAdd(args, MkExpIdentifier(MkIdentifier(buildingECERECOMModule ? "baseSystemAccess" : "publicAccess")));
break;
}
-
+
// Declaration Mode
switch(inheritanceAccess)
{
stmt = MkIfStmt(MkListOne(
MkExpOp(MkExpOp(
- MkExpMember(MkExpIdentifier(MkIdentifier("module")), MkIdentifier("application")), EQ_OP,
+ MkExpMember(MkExpIdentifier(MkIdentifier("module")), MkIdentifier("application")), EQ_OP,
MkExpMember(MkExpIdentifier(MkIdentifier("__thisModule")), MkIdentifier("application"))), AND_OP, MkExpIdentifier(MkIdentifier("class")))),
MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(symbol.className)), '=',
MkExpIdentifier(MkIdentifier("class"))))), null);
for(c = 0; c<base.vTblSize; c++)
{
Symbol method = (Symbol)regClass._vTbl[c];
- if((void *) method != DummyMethod && base._vTbl[c] != (void *)method ) // TOLOOKAT: Module check here?
+ if((void *) method != DummyMethod && base._vTbl[c] != (void *)method && method.methodExternal) // TOLOOKAT: Module check here?
{
External external = method.methodExternal;
OldList * args = MkList();
Identifier id = external.function ? GetDeclId(external.function.declarator) : null;
-
+
// Class class
ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
// char * name
{
char memberTypeString[132] = "TemplateMemberType::";
bool needClass = true;
-
+
param.memberType.OnGetString(memberTypeString + strlen(memberTypeString), null, &needClass);
- ListAdd(args,
- MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null, null), null)),
+ ListAdd(args,
+ MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null, null), null)),
MkExpIdentifier(MkIdentifier(memberTypeString))));
break;
}
{
case type:
{
- char * typeString = param.defaultArgument.templateDatatype ?
+ char * typeString = param.defaultArgument.templateDatatype ?
StringFromSpecDecl(param.defaultArgument.templateDatatype.specifiers, param.defaultArgument.templateDatatype.decl) : null;
char * string = QMkString(typeString);
// TOFIX: UNIONS ARE BROKEN FOR ASSIGNMENTS, USING dataTypeString INSTEAD
// members->Add(MkMemberInit(MkListOne(MkIdentifier("memberString")), MkInitializerAssignment(MkExpString(string))));
- members->Add(MkMemberInit(MkListOne(MkIdentifier("dataTypeString")), MkInitializerAssignment(MkExpString(string))));
+ members->Add(MkMemberInit(MkListOne(MkIdentifier("dataTypeString")), MkInitializerAssignment(MkExpString(string))));
delete string;
break;
//string = QMkString(ui64String);
members->Add(MkMemberInit(ids, MkInitializerAssignment(MkExpConstant(ui64String))));
-
+
delete string;
delete ui64String;
break;
ListAdd(registerModuleBody.compound.statements, stmt);
}
stmt = MkExpressionStmt(MkListOne(
- MkExpCall(MkExpIdentifier(MkIdentifier("eClass_DoneAddingTemplateParameters")),
+ MkExpCall(MkExpIdentifier(MkIdentifier("eClass_DoneAddingTemplateParameters")),
MkListOne(MkExpIdentifier(MkIdentifier("class"))))));
ListAdd(registerModuleBody.compound.statements, stmt);
}
DeclareClass(FindClass(def.designer), className);
*/
- stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(
- MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("designerClass")), '=',
- MkExpString(QMkString(def.designer))))), null);
+ {
+ char * s = QMkString(def.designer);
+ stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(
+ MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("designerClass")), '=',
+ MkExpString(s)))), null);
+ delete s;
+ }
ListAdd(registerModuleBody.compound.statements, stmt);
}
else if(def.type == classNoExpansionClassDef)
}
else if(def.type == designerDefaultPropertyClassDef)
{
+ char * s = QMkString(def.defaultProperty.string);
stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(
MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("defaultProperty")), '=',
- MkExpString(QMkString(def.defaultProperty.string))))), null);
+ MkExpString(s)))), null);
ListAdd(registerModuleBody.compound.statements, stmt);
+ delete s;
}
else if(def.type == classPropertyValueClassDef)
{
- OldList * args = MkList();
- ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
- ListAdd(args, MkExpString(QMkString(def.id.string)));
- ListAdd(args, MkExpCast(MkTypeName(MkListOne(MkSpecifier(INT64)), null), def.initializer.exp));
-
+ classPropValues.Add(ClassPropertyValue { regClass = regClass, id = def.id, exp = def.initializer.exp });
+ def.id = null;
def.initializer.exp = null;
-
- stmt = MkExpressionStmt(MkListOne(
- MkExpCall(MkExpIdentifier(MkIdentifier("ecere::com::eClass_SetProperty")), args)));
-
- ListAdd(registerModuleBody.compound.statements, stmt);
}
}
}
}
}
+class ClassPropertyValue
+{
+ Class regClass;
+ Identifier id;
+ Expression exp;
+
+ ~ClassPropertyValue()
+ {
+ FreeIdentifier(id);
+ }
+};
+
+static List<ClassPropertyValue> classPropValues { };
+
public void ProcessClassDefinitions()
{
External external, next;
{
Specifier specifier;
bool removeExternal = false;
-
+
for(specifier = declaration.specifiers->first; specifier; specifier = specifier.next)
{
- if((specifier.type == enumSpecifier || specifier.type == structSpecifier || specifier.type == unionSpecifier) && specifier.id && specifier.id.string &&
+ if((specifier.type == enumSpecifier || specifier.type == structSpecifier || specifier.type == unionSpecifier) && specifier.id && specifier.id.string &&
(declaration.declMode || specifier.baseSpecs || (specifier.type == enumSpecifier && specifier.definitions)))
{
Symbol symbol = FindClass(specifier.id.string);
ClassType classType;
if(specifier.type == enumSpecifier)
classType = enumClass;
- else
+ else
classType = structClass;
removeExternal = true;
ProcessClass(classType, specifier.definitions, symbol, specifier.baseSpecs, specifier.list,ast, external, declaration.declMode);
}
}
- }
+ }
if(inCompiler && removeExternal)
{
ast->Remove(external);
}
}
}
+
+ // Set the class properties at the very end
+ for(v : classPropValues)
+ {
+ OldList * findClassArgs = MkList();
+ OldList * args = MkList();
+ Statement compoundStmt;
+ String s;
+
+ ListAdd(findClassArgs, MkExpIdentifier(MkIdentifier("module")));
+ s = QMkString(v.regClass.name);
+ ListAdd(findClassArgs, MkExpString(s));
+ delete s;
+
+ ListAdd(args, MkExpIdentifier(MkIdentifier("_class")));
+ s = QMkString(v.id.string);
+ ListAdd(args, MkExpString(s));
+ delete s;
+ ListAdd(args, MkExpCast(MkTypeName(MkListOne(MkSpecifier(INT64)), null), v.exp));
+ compoundStmt = MkCompoundStmt(MkListOne(MkDeclaration(MkListOne(MkSpecifierName("ecere::com::Class")),
+ MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("_class")),
+ MkInitializerAssignment(MkExpCall(MkExpIdentifier(MkIdentifier("ecere::com::eSystem_FindClass")), findClassArgs)))))),
+ MkListOne(MkExpressionStmt(MkListOne(
+ MkExpCall(MkExpIdentifier(MkIdentifier("ecere::com::eClass_SetProperty")), args)))));
+ compoundStmt.compound.context = Context { parent = registerModuleBody.compound.context };
+ ListAdd(registerModuleBody.compound.statements, compoundStmt);
+ }
+
+ classPropValues.Free();
}
}