Author: coke Date: Fri Jan 13 08:19:37 2006 New Revision: 11149 Modified: trunk/languages/tcl/lib/expression.pir trunk/languages/tcl/lib/tclbinaryops.pir Log: tcl -
o fix remaining break, continue, expr tests o remove hack that tried to numify strings. Instead, insert hack that tries to numify all operands for binary ops. If it fails, it uses the arg as is. If it works, then use the number. Modified: trunk/languages/tcl/lib/expression.pir ============================================================================== --- trunk/languages/tcl/lib/expression.pir (original) +++ trunk/languages/tcl/lib/expression.pir Fri Jan 13 08:19:37 2006 @@ -256,19 +256,9 @@ number: .return get_number(expr, pos) quote: - ($P0, $I0) = get_quote(expr, pos) + ($P0,$I0) = get_quote(expr,pos) inc $I0 - .local string type_o - type_o = typeof $P0 - #XXX Too protective? - if type_o != "TclConst" goto done_quote - # quotes can contain numbers that should be treated as such. Is this a number? - push_eh done_quote - $P1 = __number($P0) - clear_eh - .return ($P1,$I0) -done_quote: - .return($P0, $I0) + .return ($P0,$I0) brace: ($P0, $I0) = get_brace(expr, pos) Modified: trunk/languages/tcl/lib/tclbinaryops.pir ============================================================================== --- trunk/languages/tcl/lib/tclbinaryops.pir (original) +++ trunk/languages/tcl/lib/tclbinaryops.pir Fri Jan 13 08:19:37 2006 @@ -40,6 +40,7 @@ goto done .endm +#XXX This macro is unused? .macro binary_op2num(FORMAT) $P1 = new .Array $P1 = 6 @@ -157,6 +158,47 @@ Initialize the attributes for an instanc (r_reg,r_code) = compile(register_num, r_operand) register_num = r_reg + 1 + + # Operands have a chance to be treated numerically. + # XXX This is overkill, as it tries to numerify things that + # we just declared as constants: more logic needs to go + # in here to only do this if we know it's of a certain + # type. + .local string temp_code + temp_code = <<"END_PIR" + .local pmc __number + __number = find_global "_Tcl", "__number" +push_eh l_code_check_%s + $P%s = __number($P%s) +clear_eh +l_code_check_%s: +END_PIR + $P1 = new Array + $P1 =8 + $P1[0] = l_reg + $P1[1] = l_reg + $P1[2] = l_reg + $P1[3] = l_reg + $S0 = sprintf temp_code, $P1 + l_code .= $S0 + + temp_code = <<"END_PIR" +push_eh r_code_check_%s + $P%s = __number($P%s) +clear_eh +r_code_check_%s: +END_PIR + $P1 = new Array + $P1 =8 + $P1[0] = r_reg + $P1[1] = r_reg + $P1[2] = r_reg + $P1[3] = r_reg + $S0 = sprintf temp_code, $P1 + r_code .= $S0 + + ## end numeric_check + if op == OPERATOR_MUL goto op_mul if op == OPERATOR_DIV goto op_div if op == OPERATOR_MOD goto op_mod @@ -360,7 +402,6 @@ END_PIR pir_code .= $S1 done: - .return(register_num, pir_code) .end
