Most statements don't return a value
authorLars Knoll <lars.knoll@digia.com>
Mon, 28 Jan 2013 09:40:30 +0000 (10:40 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Mon, 28 Jan 2013 12:32:48 +0000 (13:32 +0100)
In eval mode, we need to write the result of statements
into the return value. But most statements don't return
a value, so the statement shouldn't write a return value.

Change-Id: I9ce24fe6689bd2bb2aee6241ca84a25f9a266f5c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
qv4codegen.cpp

index 462aeea..b5c0e9d 100644 (file)
@@ -726,10 +726,6 @@ void Codegen::statement(ExpressionNode *ast)
 {
     if (! ast) {
         return;
-    } else if (_mode == EvalCode) {
-        Result e = expression(ast);
-        if (*e)
-            move(_block->TEMP(_returnAddress), *e);
     } else {
         Result r(nx);
         qSwap(_expr, r);
@@ -2091,7 +2087,13 @@ bool Codegen::visit(EmptyStatement *)
 
 bool Codegen::visit(ExpressionStatement *ast)
 {
-    statement(ast->expression);
+    if (_mode == EvalCode) {
+        Result e = expression(ast->expression);
+        if (*e)
+            move(_block->TEMP(_returnAddress), *e);
+    } else {
+        statement(ast->expression);
+    }
     return false;
 }