Author: mdiep Date: Sat Aug 13 21:17:51 2005 New Revision: 8952 Modified: trunk/languages/tcl/lib/expression.pir trunk/languages/tcl/tcl.pir_template Log: tcl: Add eq and ne operators
Modified: trunk/languages/tcl/lib/expression.pir ============================================================================== --- trunk/languages/tcl/lib/expression.pir (original) +++ trunk/languages/tcl/lib/expression.pir Sat Aug 13 21:17:51 2005 @@ -130,7 +130,7 @@ get_function: .local pmc result (op_length,func,result) = __expr_get_function(expr,chunk_start) - if op_length == 0 goto get_number + if op_length == 0 goto get_operator chunk = new TclList chunk[0] = FUNC chunk[1] = func @@ -425,6 +425,8 @@ do_op: if func == OPERATOR_BITAND goto op_bitand if func == OPERATOR_BITXOR goto op_bitxor if func == OPERATOR_BITOR goto op_bitor + if func == OPERATOR_NE goto op_ne + if func == OPERATOR_EQ goto op_eq func_list: if func == FUNCTION_ABS goto func_abs if func == FUNCTION_ACOS goto func_acos @@ -504,6 +506,20 @@ op_bitxor: op_bitor: op_result = bor l_arg, r_arg goto done_op +op_ne: + op_result = 1 + $S0 = l_arg + $S1 = r_arg + if $S0 != $S1 goto done_op + op_result = 0 + goto done_op +op_eq: + op_result = 1 + $S0 = l_arg + $S1 = r_arg + if $S0 == $S1 goto done_op + op_result = 0 + goto done_op func_abs: # XXX This isn't int only, izzit? $I0 = l_arg Modified: trunk/languages/tcl/tcl.pir_template ============================================================================== --- trunk/languages/tcl/tcl.pir_template (original) +++ trunk/languages/tcl/tcl.pir_template Sat Aug 13 21:17:51 2005 @@ -35,6 +35,8 @@ providing a compreg-compatible method. # Constants for operator/function lookup. + .const int OPERATOR_EQ = 28 + .const int OPERATOR_NE = 29 .const int OPERATOR_BITAND = 30 .const int OPERATOR_BITOR = 31 .const int OPERATOR_BITXOR = 32 @@ -147,7 +149,11 @@ providing a compreg-compatible method. operators["=="] = OPERATOR_EQUAL precedence["=="] = 5 operators["!="] = OPERATOR_UNEQUAL - precedence["!="] = 5 + precedence["!="] = 5 + operators["ne"] = OPERATOR_NE + precedence["ne"] = 6 + operators["eq"] = OPERATOR_EQ + precedence["eq"] = 6 operators["&"] = OPERATOR_BITAND precedence["&"] = 7 operators["^"] = OPERATOR_BITXOR
