Browse code

prepare for reading globals from ctx

Török Edvin authored on 2010/03/06 23:00:54
Showing 3 changed files
... ...
@@ -67,6 +67,8 @@ struct cli_bc_ctx *cli_bytecode_context_alloc(void)
67 67
     ctx->line = 0;
68 68
     ctx->col = 0;
69 69
     ctx->mpool = NULL;
70
+    ctx->numGlobals = 0;
71
+    ctx->globals = NULL;
70 72
     return ctx;
71 73
 }
72 74
 
... ...
@@ -147,6 +147,8 @@ struct cli_bc_ctx {
147 147
     unsigned line;
148 148
     unsigned col;
149 149
     mpool_t *mpool;
150
+    uint32_t numGlobals;
151
+    uint8_t* globals;
150 152
 };
151 153
 struct cli_all_bc;
152 154
 int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct cli_bc_func *func, const struct cli_bc_inst *inst);
... ...
@@ -262,7 +262,15 @@ static always_inline struct stack_entry *pop_stack(struct stack *stack,
262 262
     x = *(uint_type(n)*)&(from)[(p)];\
263 263
     TRACE_R(x)
264 264
 
265
-#define READN(x, n, p) READNfrom(func->numBytes, values, x, n, p)
265
+#define READN(x, n, p)\
266
+ do {\
267
+     if (p&0x80000000) {\
268
+	 uint32_t pg = p&0x7fffffff;\
269
+	 READNfrom(ctx->numGlobals, ctx->globals, x, n, p);\
270
+     } else {\
271
+	 READNfrom(func->numBytes, values, x, n, p);\
272
+     }\
273
+ } while (0)
266 274
 
267 275
 #define READ1(x, p) READN(x, 8, p);\
268 276
     x = x&1