]> git.mxchange.org Git - simgear.git/blobdiff - simgear/nasal/code.c
Olaf Flebbe:
[simgear.git] / simgear / nasal / code.c
index 871bad06ebd12d3e8cf62ea552002e85381f52e2..52cbf5bdc2c1f926fe9879fbeafd54f4217752d2 100644 (file)
@@ -200,11 +200,29 @@ void naFreeContext(struct Context* c)
     UNLOCK();
 }
 
-#define PUSH(r) do { \
+#if 0
+/*
+ * This is the original code which might not work properly on all
+ * platforms since it allows one to work on the same variable in one
+ * statement without the prior knowledge how this will behave.
+ * 
+ * e.g. ctx->opStack[ctx->opTop++] = ctx->opStack[ctx->opTop-1];
+ *                        ^^^^^                        ^^^^^
+ */
+# define PUSH(r) do { \
     if(ctx->opTop >= MAX_STACK_DEPTH) ERR(ctx, "stack overflow"); \
     ctx->opStack[ctx->opTop++] = r; \
     } while(0)
 
+#else
+
+# define PUSH(r)  _PUSH((ctx), (r))
+void _PUSH(struct Context* ctx, naRef r) {
+   if(ctx->opTop >= MAX_STACK_DEPTH) ERR(ctx, "stack overflow");
+    ctx->opStack[ctx->opTop++] = r;
+}
+#endif
+
 static void setupArgs(naContext ctx, struct Frame* f, naRef* args, int nargs)
 {
     int i;