diff --git a/tools/qfcc/source/constfold.c b/tools/qfcc/source/constfold.c index e56a8bca2..a2afd19c0 100644 --- a/tools/qfcc/source/constfold.c +++ b/tools/qfcc/source/constfold.c @@ -149,6 +149,7 @@ convert_to_float (expr_t *e) case ex_def: case ex_expr: case ex_uexpr: + case ex_temp: return cast_expr (&type_float, e); default: internal_error (e); @@ -169,7 +170,15 @@ do_op_float (int op, expr_t *e, expr_t *e1, expr_t *e2) if (!valid_op (op, valid)) return error (e1, "invalid operand for float"); - if (op == '=') { + if (op == 'b') { + // bind is backwards to assign (why did I do that? :P) + if ((type = get_type (e2)) != &type_float) { + //FIXME optimize casting a constant + e->e.expr.e1 = e1 = cast_expr (type, e1); + } else if ((conv = convert_to_float (e1)) != e1) { + e->e.expr.e1 = e1 = conv; + } + } else if (op == '=' || op == PAS) { if ((type = get_type (e1)) != &type_float) { //FIXME optimize casting a constant e->e.expr.e2 = e2 = cast_expr (type, e2); @@ -636,6 +645,7 @@ convert_to_uinteger (expr_t *e) case ex_def: case ex_expr: case ex_uexpr: + case ex_temp: return cast_expr (&type_uinteger, e); default: internal_error (e); @@ -660,7 +670,14 @@ do_op_uinteger (int op, expr_t *e, expr_t *e1, expr_t *e2) convert_short_uint (e1); if (e1->type == ex_integer) convert_int_uint (e1); - if (op == '=') { + if (op == 'b') { + // bind is backwards to assign (why did I do that? :P) + if ((type = get_type (e2)) != &type_uinteger) { + e->e.expr.e1 = e1 = cast_expr (type, e1); + } else if ((conv = convert_to_uinteger (e1)) != e1) { + e->e.expr.e1 = e1 = conv; + } + } else if (op == '=' || op == PAS) { if ((type = get_type (e1)) != &type_uinteger) { e->e.expr.e2 = e2 = cast_expr (type, e2); } else if ((conv = convert_to_uinteger (e2)) != e2) { diff --git a/tools/qfcc/source/method.c b/tools/qfcc/source/method.c index acfed1e9c..19a889d48 100644 --- a/tools/qfcc/source/method.c +++ b/tools/qfcc/source/method.c @@ -468,10 +468,6 @@ method_check_params (method_t *method, expr_t *args) if (!t) return e; - if (mtype->parm_types[i] == &type_float && e->type == ex_integer) { - convert_int (e); - t = &type_float; - } if (i < parm_count) { if (e->type != ex_nil) if (!type_assignable (mtype->parm_types[i], t)) {