RPA Toolkit
implemented conditional expressions and fixes
authorMartin Stoilov <martin@rpasearch.com>
Tue, 18 Jan 2011 06:47:10 +0000 (22:47 -0800)
committerMartin Stoilov <martin@rpasearch.com>
Tue, 18 Jan 2011 06:47:10 +0000 (22:47 -0800)
rvm/rvmcpu.c
rvm/rvmcpu.h
tests/ecma262.rpa
tests/rpagen-test.c

index 9b1bcdd..59db0d0 100644 (file)
@@ -371,7 +371,11 @@ static void rvm_op_strw(rvmcpu_t *cpu, rvm_asmins_t *ins)
 
 static void rvm_op_strr(rvmcpu_t *cpu, rvm_asmins_t *ins)
 {
-       *((rvmreg_t*)RVM_CPUREG_GETP(cpu, ins->op2)) = RVM_CPUREG_GET(cpu, ins->op1);
+       rvmreg_t *dest = RVM_CPUREG_PTR(cpu, ins->op2);
+       if (RVM_REG_GETTYPE(dest) != RVM_DTYPE_POINTER)
+               RVM_ABORT(cpu, RVM_E_LVALUE);
+       else
+               *((rvmreg_t*)RVM_REG_GETP(dest)) = RVM_CPUREG_GET(cpu, ins->op1);
 }
 
 
@@ -1577,7 +1581,6 @@ rvmcpu_t *rvm_cpu_create()
                return ((void*)0);
        r_memset(cpu, 0, sizeof(*cpu));
        cpu->switables = r_array_create(sizeof(rvm_switable_t*));
-//     cpu->stack = r_carray_create(sizeof(rvmreg_t));
        cpu->stack = r_malloc(4 * 1024 *sizeof(rvmreg_t));
        cpu->data = r_carray_create(sizeof(rvmreg_t));
        cpu->opmap = rvm_opmap_create();
index 7aa09cf..c96c0b3 100644 (file)
@@ -245,7 +245,7 @@ do { \
 #define RVM_E_CAST                     (3)
 #define RVM_E_SWINUM           (4)
 #define RVM_E_SWITABLE         (5)
-#define RVM_E_ILLEGALDST       (6)
+#define RVM_E_LVALUE           (6)
 
 typedef struct rvm_asmins_s rvm_asmins_t;
 typedef struct rvmcpu_s rvmcpu_t;
index a39a654..c503940 100644 (file)
@@ -296,10 +296,6 @@ IterationStatement                                         ::= <:IterationWhileOp:> |
                                                                        <:IterationDo:>
 
 # 11.12 Conditional Operator ( ? : )
-#ConditionalExpression                                 ::= <:LogicalORExpression:> ( <S>? '?' <S>? <:AssignmentExpression:> <S>? ':' <S>? <:AssignmentExpression:> )?
-#ConditionalExpressionNoIn                     ::= <:LogicalORExpressionNoIn:> ( <S>? '?' <S>? <:AssignmentExpression:> <S>? ':' <S>? <:AssignmentExpressionNoIn:> )?
-#
-
 AssignmentExpressionIfTrueOp           ::= <:AssignmentExpression:>
 AssignmentExpressionIfFalseOp          ::= <:AssignmentExpression:>
 QuestionMarkOp                                         ::= '?'
index 3c7faed..92d0df3 100644 (file)
@@ -1686,6 +1686,7 @@ void rpagen_load_rules(rpa_dbex_handle dbex, rvm_compiler_t *co)
 
        rpa_dbex_add_callback_exact(dbex, "WhileConditionOp", RPA_REASON_MATCHED, codegen_whileconditionop_callback, co);
        rpa_dbex_add_callback_exact(dbex, "IterationWhileOp", RPA_REASON_ALL, codegen_iterationwhileop_callback, co);
+
        rpa_dbex_add_callback_exact(dbex, "QuestionMarkOp", RPA_REASON_MATCHED, codegen_questionmarkop_callback, co);
        rpa_dbex_add_callback_exact(dbex, "AssignmentExpressionIfTrueOp", RPA_REASON_MATCHED, codegen_iftrueop_callback, co);
        rpa_dbex_add_callback_exact(dbex, "AssignmentExpressionIfFalseOp", RPA_REASON_MATCHED, codegen_iffalseop_callback, co);