[goalc] fix bug in subtraction (#2399)

fixes the turrets pointing down in fortress dump mission

Co-authored-by: ManDude <7569514+ManDude@users.noreply.github.com>
This commit is contained in:
water111
2023-03-23 14:09:27 -04:00
committed by GitHub
parent 2e34514ee5
commit 56eeb20e4c
+6 -12
View File
@@ -321,15 +321,12 @@ Val* Compiler::compile_sub(const goos::Object& form, const goos::Object& rest, E
auto result = compile_integer(0, env)->to_gpr(form, env);
env->emit_ir<IR_IntegerMath>(
form, IntegerMathKind::SUB_64, result,
to_math_type(form, compile_error_guard(args.unnamed.at(0), env), math_type, env)
->to_gpr(form, env));
to_math_type(form, first_val, math_type, env)->to_gpr(form, env));
return result;
} else {
auto result = env->make_gpr(first_type);
env->emit_ir<IR_RegSet>(
form, result,
to_math_type(form, compile_error_guard(args.unnamed.at(0), env), math_type, env)
->to_gpr(form, env));
env->emit_ir<IR_RegSet>(form, result,
to_math_type(form, first_val, math_type, env)->to_gpr(form, env));
for (size_t i = 1; i < args.unnamed.size(); i++) {
env->emit_ir<IR_IntegerMath>(
@@ -345,15 +342,12 @@ Val* Compiler::compile_sub(const goos::Object& form, const goos::Object& rest, E
auto result = compile_float(0, env, env->function_env()->segment)->to_fpr(form, env);
env->emit_ir<IR_FloatMath>(
form, FloatMathKind::SUB_SS, result,
to_math_type(form, compile_error_guard(args.unnamed.at(0), env), math_type, env)
->to_fpr(form, env));
to_math_type(form, first_val, math_type, env)->to_fpr(form, env));
return result;
} else {
auto result = env->make_fpr(first_type);
env->emit_ir<IR_RegSet>(
form, result,
to_math_type(form, compile_error_guard(args.unnamed.at(0), env), math_type, env)
->to_fpr(form, env));
env->emit_ir<IR_RegSet>(form, result,
to_math_type(form, first_val, math_type, env)->to_fpr(form, env));
for (size_t i = 1; i < args.unnamed.size(); i++) {
env->emit_ir<IR_FloatMath>(