#include "grammar.h"
extern char * yytext;
-char * defaultNameSpace;
+const char * defaultNameSpace;
int defaultNameSpaceLen;
-public void SetDefaultNameSpace(char * s) { defaultNameSpace = s; defaultNameSpaceLen = s ? strlen(s) : 0; }
+public void SetDefaultNameSpace(const char * s) { defaultNameSpace = s; defaultNameSpaceLen = s ? strlen(s) : 0; }
bool strictNameSpaces;
public void SetStrictNameSpaces(bool b) { strictNameSpaces = b; }
AccessMode declMode = privateAccess;
-public void SetDeclMode(AccessMode accessMode) { declMode = accessMode; }
+AccessMode structDeclMode = privateAccess;
+
+public void SetDeclMode(AccessMode accessMode) { structDeclMode = declMode = accessMode; }
AccessMode defaultDeclMode = privateAccess;
public void SetDefaultDeclMode(AccessMode accessMode) { defaultDeclMode = accessMode; }
-char * currentNameSpace;
+const char * currentNameSpace;
int currentNameSpaceLen;
-public void SetCurrentNameSpace(char * s) { currentNameSpace = s; currentNameSpaceLen = s ? strlen(s) : 0; }
+public void SetCurrentNameSpace(const char * s) { currentNameSpace = s; currentNameSpaceLen = s ? strlen(s) : 0; }
#ifdef _TIMINGS
Time findClassTotalTime;
list.Insert(null, item);
}
-public Identifier MkIdentifier(char * string)
+public Identifier MkIdentifier(const char * string)
{
Identifier id { };
int c;
-
+
id._class = null; // Default class...
if(string)
{
- char * namePart;
+ const char * namePart;
bool gotColon = false;
for(c = strlen(string)-1; c >= 0; c--)
if(string[c] == ':')
else
id.string = CopyString(string);
}
- }
+ }
}
else if(gotColon)
{
public Expression MkExpIdentifier(Identifier id)
{
- return { type = identifierExp, identifier = id };
+ return { type = identifierExp, identifier = id, loc = yylloc };
}
public Expression MkExpDummy()
return exp;
}
-public Expression MkExpConstant(char * string)
+public Expression MkExpConstant(const char * string)
+{
+ return { type = constantExp, constant = CopyString(string), loc = yylloc };
+}
+
+Expression MkExpString(const char * string)
{
- return { type = constantExp, constant = CopyString(string) };
+ return { type = stringExp, string = CopyString(string), loc = yylloc };
}
-Expression MkExpString(char * string)
+Expression MkExpWideString(const char * string)
{
- return { type = stringExp, string = CopyString(string) };
+ return { type = stringExp, string = CopyString(string), loc = yylloc, wideString = true };
}
// TODO: String is case sensitive..
}
};
-Map<ContextStringPair, List<Location> > intlStrings { };
+Map<ContextStringPair, List<Location>> intlStrings { };
-Expression MkExpIntlString(char * string, char * context)
+Expression MkExpIntlString(const char * string, const char * context)
{
- OldList * list = MkList();
if(inCompiler)
{
- ContextStringPair pair { };
- List<Location> list;
- int len = strlen(string);
+ OldList * list = MkList();
+ String s;
+ if(inCompiler)
+ {
+ ContextStringPair pair { };
+ List<Location> list;
+ int len = strlen(string);
- pair.string = new byte[len-2+1]; memcpy(pair.string, string+1, len-2); pair.string[len-2] = '\0';
- if(context) { len = strlen(context); pair.context = new byte[len-2+1]; memcpy(pair.context, context+1, len-2); pair.context[len-2] = '\0'; }
+ pair.string = new byte[len-2+1]; memcpy(pair.string, string+1, len-2); pair.string[len-2] = '\0';
+ if(context) { len = strlen(context); pair.context = new byte[len-2+1]; memcpy(pair.context, context+1, len-2); pair.context[len-2] = '\0'; }
- list = intlStrings[pair];
- if(!list)
- {
- list = { };
- intlStrings[pair] = list;
+ list = intlStrings[pair];
+ if(!list)
+ {
+ list = { };
+ intlStrings[pair] = list;
+ }
+ else
+ {
+ delete pair.string;
+ delete pair.context;
+ }
+ list.Add(yylloc);
}
- else
+ //ListAdd(list, QMkExpId("__thisModule"));
+ s = QMkString(i18nModuleName ? i18nModuleName : "");
+ ListAdd(list, MkExpString(s));
+ delete s;
+ ListAdd(list, MkExpString(string));
+ if(context)
{
- delete pair.string;
- delete pair.context;
+ int lenString = strlen(string), lenContext = strlen(context);
+ char * msgid = new char[lenString-2 + lenContext-2 + 4];
+ msgid[0] = '\"';
+ memcpy(msgid+1, context+1, lenContext-2);
+ msgid[1+lenContext-2] = 4; // EOT
+ memcpy(msgid+1+lenContext-2+1, string+1, lenString-2);
+ memcpy(msgid+1+lenContext-2+1+lenString-2, "\"", 2);
+ ListAdd(list, MkExpString(msgid));
+ delete msgid;
}
- list.Add(yylloc);
- }
- ListAdd(list, QMkExpId("__thisModule"));
- ListAdd(list, MkExpString(string));
- if(context)
- {
- int lenString = strlen(string), lenContext = strlen(context);
- char * msgid = new char[lenString-2 + lenContext-2 + 4];
- msgid[0] = '\"';
- memcpy(msgid+1, context+1, lenContext-2);
- msgid[1+lenContext-2] = 4; // EOT
- memcpy(msgid+1+lenContext-2+1, string+1, lenString-2);
- memcpy(msgid+1+lenContext-2+1+lenString-2, "\"", 2);
- ListAdd(list, MkExpString(msgid));
- delete msgid;
+ else
+ ListAdd(list, QMkExpId("null"));
+ return MkExpCall(QMkExpId("GetTranslatedString"), list);
}
else
- ListAdd(list, QMkExpId("null"));
- return MkExpCall(QMkExpId("GetTranslatedString"), list);
+ {
+ Expression e = MkExpString(string);
+ e.intlString = true;
+ return e;
+ }
}
Expression MkExpOp(Expression exp1, int op, Expression exp2)
Expression MkExpCall(Expression expression, OldList arguments)
{
- return { type = callExp, call.exp = expression, call.arguments = arguments };
+ return { type = callExp, call.exp = expression, call.arguments = arguments, loc = yylloc };
}
Expression MkExpMember(Expression expression, Identifier member)
{
- return { type = memberExp, member.exp = expression, member.member = member };
+ return { type = memberExp, member.exp = expression, member.member = member, loc = yylloc };
}
Expression MkExpPointer(Expression expression, Identifier member)
{
- return { type = pointerExp, member.exp = expression, member.member = member };
+ return { type = pointerExp, member.exp = expression, member.member = member, loc = yylloc };
}
Expression MkExpTypeSize(TypeName typeName)
{
- return { type = typeSizeExp, typeName = typeName };
+ return { type = typeSizeExp, typeName = typeName, loc = yylloc };
}
Expression MkExpTypeAlign(TypeName typeName)
{
- return { type = typeAlignExp, typeName = typeName };
+ return { type = typeAlignExp, typeName = typeName, loc = yylloc };
}
Expression MkExpClassSize(Specifier _class)
{
- return { type = classSizeExp, _class = _class };
+ return { type = classSizeExp, _class = _class, loc = yylloc };
}
Expression MkExpCast(TypeName typeName, Expression expression)
{
- return { type = castExp, cast.typeName = typeName, cast.exp = expression };
+ return { type = castExp, cast.typeName = typeName, cast.exp = expression, loc = yylloc };
}
Expression MkExpCondition(Expression cond, OldList expressions, Expression elseExp)
{
- return { type = conditionExp, cond.cond = cond, cond.exp = expressions, cond.elseExp = elseExp };
+ return { type = conditionExp, cond.cond = cond, cond.exp = expressions, cond.elseExp = elseExp, loc = yylloc };
}
Expression MkExpRenew(Expression memExp, TypeName type, Expression size)
{
- return { type = renewExp, _renew.exp = memExp, _renew.typeName = type, _renew.size = size };
+ return { type = renewExp, _renew.exp = memExp, _renew.typeName = type, _renew.size = size, loc = yylloc };
}
Expression MkExpRenew0(Expression memExp, TypeName type, Expression size)
{
- return { type = renew0Exp, _renew.exp = memExp, _renew.typeName = type, _renew.size = size };
+ return { type = renew0Exp, _renew.exp = memExp, _renew.typeName = type, _renew.size = size, loc = yylloc };
}
Expression MkExpNew(TypeName type, Expression size)
{
- return { type = newExp, _new.typeName = type, _new.size = size };
+ return { type = newExp, _new.typeName = type, _new.size = size, loc = yylloc };
}
Expression MkExpNew0(TypeName type, Expression size)
{
- return { type = new0Exp, _new.typeName = type, _new.size = size };
+ return { type = new0Exp, _new.typeName = type, _new.size = size, loc = yylloc };
}
Expression MkExpVaArg(Expression exp, TypeName type)
{
- return { type = vaArgExp, vaArg.exp = exp, vaArg.typeName = type };
+ return { type = vaArgExp, vaArg.exp = exp, vaArg.typeName = type, loc = yylloc };
}
Specifier MkSpecifier(int specifier)
{
- return { type = baseSpecifier, specifier = specifier };
+ if(specifier == _BOOL && (declMode != defaultAccess && defaultDeclMode != defaultAccess))
+ return MkSpecifierName("bool");
+ else if(specifier == _BOOL || specifier == BOOL)
+ return { type = baseSpecifier, specifier = specifier };
+ else
+ return { type = baseSpecifier, specifier = specifier };
}
Specifier MkSpecifierTypeOf(Expression expression)
Specifier MkEnum(Identifier id, OldList list)
{
- Specifier spec
+ Specifier spec
{
type = enumSpecifier;
id = id;
{
Specifier spec { type = type, id = id };
if(id && FindType(curContext, id.string))
- declMode = defaultAccess;
+ structDeclMode = defaultAccess;
spec.definitions = definitions;
- if(definitions && id && !declMode)
+ if(definitions && id && structDeclMode == defaultAccess)
{
OldList specs { };
Symbol symbol;
next = spec.next;
if(gotType && !declarator && ((spec.type == nameSpecifier && spec.name) || (spec.type == baseSpecifier && gotFullType)))
{
- String s = null;
+ const String s = null;
if(spec.type == nameSpecifier)
{
char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
string = (inst.exp.type == identifierExp) ? CopyString(inst.exp.identifier.string) : null;
type = MkClassTypeSymbol(inst._class.symbol);
};
- symbol.idCode = symbol.id = curContext.nextID++;
if(strstr(symbol.string, "::"))
curContext.hasNameSpace = true;
if(!(curContext.templateTypesOnly ? curContext.parent : curContext).symbols.Add((BTNode)symbol))
{
Declaration decl { type = initDeclaration, declarators = initDeclarators, specifiers = specifiers, loc = yylloc };
bool variable = true;
-
+
if(specifiers != null)
{
bool gotType = false;
if(initDeclarators != null)
{
InitDeclarator d;
-
+
for(d = initDeclarators.first; d; d = d.next)
{
if(GetDeclId(d.declarator).string)
string = CopyString(GetDeclId(d.declarator).string);
type = ProcessType(specifiers, d.declarator);
};
- type.id = type.idCode = curContext.nextID++;
if(!(curContext.templateTypesOnly ? curContext.parent : curContext).types.Add((BTNode)type))
excludedSymbols->Add(type);
{
if((spec.type == nameSpecifier && spec.name) || spec.type == baseSpecifier)
{
- String s = null;
+ const String s = null;
if(spec.type == nameSpecifier)
{
- char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
+ const char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
s = colon ? colon + 2 : spec.name;
}
else if(spec.type == baseSpecifier)
if(s)
{
Symbol type { string = CopyString(s), type = ProcessType(specifiers, null) };
- type.id = type.idCode = curContext.nextID++;
decl.symbol = type;
decl.declarators = initDeclarators = MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier(s)), null));
specifiers.Remove(spec);
variable = false;
break;
}
- else if(spec.type == baseSpecifier &&
+ else if(spec.type == baseSpecifier &&
(spec.specifier == STRUCT || spec.specifier == UNION))
variable = false;
else
{
if(gotType && initDeclarators == null && !spec.next && ((spec.type == nameSpecifier && spec.name) || spec.type == baseSpecifier))
{
- String s = null;
+ const String s = null;
if(spec.type == nameSpecifier)
{
char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
delete id.string;
id.string = CopyString(name);
}
-
+
// Avoid memory leaks on duplicated symbols (BinaryTree::Add Would Fail)
symbol = (Symbol)(curContext.templateTypesOnly ? curContext.parent : curContext).symbols.FindString(id.string);
if(!symbol)
symbol.type.freeExp = true;
}
}
- symbol.id = symbol.idCode = curContext.nextID++;
}
decl.symbol = d.declarator.symbol = symbol;
}
else
{
decl.symbol = Symbol { };
- decl.symbol.id = decl.symbol.idCode = curContext.nextID++;
excludedSymbols->Add(decl.symbol);
}
return decl;
next = spec.next;
if(gotType && declarators == null && ((spec.type == nameSpecifier && spec.name) || spec.type == baseSpecifier))
{
- String s = null;
+ const String s = null;
if(spec.type == nameSpecifier)
{
- char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
+ const char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
s = colon ? colon + 2 : spec.name;
}
else if(spec.type == baseSpecifier)
Specifier spec = tn.qualifiers ? tn.qualifiers->first : null;
if(!tn.declarator && !tn.prev && !tn.next && spec && !spec.next && spec.type == baseSpecifier && spec.specifier == VOID);
else
- Compiler_Error("parameter name omitted\n");
+ Compiler_Error($"parameter name omitted\n");
break;
}
}
if(!context.symbols.Add((BTNode)symbol))
excludedSymbols->Add(symbol);
- // TODO: Fix this, the parameters' IDs should really be smaller...
- symbol.id = context.nextID++;
param.declarator.symbol = symbol;
}
}
id.string = CopyString(name);
}
symbol = Symbol { string = CopyString(id.string), type = ProcessType(func.specifiers, declarator) };
- symbol.idCode = symbol.id = globalContext.nextID++;
if(strstr(symbol.string, "::"))
globalContext.hasNameSpace = true;
if(!globalContext.symbols.Add((BTNode)symbol))
for(spec = function.specifiers->first; spec; spec = spec.next)
if(spec.type == baseSpecifier && spec.specifier == STATIC)
{
- declMode = staticAccess;
+ structDeclMode = declMode = staticAccess;
break;
}
}
External MkExternalDeclaration(Declaration declaration)
{
External external { type = declarationExternal, declaration = declaration, symbol = declaration ? declaration.symbol : null };
- InitDeclarator d = (declaration && declaration.declarators) ? declaration.declarators->last : null;
if(declaration && declaration.type == initDeclaration && declaration.specifiers)
{
Specifier spec;
for(spec = declaration.specifiers->first; spec; spec = spec.next)
if(spec.type == baseSpecifier && spec.specifier == TYPEDEF)
{
- declMode = defaultAccess;
+ structDeclMode = declMode = defaultAccess;
break;
}
else if(spec.type == baseSpecifier && spec.specifier == STATIC)
{
- declMode = staticAccess;
+ structDeclMode = declMode = staticAccess;
break;
}
}
fileInput = backFileInput;
if(fileInput)
{
- fileInput.Seek(yylloc.start.pos, start);
+ fileInput.Seek(yylloc.start.pos, start);
resetScannerPos(&yylloc.start);
yychar = -2;
}
if(!symbol && spec.symbol)
{
// If class was only decl'ed, invoke DeclClass on this templated class as well
- symbol = _DeclClass(MAXINT, templateString);
+ symbol = _DeclClass(null, templateString);
+ symbol.notYetDeclared = true;
}
// Add a reference to all templated class to the basic class
if(spec.symbol)
FreeList(templateArgs, FreeTemplateArgument);
}
-Specifier _MkSpecifierName(char * name, Symbol symbol, OldList templateArgs)
+Specifier _MkSpecifierName(const char * name, Symbol symbol, OldList templateArgs)
{
Specifier spec { type = nameSpecifier };
}
}
else if(symbol)
- spec.name = CopyString(symbol.string);
+ {
+ char nameSpace[1024];
+ char * c = strstr(name, symbol.string);
+ spec.name = CopyString(symbol.string);
+ if(c && c >= name + 2 && c[-1] == ':' && c[-2] == ':')
+ {
+ if(c > name + 2)
+ {
+ memcpy(nameSpace, name, c - name - 2);
+ nameSpace[c-name] = 0;
+ spec.nsSpec = _MkSpecifierName(nameSpace, null, null);
+ }
+ else
+ spec.nsSpec = _MkSpecifierName(null, null, null);
+ }
+ }
else
spec.name = CopyString(name);
spec.symbol = symbol;
return spec;
}
-public Specifier MkSpecifierName(char * name)
+public Specifier MkSpecifierName(const char * name)
{
return _MkSpecifierName(name, null, null);
}
-public Specifier MkSpecifierNameArgs(char * name, OldList * templateArgs)
+public Specifier MkSpecifierNameArgs(const char * name, OldList * templateArgs)
{
return _MkSpecifierName(name, null, templateArgs);
}
/*
-Specifier MkClassName(char * string)
+Specifier MkClassName(const char * string)
{
return { type = SpecifierClass, name = CopyString(string) };
}
isParam = true;
};
- // TODO: Fix this, the parameters' IDs should really be smaller...
- symbol.idCode = symbol.id = context.nextID++;
if(!context.symbols.Add((BTNode)symbol))
excludedSymbols->Add(symbol);
symbol = Symbol
{
-
+
};
{
symbolSpecs->Add(CopySpecifier(spec));
}
symbol.type = ProcessType(symbolSpecs, decl);
- symbol.idCode = symbol.id = globalContext.nextID++;
decl.symbol = symbol;
excludedSymbols->Add(symbol);
}
FreeList(specs, FreeSpecifier);
-
+
if(!spec)
{
Compiler_Error($"Expecting class specifier\n");
return { type = classDataClassDef, decl = decl };
}
-ClassDef MkClassDefDesigner(char * designer)
+ClassDef MkClassDefDesigner(const char * designer)
{
return { type = classDesignerClassDef, designer = CopyString(designer) };
}
return def;
}
-Symbol DeclClassAddNameSpace(int symbolID, char * className)
+Symbol DeclClassAddNameSpace(Specifier _class, const char * className)
{
char name[1024];
int len = 0, stringLen;
name[0] = '\0';
- if((currentNameSpace || defaultNameSpace) && declMode != defaultAccess && defaultDeclMode != defaultAccess)
+ if(className[0] != ':' && (currentNameSpace || defaultNameSpace) && declMode != defaultAccess && defaultDeclMode != defaultAccess && (!_class || _class.name))
{
if(defaultNameSpace)
{
memcpy(name + len, className, stringLen);
len += stringLen;
name[len] = 0;
- return _DeclClass(symbolID, name);
+ return _DeclClass(_class, name);
}
-Symbol DeclClass(int symbolID, char * name)
+Symbol DeclClass(Specifier _class, const char * name)
{
- if(strchr(name, ':'))
- return _DeclClass(symbolID, name);
+ if(_class || strchr(name, ':'))
+ return _DeclClass(_class, name);
else
- return DeclClassAddNameSpace(symbolID, name);
+ return DeclClassAddNameSpace(_class, name);
}
-Symbol _DeclClass(int symbolID, char * name)
+Symbol _DeclClass(Specifier _class, const char * name)
{
- Symbol symbol = FindClass(name);
+ Symbol symbol;
+ char nameBuffer[1024];
+ if(_class)
+ {
+ strcpy(nameBuffer, _class.name ? _class.name : "");
+ strcat(nameBuffer, "::");
+ strcat(nameBuffer, name);
+ name = nameBuffer;
+ }
+
+ symbol = FindClass(name);
if(!symbol)
{
/*
for(classContext = curContext; classContext && !classContext.classDef; classContext = classContext.parent);
if(classContext)
{
-
+
}
*/
if(name[0] == ':' && name[1] == ':')
symbol = Symbol
{
string = CopyString(name);
- idCode = symbolID, id = symbolID;
+ notYetDeclared = true;
};
if(!globalContext.classes.Add((BTNode)symbol))
excludedSymbols->Add(symbol);
symbol.shortName = CopyString(name + start);
}
}
- if(symbolID)
- symbol.idCode = symbol.id = symbolID;
return symbol;
}
strcpy(name, ((Specifier)baseSpecs.first).name);
tpl = strchr(name, '<');
if(tpl) *tpl = 0;
-
+
baseClass = FindClass(name);
- if(baseClass.ctx)
+ if(baseClass && baseClass.ctx)
{
TemplatedType copy;
for(copy = (TemplatedType)baseClass.ctx.templateTypes.first; copy; copy = (TemplatedType)copy.next)
delete type;
}
}
- else if(baseClass.registered)
+ else if(baseClass && baseClass.registered)
{
Class sClass;
for(sClass = baseClass.registered; sClass; sClass = sClass.base)
{
p.param = param = TemplateParameter
{
- identifier = MkIdentifier(p.name), type = p.type,
+ identifier = MkIdentifier(p.name), type = p.type,
dataTypeString = p.dataTypeString /*, dataType = { specs, decl }*/
};
}
delete symbol.ctx;
}
symbol.ctx = curContext;
- classDef = { symbol = symbol, _class = MkSpecifierName /*MkClassName*/(symbol.string), baseSpecs = baseSpecs, definitions = definitions, nameLoc = symbol.nameLoc };
+ classDef = { symbol = symbol, _class = MkSpecifierName(symbol.string), baseSpecs = baseSpecs, definitions = definitions, nameLoc = symbol.nameLoc };
curContext.classDef = classDef;
return classDef;
}
string = CopyString(id.string);
type = type;
};
- symbol.idCode = symbol.id = globalContext.nextID++;
excludedSymbols->Add(symbol);
- globalContext.nextID++;
- globalContext.nextID++;
prop.symbol = symbol;
return prop;
}
ClassDef MkClassDefProperty(PropertyDef propertyDef)
{
- return { type = propertyClassDef, propertyDef = propertyDef };
+ return { type = propertyClassDef, propertyDef = propertyDef, loc = yylloc };
}
ClassDef MkClassDefClassProperty(PropertyDef propertyDef)
{
- return { type = classPropertyClassDef, propertyDef = propertyDef };
+ return { type = classPropertyClassDef, propertyDef = propertyDef, loc = yylloc };
}
ClassDef MkClassDefClassPropertyValue(Identifier id, Initializer initializer)
{
- return { type = classPropertyValueClassDef, id = id, initializer = initializer };
+ return { type = classPropertyValueClassDef, id = id, initializer = initializer, loc = yylloc };
}
-int CheckType(char * text)
+int CheckType(const char * text)
{
#ifdef _TIMINGS
Time startTime = GetTime();
curContext = ctx.parent;
}
-Symbol FindType(Context ctx, char * name)
+Symbol FindType(Context ctx, const char * name)
{
Symbol type = null;
- if(curContext)
+ if(ctx)
{
//char output[8192];
type = (Symbol)ctx.types.FindString(name);
return type;
}
-TemplatedType FindTemplateTypeParameter(Context ctx, char * name)
+Symbol FindStruct(Context ctx, const char * name)
+{
+ Symbol type = null;
+ if(ctx)
+ {
+ type = (Symbol)ctx.structSymbols.FindString(name);
+ if(!type && ctx.parent)
+ type = FindStruct(ctx.parent, name);
+ }
+ return type;
+}
+
+TemplatedType FindTemplateTypeParameter(Context ctx, const char * name)
{
TemplatedType templatedType = null;
if(curContext)
bool ModuleAccess(Module searchIn, Module searchFor)
{
SubModule subModule;
-
+
if(searchFor == searchIn)
return true;
break;
if(!module)
{
- module = ModuleImport
- {
+ module = ModuleImport
+ {
name = CopyString(moduleToFind.name), importType = moduleToFind.importType,
importAccess = ModuleAccess(privateModule, moduleToFind) ? publicAccess : privateAccess
};
{
GetFullClassNameSpace(ns->parent, name);
strcat(name, ns->name);
- strcat(name, "::");
+ strcat(name, "::");
}
}
}
*/
-public Symbol FindClass(char * name)
+public Symbol FindClass(const char * name)
{
-#ifdef _DEBUG
+#ifdef _TIMINGS
Time startTime = GetTime();
#endif
Symbol cl = null;
}
*/
if(cl.shortName && !strcmp(cl.shortName, name))
- break;
+ break;
}
#ifdef _TIMINGS
findClassIgnoreNSTotalTime += GetTime() - startTime;
{
string = CopyString(name);
registered = _class;
- id = MAXINT;
- idCode = MAXINT;
+ notYetDeclared = true;
imported = true;
};
_class.symbol = cl;
void CopyTypeInto(Type type, Type src)
{
type = *src;
+
type.name = CopyString(src.name);
+ type.typeName = CopyString(src.typeName);
type.refCount = 1;
if(src.kind == enumType)
{
- NamedLink member;
+ NamedLink64 member;
type.members.Clear();
// This must have been a mistake: member = **type**.members.first
for(member = src.members.first; member; member = member.next)
{
- type.members.Add(NamedLink { name = CopyString(member.name), data = member.data });
+ type.members.Add(NamedLink64 { name = CopyString(member.name), data = member.data });
}
type.enumName = CopyString(src.enumName);
}
if(type.arraySizeExp)
type.arraySizeExp = CopyExpression(type.arraySizeExp);
}
-
}
}
ExtDecl extDecl = spec.extDecl;
if(extDecl.type == extDeclString)
{
- String s = spec.extDecl.s;
if(!strcmp(spec.extDecl.s, "__declspec(dllexport)") || !strcmp(spec.extDecl.s, "dllexport"))
specType.dllExport = true;
else if(!strcmp(spec.extDecl.s, "__declspec(stdcall)") || !strcmp(spec.extDecl.s, "stdcall"))
else if(spec.specifier == VOID) specType.kind = voidType;
else if(spec.specifier == CHAR) specType.kind = charType;
else if(spec.specifier == INT) { if(specType.kind != shortType && specType.kind != longType && !isLong) specType.kind = intType; }
+ else if(spec.specifier == _BOOL || spec.specifier == BOOL)
+ specType.kind = _BoolType;
else if(spec.specifier == UINT) { if(specType.kind != shortType && specType.kind != longType) specType.kind = intType; specType.isSigned = false; }
else if(spec.specifier == INT64) specType.kind = int64Type;
- else if(spec.specifier == VALIST)
+ else if(spec.specifier == VALIST)
specType.kind = vaListType;
else if(spec.specifier == SHORT) specType.kind = shortType;
- else if(spec.specifier == LONG)
+ else if(spec.specifier == LONG)
{
if(isLong || (targetBits == 64 && targetPlatform != win32))
specType.kind = int64Type;
else if(spec.specifier == CONST)
specType.constant = true;
else if(spec.specifier == TYPED_OBJECT || spec.specifier == ANY_OBJECT || spec.specifier == CLASS)
- {
+ {
switch(spec.specifier)
{
case TYPED_OBJECT: specType.classObjectType = typedObject; break;
Symbol symbol = spec.name ? FindType(curContext, spec.name) : null;
if(symbol && symbol.type)
{
+ // Keep constant qualifier
+ bool isConstant = specType.constant;
// Free Type Contents:
Type dummy { };
*dummy = *specType;
FreeType(dummy);
CopyTypeInto(specType, symbol.type);
+ specType.constant = isConstant;
+ delete specType.typeName;
specType.typeName = CopyString(symbol.type.name);
}
else if(!isTypedef) // !specType.kind) // TESTING THIS FOR enum / typedef problem
if(spec.list)
{
Enumerator e;
- int nextValue = 0;
for(e = spec.list->first; e; e = e.next)
{
- // TOFIX: NamedItem i { } causes cryptic error, bad .c!
- NamedLink i { name = CopyString(e.id.string) };
+ NamedLink64 i { name = CopyString(e.id.string) };
+ if(e.exp && e.exp.type == constantExp && e.exp.constant)
+ i.data = strtoll(e.exp.constant, null, 0);
specType.members.Add(i);
}
}
Symbol _class = spec.id ? FindClass(spec.id.string) : null;
if(_class)
{
+ specType.declaredWithStruct = true;
if(!_class.registered || _class.registered.type != structClass)
- specType.directClassAccess = true;
+ specType.directClassAccess = true; // TODO: Need to clarify what 'directClassAccess' is about
specType._class = _class;
specType.kind = classType;
break;
specType.kind = unionType;
if(spec.id)
{
- // TESTING THIS HERE... Had 0 type size
+ // TESTING THIS HERE... Had 0 type size
if(!spec.definitions && !isTypedef)
{
Symbol symbol = spec.id.string ? FindSymbol(spec.id.string, curContext, globalContext, true, false) : null;
if(symbol.type.kind == enumType)
{
- NamedLink member;
+ NamedLink64 member;
specType.members.Clear();
for(member = symbol.type.members.first; member; member = member.next)
{
- NamedLink item { name = CopyString(member.name), data = member.data };
+ NamedLink64 item { name = CopyString(member.name), data = member.data };
specType.members.Add(item);
}
}
}
else if(spec.type == subClassSpecifier)
{
- specType.kind = specType.kind = subClassType;
+ specType.kind = subClassType;
specType._class = spec._class.symbol;
}
}
}
else if(assumeEllipsis)
specType.kind = ellipsisType;
- return specType;
+ return specType;
}
static Type ProcessTypeDecls(OldList specs, Declarator decl, Type parentType)
{
type = { refCount = 1, kind = arrayType, arraySizeExp = CopyExpression(decl.array.exp), freeExp = true, type = type, dllExport = type.dllExport, attrStdcall = type.attrStdcall };
if(decl.array.enumClass)
- type.enumClass = decl.array.enumClass.symbol;
+ type.enumClass = decl.array.enumClass.symbol;
break;
}
case pointerDeclarator:
return ProcessTypeDecls(specs, decl, null);
}
-public Type ProcessTypeString(char * string, bool staticMethod)
+public Type ProcessTypeString(const char * string, bool staticMethod)
{
OldList * specs = MkList();
Declarator decl = SpecDeclFromString(string, specs, null);
return null;
}
-public Type MkClassType(char * name)
+public Type MkClassType(const char * name)
{
if(name)
{
return null;
}
-AsmField MkAsmField(char * command, Expression expression)
+AsmField MkAsmField(char * command, Expression expression, Identifier symbolic)
{
- return { command = command, expression = expression };
+ return { command = command, expression = expression, symbolic = symbolic };
}
Statement MkAsmStmt(Specifier spec, char * statements, OldList inputFields, OldList outputFields, OldList clobberedFields)
{
- return { type = asmStmt, asmStmt.spec = spec, asmStmt.statements = statements,
- asmStmt.inputFields = inputFields, asmStmt.outputFields = outputFields,
+ return { type = asmStmt, asmStmt.spec = spec, asmStmt.statements = statements,
+ asmStmt.inputFields = inputFields, asmStmt.outputFields = outputFields,
asmStmt.clobberedFields = clobberedFields };
}
return { type = arrayExp, list = expressions };
}
-Expression GetTemplateArgExpByName(char * paramName, Class curClass, TemplateParameterType tplType)
+Expression GetTemplateArgExpByName(const char * paramName, Class curClass, TemplateParameterType tplType)
{
Expression argExp = null;
Class _class = curClass ? curClass : ((curExternal && curExternal.type == functionExternal && curExternal.function) ? curExternal.function._class : null);
{
char idString[32];
char className[1024];
- Expression classExp;
-
+
sprintf(idString, "%d", id);
strcpy(className, "__ecereClass_");
FullClassNameCat(className, _class.fullName, true);
- MangleClassName(className);
- DeclareClass(FindClass(_class.fullName), className);
+ DeclareClass(curExternal, FindClass(_class.fullName), className);
argExp = MkExpIndex((/*pointer ? MkExpPointer : */MkExpMember)
- (MkExpMember(MkExpIdentifier(MkIdentifier("this")), MkIdentifier("_class")) /*MkExpIdentifier(MkIdentifier(className))*/,
+ (MkExpMember(MkExpIdentifier(MkIdentifier("this")), MkIdentifier("_class")) /*MkExpIdentifier(MkIdentifier(className))*/,
MkIdentifier("templateArgs")), MkListOne(MkExpConstant(idString)));
}
}
- return argExp;
+ return argExp;
}
Expression GetTemplateArgExp(TemplateParameter param, Class curClass, bool pointer)
return param.identifier ? GetTemplateArgExpByName(param.identifier.string, curClass, type) : null;
}
-/*char * CreateMsgID(char * string, char * context)
+/*char * CreateMsgID(const char * string, const char * context)
{
int lenString = strlen(string), lenContext = strlen(context);
char * msgid = new char[lenString + lenContext + 20];
{
if(intlStrings.count)
{
- char * srcFile = GetSourceFile();
- char * objFile = GetOutputFile();
+ const char * srcFile = GetSourceFile();
+ const char * objFile = GetOutputFile();
char srcFileFixed[MAX_LOCATION];
char potFile[MAX_LOCATION];
File f;
f = FileOpen(potFile, write);
if(f)
{
- char * filePrefix = "";
+ const char * filePrefix = "";
if(!(srcFile[0] && (srcFile[1] == ':' || srcFile[0] == '/')))
- filePrefix = "./"; //(GetRuntimePlatform() == win32) ? ".\\" : "./";
+ filePrefix = "./"; //(__runtimePlatform == win32) ? ".\\" : "./";
// GetSystemPathBuffer(srcFileFixed, srcFile);
GetSlashPathBuffer(srcFileFixed, srcFile);
+
for(s : intlStrings)
{
// TOFIX: (#654) ContextStringPair * pair = &s;