Better handling of casting
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-08-18 13:17:53 +02:00
parent 0fde3d46df
commit 1d72e2eccd
8 changed files with 78 additions and 21 deletions

View File

@@ -176,4 +176,24 @@ namespace Porygon::Evaluation {
}
}
}
EvalValue *IntegerEvalValue::Cast(shared_ptr<const ScriptType> castType) const {
if (castType->GetClass() == TypeClass::Number){
auto num = static_pointer_cast<const NumericScriptType>(castType);
if (num->IsFloat()){
return new FloatEvalValue(GetIntegerValue());
}
}
return EvalValue::Cast(castType);
}
EvalValue *FloatEvalValue::Cast(shared_ptr<const ScriptType> castType) const {
if (castType->GetClass() == TypeClass::Number){
auto num = static_pointer_cast<const NumericScriptType>(castType);
if (!num->IsFloat()){
return new IntegerEvalValue(GetFloatValue());
}
}
return EvalValue::Cast(castType);
}
}