Algorithmique Numérique Distribuée Public GIT Repository
 author Matthieu Volat Thu, 12 Jan 2017 16:18:24 +0000 (17:18 +0100) committer degomme Thu, 12 Jan 2017 17:05:09 +0000 (18:05 +0100)
In all those cases, the order of pop() was not an issue since
the operations were commutatives, but those could give bad
ideas for other cases.

index 03298eb..86043a0 100644 (file)
@@ -205,13 +205,19 @@ void execute(
// and replace the top of the stack with the computed value
// (stack.top() += stack.before_top()).

-    case DW_OP_plus:
-      stack.push(stack.pop() + stack.pop());
+    case DW_OP_plus: {
+      intptr_t first = stack.pop();
+      intptr_t second = stack.pop();
+      stack.push(first + second);
break;
+    }

-    case DW_OP_mul:
-      stack.push(stack.pop() * stack.pop());
+    case DW_OP_mul: {
+      intptr_t first = stack.pop();
+      intptr_t second = stack.pop();
+      stack.push(first * second);
break;
+    }

case DW_OP_plus_uconst:
stack.top() += op->number;
@@ -232,17 +238,26 @@ void execute(
break;
}

-    case DW_OP_and:
-      stack.push(stack.pop() & stack.pop());
+    case DW_OP_and: {
+      intptr_t first = stack.pop();
+      intptr_t second = stack.pop();
+      stack.push(first & second);
break;
+    }

-    case DW_OP_or:
-      stack.push(stack.pop() | stack.pop());
+    case DW_OP_or: {
+      intptr_t first = stack.pop();
+      intptr_t second = stack.pop();
+      stack.push(first | second);
break;
+    }

-    case DW_OP_xor:
-      stack.push(stack.pop() ^ stack.pop());
+    case DW_OP_xor: {
+      intptr_t first = stack.pop();
+      intptr_t second = stack.pop();
+      stack.push(first ^ second);
break;
+    }

case DW_OP_nop:
break;