}
if(dest.kind != classType && source.kind == classType && source._class && source._class.registered &&
- !strcmp(source._class.registered.fullName, "ecere::com::unichar"))
+ !strcmp(source._class.registered.fullName, "unichar" /*"ecere::com::unichar"*/))
{
FreeType(source);
source = Type { kind = intType, isSigned = false, refCount = 1 };
break;
}
}
- if(newExp.type == memberExp && newExp.member.memberType == dataMember)
+ /*if(newExp.type == memberExp && newExp.member.memberType == dataMember)
{
+ // When was this required? Removed to address using templated values to pass to printf()
exp.type = opExp;
exp.op.op = '*';
exp.op.exp1 = null;
exp.op.exp2 = MkExpCast(MkTypeName(MkListOne(MkSpecifierName("uint64")), MkDeclaratorPointer(MkPointer(null, null), null)),
MkExpBrackets(MkListOne(MkExpOp(null, '&', newExp))));
}
- else
+ else*/
{
char typeString[1024];
Declarator decl;
exp.cast.typeName = MkTypeName(specs, decl);
exp.cast.exp = MkExpBrackets(MkListOne(newExp));
exp.cast.exp.needCast = true;
+ exp.needTemplateCast = 2;
+ newExp.needTemplateCast = 2;
}
break;
}
return null;
}
-static void ProcessDeclaration(Declaration decl);
-
/*static */Symbol FindSymbol(const char * name, Context startContext, Context endContext, bool isStruct, bool globalNameSpace)
{
#ifdef _DEBUG
char * endP = null;
int64 i64 = strtoll(constant, &endP, 0);
uint64 ui64 = strtoull(constant, &endP, 0);
- bool is64Bit = endP && (!strcmp(endP, "LL") || !strcmp(endP, "ll"));
+ bool is64Bit = endP && (!strcmp(endP, "LL") || !strcmp(endP, "ll") || !strcmp(endP, "LLU") || !strcmp(endP, "llu") || !strcmp(endP, "ull") || !strcmp(endP, "ULL"));
+ bool forceUnsigned = endP && (!strcmp(endP, "U") || !strcmp(endP, "u") || !strcmp(endP, "LLU") || !strcmp(endP, "llu") || !strcmp(endP, "ull") || !strcmp(endP, "ULL"));
if(isSigned)
{
if(i64 < MININT)
else if(constant[0] != '0' || !constant[1])
isSigned = true;
}
+ if(forceUnsigned)
+ isSigned = false;
type.kind = is64Bit ? int64Type : intType;
type.isSigned = isSigned;
}
FinishTemplatesContext(context);
// Mark parameters that were 'thisclass'
- /*{
+ {
Type p, op;
for(p = functionType.params.first, op = methodType.method.dataType.params.first; p && op; p = p.next, op = op.next)
- p.wasThisClass = op.kind == thisClassType;
- }*/
+ {
+ //p.wasThisClass = op.kind == thisClassType;
+ if(op.kind == thisClassType)
+ p.thisClassFrom = methodType.method._class;
+ }
+ }
+ if(methodType.method.dataType.returnType.kind == thisClassType)
+ {
+ // functionType.returnType.wasThisClass = true;
+ functionType.returnType.thisClassFrom = methodType.method._class;
+ }
}
FreeList(specs, FreeSpecifier);
kind = classType;
_class = prop ? prop._class.symbol : method ? method._class.symbol : _class.symbol;
// wasThisClass = type ? type.wasThisClass : false;
+ thisClassFrom = type ? type.thisClassFrom : null;
};
}
ClassTemplateArgument arg = tClass.templateArgs[id];
Context context = SetupTemplatesContext(tClass);
bool constant = exp.expType.constant;
+ bool passAsTemplate = false;
+ Class thisClassFrom = null;
+ Type t = ProcessTypeString(exp.expType.templateParameter.dataTypeString, false);
+ if(t && t.kind == classType && t._class)
+ thisClassFrom = t._class.registered;
+ FreeType(t);
+
+ passAsTemplate = tClass.templateClass && (exp.expType.kind != templateType ||
+ (!exp.expType.templateParameter || (!exp.expType.templateParameter.dataTypeString && !exp.expType.templateParameter.dataType)));
+
/*if(!arg.dataType)
arg.dataType = ProcessTypeString(arg.dataTypeString, false);*/
FreeType(exp.expType);
exp.expType = ProcessTypeString(arg.dataTypeString, false);
+ exp.expType.thisClassFrom = thisClassFrom;
if(exp.expType.kind == classType && constant) exp.expType.constant = true;
else if(exp.expType.kind == pointerType)
{
exp.expType = ReplaceThisClassType(_class);
}
- if(tClass.templateClass && (exp.expType.kind != templateType || (!exp.expType.templateParameter || (!exp.expType.templateParameter.dataTypeString && !exp.expType.templateParameter.dataType))))
+ if(passAsTemplate)
exp.expType.passAsTemplate = true;
//exp.expType.refCount++;
if(!exp.destType)
}
}
-static void ProcessSpecifier(Specifier spec, bool declareStruct)
+static void ProcessSpecifier(Specifier spec, bool declareStruct, bool warnClasses)
{
switch(spec.type)
{
spec.type = nameSpecifier;
spec.name = ReplaceThisClass(thisClass);
spec.symbol = FindClass(spec.name);
- ProcessSpecifier(spec, declareStruct);
+ ProcessSpecifier(spec, declareStruct, false);
}
}
break;
else if(spec.symbol /*&& declareStruct*/)
{
Class c = spec.symbol.registered;
+ if(warnClasses && !c)
+ Compiler_Warning("Undeclared class %s\n", spec.name);
DeclareStruct(curExternal, spec.name, c && c.type == noHeadClass, declareStruct && c && c.type == structClass);
}
break;
spec.type = nameSpecifier;
spec.name = ReplaceThisClass(thisClass);
spec.symbol = FindClass(spec.name);
- ProcessSpecifier(spec, false);
+ ProcessSpecifier(spec, false, false);
}
break;
}
}
else if(spec.type == nameSpecifier)
{
- ProcessSpecifier(spec, isFunction);
+ ProcessSpecifier(spec, isFunction, true);
}
}
}
}
}
-static void ProcessDeclaration(Declaration decl)
+static void ProcessDeclaration(Declaration decl, bool warnClasses)
{
yylloc = decl.loc;
switch(decl.type)
Specifier s;
for(s = decl.specifiers->first; s; s = s.next)
{
- ProcessSpecifier(s, declareStruct);
+ ProcessSpecifier(s, declareStruct, true);
}
}
break;
if(decl.specifiers)
{
for(spec = decl.specifiers->first; spec; spec = spec.next)
- ProcessSpecifier(spec, declareStruct);
+ ProcessSpecifier(spec, declareStruct, warnClasses);
}
break;
}
if(stmt.compound.declarations)
{
for(decl = stmt.compound.declarations->first; decl; decl = decl.next)
- ProcessDeclaration(decl);
+ ProcessDeclaration(decl, true);
}
if(stmt.compound.statements)
{
}
ProcessExpressionType(expIt);
if(stmt.compound.declarations->first)
- ProcessDeclaration(stmt.compound.declarations->first);
+ ProcessDeclaration(stmt.compound.declarations->first, true);
if(symbol)
symbol.isIterator = isMap ? 2 : ((isArray || isBuiltin) ? 3 : (isLinkList ? (isList ? 5 : 4) : (isCustomAVLTree ? 6 : 1)));
}
case badDeclarationStmt:
{
- ProcessDeclaration(stmt.decl);
+ ProcessDeclaration(stmt.decl, true);
break;
}
case asmStmt:
{
Class backThisClass = thisClass;
if(regClass) thisClass = regClass;
- ProcessDeclaration(def.decl);
+ ProcessDeclaration(def.decl, symbol ? true : false);
thisClass = backThisClass;
}
}
currentClass = null;
if(external.declaration)
- ProcessDeclaration(external.declaration);
+ ProcessDeclaration(external.declaration, true);
}
else if(external.type == classExternal)
{