Better handling of casting
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user