private void CheckAssignment(BfsSourceRange range, BfsPrimitiveTypeEnum target, BfsPrimitiveTypeEnum newvar) { if (target < newvar) BfsCompiler.ReportError(range,"The type '"+newvar+"' could not be stored into the type '"+target+"'"); }
private void CheckType(BfsExpGroup group, BfsPrimitiveTypeEnum type, IBfsDataBlock block) { //If boolean and non-boolean types are mixed. if((group.PrimitiveType == BfsPrimitiveTypeEnum.Bool && type > BfsPrimitiveTypeEnum.Bool)) BfsCompiler.ReportError(group.SourceRange, "Cannot mix boolean and " + type + " types"); else if(type == BfsPrimitiveTypeEnum.Bool && group.PrimitiveType > BfsPrimitiveTypeEnum.Bool) BfsCompiler.ReportError(group.SourceRange, "Cannot mix boolean and " + group.PrimitiveType + " types"); //if (type == BfsPrimitiveTypeEnum.FunctionType || group.PrimitiveType == BfsPrimitiveTypeEnum.FunctionType) // BfsCompiler.ReportError(group.SourceRange, "You cannot use function typed variables in expressions"); if (type == BfsPrimitiveTypeEnum.Undetermined) BfsCompiler.ReportError(group.SourceRange,"Undetermined type of variable"); //If all is well then it will pick the largest type that can contain the variable. //Hiearchy: Undetermined,Bool,Ubyte,Sbyte,Ushort,Short,Uint,Int,Ulong,Long BfsPrimitiveTypeEnum a = group.PrimitiveType; BfsPrimitiveTypeEnum b = type; group.PrimitiveType = (a > b) ? a : b; }