if(identifier.string)
{
TemplateParameter param { type = TemplateParameterType::type, identifier = identifier, dataType = baseTplDatatype, defaultArgument = defaultArgument };
- TemplatedType type { key = (uint)identifier.string, param = param };
+ TemplatedType type { key = (uintptr)identifier.string, param = param };
if(!curContext.templateTypes.Add((BTNode)type))
delete type;
return param;
return { type = typeSizeExp, typeName = typeName };
}
+Expression MkExpTypeAlign(TypeName typeName)
+{
+ return { type = typeAlignExp, typeName = typeName };
+}
+
Expression MkExpClassSize(Specifier _class)
{
return { type = classSizeExp, _class = _class };
return { type = subClassSpecifier, _class = _class };
}
-Specifier MkSpecifierExtended(char * name)
+Specifier MkSpecifierExtended(ExtDecl extDecl)
{
- return { type = extendedSpecifier, name = CopyString(name) };
+ return { type = extendedSpecifier, extDecl = extDecl /*name = CopyString(name)*/ };
}
Specifier MkEnum(Identifier id, OldList list)
}
}
+Attribute MkAttribute(String attr, Expression exp)
+{
+ return { attr = attr, exp = exp };
+}
+
+Attrib MkAttrib(int type, OldList * attribs)
+{
+ return { type = type, attribs = attribs };
+}
+
+ExtDecl MkExtDeclString(String s)
+{
+ return { type = extDeclString, s = s };
+
+}
+
+ExtDecl MkExtDeclAttrib(Attrib attr)
+{
+ return { type = extDeclAttrib, attr = attr };
+}
+
+
public Declarator MkDeclaratorIdentifier(Identifier id)
{
return { type = identifierDeclarator, identifier = id };
return { type = functionDeclarator, declarator = declarator, function.parameters = parameters };
}
-Declarator MkDeclaratorExtended(char * extended, Declarator declarator)
+Declarator MkDeclaratorExtended(ExtDecl extended, Declarator declarator)
{
return { type = extendedDeclarator, declarator = declarator, extended.extended = extended };
}
-Declarator MkDeclaratorExtendedEnd(char * extended, Declarator declarator)
+Declarator MkDeclaratorExtendedEnd(ExtDecl extended, Declarator declarator)
{
return { type = extendedDeclaratorEnd, declarator = declarator, extended.extended = extended };
}
return { qualifiers = qualifiers, declarator = declarator };
}
+public TypeName MkTypeNameGuessDecl(OldList qualifiers, Declarator declarator)
+{
+ TypeName typeName { qualifiers = qualifiers, declarator = declarator };
+ if(qualifiers != null)
+ {
+ bool gotType = false;
+ bool gotFullType = false;
+ Specifier spec;
+ for(spec = qualifiers.first; spec; spec = spec.next)
+ {
+ if(gotType && !declarator && ((spec.type == nameSpecifier && spec.name) || (spec.type == baseSpecifier && gotFullType)))
+ {
+ String s = null;
+ if(spec.type == nameSpecifier)
+ {
+ char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
+ s = colon ? colon + 2 : spec.name;
+ }
+ else if(spec.type == baseSpecifier)
+ {
+ if(spec.specifier == INT64) s = "int64";
+ }
+ if(s)
+ {
+ typeName.declarator = declarator = MkDeclaratorIdentifier(MkIdentifier(CopyString(s)));
+ qualifiers.Remove(spec);
+ FreeSpecifier(spec);
+ }
+ }
+ if(spec.type != extendedSpecifier)
+ {
+ if(spec.type != baseSpecifier || (spec.specifier != UNSIGNED && spec.specifier != SIGNED && spec.specifier != LONG))
+ gotFullType = true;
+ gotType = true;
+ }
+ }
+ }
+ return typeName;
+}
+
public Identifier GetDeclId(Declarator decl)
{
while(decl && decl.type != identifierDeclarator)
if(!eSystem_FindDefine(privateModule, id.string))
eSystem_RegisterDefine(id.string, expString, privateModule, buildingECERECOMModule ? baseSystemAccess : publicAccess);
else
- Compiler_Warning("Redefinition of %s ignored\n", id.string);
+ Compiler_Warning($"Redefinition of %s ignored\n", id.string);
return decl;
}
if(specifiers != null)
{
+ bool gotType = false;
Specifier spec;
for(spec = specifiers.first; spec; spec = spec.next)
{
}
else if(spec.next)
{
- for(; spec; spec = spec.next)
+ //for(spec = spec.next; spec; spec = spec.next)
+ spec = specifiers.last;
{
- if(spec.type == nameSpecifier && spec.name)
+ if((spec.type == nameSpecifier && spec.name) || spec.type == baseSpecifier)
{
- Symbol type
+ String s = null;
+ if(spec.type == nameSpecifier)
{
- string = CopyString(spec.name);
- type = ProcessType(specifiers, null);
- };
- type.id = type.idCode = curContext.nextID++;
- if(!(curContext.templateTypesOnly ? curContext.parent : curContext).types.Add((BTNode)type))
- excludedSymbols->Add(type);
-
- decl.symbol = type;
+ char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
+ s = colon ? colon + 2 : spec.name;
+ }
+ else if(spec.type == baseSpecifier)
+ {
+ if(spec.specifier == INT64) s = "int64";
+ }
+ 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(CopyString(s))), null));
+ specifiers.Remove(spec);
+ FreeSpecifier(spec);
+ if(!(curContext.templateTypesOnly ? curContext.parent : curContext).types.Add((BTNode)type))
+ excludedSymbols->Add(type);
+ }
}
}
}
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;
+ if(spec.type == nameSpecifier)
+ {
+ char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
+ s = colon ? colon + 2 : spec.name;
+ }
+ else if(spec.type == baseSpecifier)
+ {
+ if(spec.specifier == INT64) s = "int64";
+ }
+ if(s)
+ {
+ decl.declarators = initDeclarators = MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier(CopyString(s))), null));
+ specifiers.Remove(spec);
+ FreeSpecifier(spec);
+ }
+ }
+ }
+ if(spec.type != extendedSpecifier)
+ gotType = true;
}
}
if(variable && initDeclarators)
Declaration MkStructDeclaration(OldList specifiers, OldList declarators, Specifier extStorage)
{
- return { type = structDeclaration, declarators = declarators, specifiers = specifiers, extStorage = extStorage, loc = yylloc };
+ Declaration decl { type = structDeclaration, declarators = declarators, specifiers = specifiers, extStorage = extStorage, loc = yylloc };
+ if(specifiers != null)
+ {
+ bool gotType = false;
+ Specifier spec;
+ for(spec = specifiers.first; spec; spec = spec.next)
+ {
+ if(gotType && declarators == null && ((spec.type == nameSpecifier && spec.name) || spec.type == baseSpecifier))
+ {
+ String s = null;
+ if(spec.type == nameSpecifier)
+ {
+ char * colon = RSearchString(spec.name, "::", strlen(spec.name), true, false);
+ s = colon ? colon + 2 : spec.name;
+ }
+ else if(spec.type == baseSpecifier)
+ {
+ if(spec.specifier == INT64) s = "int64";
+ }
+ if(s)
+ {
+ decl.declarators = declarators = MkListOne(MkDeclaratorIdentifier(MkIdentifier(CopyString(s))));
+ specifiers.Remove(spec);
+ FreeSpecifier(spec);
+ }
+ }
+ if(spec.type != extendedSpecifier)
+ gotType = true;
+ }
+ }
+ return decl;
}
Statement MkLabeledStmt(Identifier id, Statement statement)
if(!spec)
{
- Compiler_Error("Expecting class specifier\n");
+ Compiler_Error($"Expecting class specifier\n");
inst._class = MkSpecifierName /*MkClassName*/("");
//exit(1);
//return null;
dataTypeString = p.dataTypeString /*, dataType = { specs, decl }*/
};
}
- type = TemplatedType { key = (uint)p.name, param = param };
+ type = TemplatedType { key = (uintptr)p.name, param = param };
if(!curContext.templateTypes.Add((BTNode)type))
delete type;
}
SetupBaseSpecs(symbol, baseSpecs);
if(symbol.ctx)
{
+ ClassDefinition classDef = symbol.ctx.classDef;
+ if(classDef)
+ {
+ // This can occur if two instances of a class are defined...
+ // To avoid dangling 'parent' Contexts, we free the previous class definition
+ External external;
+ for(external = ast->first; external; external = external.next)
+ {
+ if(external.type == classExternal && external._class == classDef)
+ {
+ ast->Remove(external);
+ FreeExternal(external);
+ break;
+ }
+ }
+ }
FreeContext(symbol.ctx);
delete symbol.ctx;
}
Symbol type = null;
if(curContext)
{
+ //char output[8192];
type = (Symbol)ctx.types.FindString(name);
+ /*if(!strcmp(name, "intptr_t") && !type)
+ {
+ ctx.types.Print(output, depthOrder);
+ puts(output);
+ }*/
if(!type && ctx.parent)
type = FindType(ctx.parent, name);
}
if(decl.structDecl.exp.type == constantExp)
specType.bitFieldCount = strtoul(decl.structDecl.exp.constant, null, 0);
}
- if((decl.type == extendedDeclarator || decl.type == extendedDeclaratorEnd) && decl.extended.extended &&
- (!strcmp(decl.extended.extended, "__declspec(dllexport)") || !strcmp(decl.extended.extended, "dllexport")))
+ if((decl.type == extendedDeclarator || decl.type == extendedDeclaratorEnd) && decl.extended.extended && decl.extended.extended.type == extDeclString &&
+ decl.extended.extended.s && (!strcmp(decl.extended.extended.s, "__declspec(dllexport)") || !strcmp(decl.extended.extended.s, "dllexport")))
{
dllExport = true;
}
- if((decl.type == extendedDeclarator || decl.type == extendedDeclaratorEnd) && decl.extended.extended &&
- (strstr(decl.extended.extended, "__attribute__")))
+ if((decl.type == extendedDeclarator || decl.type == extendedDeclaratorEnd) && decl.extended.extended && decl.extended.extended.type == extDeclAttrib)
{
specType.keepCast = true;
}
bool isLong = false;
for(spec = specs.first; spec; spec = spec.next)
{
- if(spec.type == extendedSpecifier && (!strcmp(spec.name, "__declspec(dllexport)") || !strcmp(spec.name, "dllexport")))
+ if(spec.type == extendedSpecifier && spec.extDecl && spec.extDecl.type == extDeclString && spec.extDecl.s && (!strcmp(spec.extDecl.s, "__declspec(dllexport)") || !strcmp(spec.extDecl.s, "dllexport")))
{
dllExport = true;
}
- if(spec.type == extendedSpecifier && strstr(spec.name, "__attribute__"))
+ if(spec.type == extendedSpecifier && spec.extDecl.type == extDeclAttrib)
{
specType.keepCast = true;
}
}
else if(spec.type == nameSpecifier)
{
- Symbol symbol = spec.name ? FindType(curContext, spec.name) : null;
- if(symbol && symbol.type)
+ if(spec.name && (!strcmp(spec.name, "intptr") || !strcmp(spec.name, "uintptr")))
{
- // Free Type Contents:
- Type dummy { };
- *dummy = *specType;
- FreeType(dummy);
-
- CopyTypeInto(specType, symbol.type);
- specType.typeName = CopyString(symbol.type.name);
+ specType.kind = intPtrType;
+ if(!strcmp(spec.name, "uintptr"))
+ specType.isSigned = false;
}
- else if(!isTypedef) // !specType.kind) // TESTING THIS FOR enum / typedef problem
+ else if(spec.name && (!strcmp(spec.name, "uintsize") || !strcmp(spec.name, "intsize")))
{
- // key.sym enum values need FindClass:
- specType._class = spec.name ? FindClass(spec.name) : null;
- // specType._class = spec.symbol;
- specType.kind = classType;
- if(!specType._class)
- specType.kind = intType;
+ specType.kind = intSizeType;
+ if(!strcmp(spec.name, "uintsize"))
+ specType.isSigned = false;
+ }
+ else
+ {
+ Symbol symbol = spec.name ? FindType(curContext, spec.name) : null;
+ if(symbol && symbol.type)
+ {
+ // Free Type Contents:
+ Type dummy { };
+ *dummy = *specType;
+ FreeType(dummy);
+
+ CopyTypeInto(specType, symbol.type);
+ specType.typeName = CopyString(symbol.type.name);
+ }
+ else if(!isTypedef) // !specType.kind) // TESTING THIS FOR enum / typedef problem
+ {
+ // key.sym enum values need FindClass:
+ specType._class = spec.name ? FindClass(spec.name) : null;
+ // specType._class = spec.symbol;
+ specType.kind = classType;
+ if(!specType._class)
+ specType.kind = intType;
+ }
}
}
else if(spec.type == enumSpecifier)
// TESTING: Added extendedDeclarator here
while(d && (d.type == bracketsDeclarator || d.type == extendedDeclarator || d.type == extendedDeclaratorEnd))
{
- if((d.type == extendedDeclarator || d.type == extendedDeclaratorEnd) && d.extended.extended &&
- (!strcmp(d.extended.extended, "__declspec(dllexport)") || !strcmp(d.extended.extended, "dllexport")))
+ if((d.type == extendedDeclarator || d.type == extendedDeclaratorEnd) && d.extended.extended && d.extended.extended.type == extDeclString &&
+ d.extended.extended.s && (!strcmp(d.extended.extended.s, "__declspec(dllexport)") || !strcmp(d.extended.extended.s, "dllexport")))
{
dllExport = true;
}
{
char * filePrefix = "";
if(!(srcFile[0] && (srcFile[1] == ':' || srcFile[0] == '/')))
- filePrefix = (GetRuntimePlatform() == win32) ? ".\\" : "./";
- GetSystemPathBuffer(srcFileFixed, srcFile);
+ filePrefix = "./"; //(GetRuntimePlatform() == win32) ? ".\\" : "./";
+ // GetSystemPathBuffer(srcFileFixed, srcFile);
+ GetSlashPathBuffer(srcFileFixed, srcFile);
for(s : intlStrings)
{
// TOFIX: (#654) ContextStringPair * pair = &s;