void UlamTypeInfo::PrintPretty(ByteSink & bs) const { bs.Printf("%s",GetPrettyPrefixFromCategory(m_category)); if (IsPrimitive()) m_utip.PrintPretty(bs); else if (IsClass()) m_utic.PrintPretty(bs); else FAIL(ILLEGAL_STATE); }
bool asCDataType::IsObject() const { if( IsPrimitive() ) return false; // Null handle doesn't have an object type but should still be considered an object if( objectType == 0 ) return IsNullHandle(); return true; }
bool asCDataType::IsObject() const { if( IsPrimitive() ) return false; // Null handle doesn't have an object type but should still be considered an object if( typeInfo == 0 ) return IsNullHandle(); // Template subtypes shouldn't be considered objects return typeInfo->CastToObjectType() ? true : false; }
void UlamTypeInfo::PrintMangled(ByteSink & bs) const { if (IsUnknown()) FAIL(ILLEGAL_STATE); bs.Printf("U%c_",GetUCodeFromCategory()); if (IsPrimitive()) m_utip.PrintMangled(bs); else m_utic.PrintMangled(bs); }
bool asCDataType::IsSamePrimitiveBaseType(const asCDataType &dt) const { if( !IsPrimitive() || !dt.IsPrimitive() ) return false; if( IsIntegerType() && dt.IsIntegerType() ) return true; if( IsUnsignedType() && dt.IsUnsignedType() ) return true; if( IsFloatType() && dt.IsFloatType() ) return true; if( IsDoubleType() && dt.IsDoubleType() ) return true; if( IsBooleanType() && dt.IsBooleanType() ) return true; if( IsFloatType() && dt.IsDoubleType() ) return true; if( IsDoubleType() && dt.IsFloatType() ) return true; return false; }
bool asCDataType::CanBeCopied() const { // All primitives can be copied if( IsPrimitive() ) return true; // Plain-old-data structures can always be copied if( objectType->flags & asOBJ_POD ) return true; // It must be possible to instanciate the type if( !CanBeInstanciated() ) return false; // It must have a default constructor or factory if( objectType->beh.construct == 0 && objectType->beh.factory == 0 ) return false; // It must be possible to copy the type if( objectType->beh.copy == 0 ) return false; return true; }
// function that tokenizes the input, using a structure of conscell's, where each conscell has a car and a cdr, // each car has two values, the type and the actual value. ConsCell* tokenize(char *expression) { ConsCell *current =malloc(sizeof(ConsCell)); ConsCell *Head = current; int i = 0; for (int i = 0; expression[i]; i++) { if (expression[i]==' ') continue; else if (expression[i] == '\n'){ continue; } if (expression[i]== '\t'){ continue; } Value *carVar = malloc(sizeof(Value)); Value *cdrVar = malloc(sizeof(Value)); if (expression[i]=='(') { carVar->type = 6; carVar->openValue = '('; } else if (expression[i]==')') { carVar->type=7; carVar->closeValue = ')'; } else { if (IsAnInt(expression, i)) { carVar->type=2; carVar->intValue=GiveInt(expression, i); i = getNextTerminal(expression, i); i -=1; } else if(IsSymbol(expression, i)) { int symbolLength=returnSymbolLength(expression, i); carVar->type=5; carVar->symbolValue=returnSymbol(expression, i, symbolLength); if (IsId(carVar->symbolValue)){ carVar->type = 9; carVar->idValue = carVar->symbolValue; } else if (IsPrimitive(carVar->symbolValue)) { carVar->type = 13; carVar->primValue = carVar->symbolValue; } i+=symbolLength; } else if(IsString(expression, i)) { carVar->type=4; carVar->stringValue=returnString(expression, i); int lengthOfString = findLengthOfString(carVar->stringValue); i+=lengthOfString; } else if(IsBoolean(expression,i)){ carVar->type = 1; carVar->boolValue=returnBoolean(expression,i); i +=1; } else if(IsFloat(expression, i)) { carVar->type=3; carVar->floatValue=GiveFloat(expression, i); i = getNextTerminal(expression, i); i -=1; } else if(expression[i] == ';') { free(carVar); free(cdrVar); break; } else { free(carVar); free(cdrVar); printf("Error: Bad syntax.\n"); ConsCell *emptyCons =malloc(sizeof(ConsCell)); Value *Val = malloc(sizeof(Value)); Val->type = 0; Val->intValue= 1; emptyCons->car = Val; Value *cdrVal = malloc(sizeof(Value)); cdrVal->type = 0; cdrVal->intValue = 0; current->car = cdrVal; cleanupCCLL(Head); return emptyCons; break; } } ConsCell *newCell = malloc(sizeof(ConsCell)); cdrVar->type = 8; cdrVar->cons = newCell; current = insertCC(current, carVar, cdrVar); current = newCell; } Value *cdrVal = malloc(sizeof(Value)); cdrVal->type = 0; cdrVal->intValue = 0; current->car = cdrVal; return Head; }