//if(inCompiler)
{
- /*FunctionDefinition*/ function = MkFunction(func.specifiers, func.declarator, null);
+ /*FunctionDefinition*/ function = _MkFunction(func.specifiers, func.declarator, null, false);
function.propSet = func.propSet;
+ function.type = func.type;
+ 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
// Mark typed_object/any_object parameters as such according to method type
Type typeParam;
Declarator funcDecl = GetFuncDecl(func.declarator);
- if(funcDecl.function.parameters)
+ if(funcDecl.function.parameters && funcDecl.function.parameters->first)
{
TypeName param = funcDecl.function.parameters->first;
- for(typeParam = methodDataType.params.first; typeParam; typeParam = typeParam.next)
+ for(typeParam = methodDataType.params.first; typeParam && param; typeParam = typeParam.next)
{
if(typeParam.classObjectType)
{
if(param.declarator && param.declarator.symbol)
param.declarator.symbol.type.classObjectType = typeParam.classObjectType;
}
- param = param.next;
+ param = param ? param.next : null;
}
}
}
{
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);
//strcpy(moduleName, argv[2]);
StripExtension(moduleName);
- ChangeCh(moduleName, '.', '_');
- ChangeCh(moduleName, ' ', '_');
- ChangeCh(moduleName, '-', '_');
+ FixModuleName(moduleName);
sprintf(registerName, "__ecereRegisterModule_%s", moduleName);
declarator = MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(registerName)),
MkListOne(moduleParam));
{
- FunctionDefinition function = MkFunction(specifiers, declarator, null);
+ FunctionDefinition function = _MkFunction(specifiers, declarator, null, false);
ProcessFunctionBody(function, registerModuleBody);
function.declMode = defaultAccess;
if(!ast) ast = MkList();
// 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);
StripExtension(moduleName);
- ChangeCh(moduleName, '.', '_');
- ChangeCh(moduleName, ' ', '_');
- ChangeCh(moduleName, '-', '_');
+ FixModuleName(moduleName);
//strcpy(moduleName, argv[2]);
sprintf(registerName, "__ecereUnregisterModule_%s", moduleName);
MkListOne(moduleParam));
{
- FunctionDefinition function = MkFunction(specifiers, declarator, null);
+ FunctionDefinition function = _MkFunction(specifiers, declarator, null, false);
ProcessFunctionBody(function, unregisterModuleBody);
function.declMode = defaultAccess;
if(!ast) ast = MkList();
int privateID = 0;
bool privateMembers = false;
- sprintf(dataMemberSize, "%d", sizeof(DataMember));
+ sprintf(dataMemberSize, "%d", (int)sizeof(DataMember));
if(!isMember)
{
for(prop = regClass.conversions.first; prop; prop = prop.next)
MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null,null), null)), MkExpIdentifier(MkIdentifier(name))))));
ListAdd(registerModuleBody.compound.statements, stmt);
}
- if(((Symbol)prop.symbol).propCategory)
+ if(prop.symbol && ((Symbol)prop.symbol).propCategory)
{
stmt = MkExpressionStmt(MkListOne(
MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier(nameM)), MkIdentifier("category")), '=',
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);
}
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));
//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
// uint value
{
char temp[1024];
- sprintf(temp, "%d", value.data);
+ // TODO: Support 64 bit enums
+ sprintf(temp, "%d", (int)value.data);
ListAdd(args, MkExpConstant(temp));
}
{
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);
}
}
else if(external.type == functionExternal)
{
+ bool setStaticMethod = false;
// Mark
- if(external.symbol && !external.symbol.type.thisClass)
+ if(external.symbol && !external.symbol.type.thisClass && !external.symbol.type.staticMethod)
+ {
+ // TOCHECK: Where do we actually need this to be set?
external.symbol.type.staticMethod = true;
+ setStaticMethod = true;
+ }
if(inCompiler)
{
{
char * string;
char type[1024] = "";
+ // We don't want functions to be marked as static methods
+ if(setStaticMethod)
+ function.declarator.symbol.type.staticMethod = false;
PrintType(function.declarator.symbol.type, type, true, true);
+ if(setStaticMethod)
+ function.declarator.symbol.type.staticMethod = true;
string = QMkString(type);
ListAdd(args, MkExpString(string));
delete string;
{
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);