language

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 21182f92a0e560602b7510473457c6303fca35da
parent 64e83e42aef2b9a2990292d9d42ef21f459cc7c3
Author: Paul Longtine <paullongtine@gmail.com>
Date:   Fri,  1 Jul 2016 15:56:26 -0400

Woah, I fixed a thing! Roadblock is gone :)

Diffstat:
Msrc/lc/bytecode.py | 2+-
Msrc/lc/test_files/class.ti | 7+++++--
Msrc/vm/inc/ns.h | 1+
Msrc/vm/src/ns.c | 15+++++++++++++--
Msrc/vm/src/object.c | 2+-
Msrc/vm/src/proc.c | 8++++----
Msrc/vm/src/stk.c | 6+++++-
7 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/src/lc/bytecode.py b/src/lc/bytecode.py @@ -67,7 +67,7 @@ class NewClass(): self.label.action(s=True), self.label.action(), OP_DEC, - self.label.action(s=True), + self.toset.action(s=True), 0x06, self.toset.action(), OP_STV, diff --git a/src/lc/test_files/class.ti b/src/lc/test_files/class.ti @@ -1,5 +1,3 @@ -DEBUG; - class Counter: { int data = 0; @@ -59,3 +57,8 @@ class ObjectFibb: ObjectFibb test = new ObjectFibb(); test.run(15); +print "ALL DONE!"; +print test.a; +print test.b; +print test.c; + diff --git a/src/vm/inc/ns.h b/src/vm/inc/ns.h @@ -19,6 +19,7 @@ typedef struct ns_cont { } ns_cont; typedef struct ns_t { + int id; ns_cont* root; ns_cont* last; } ns_t; diff --git a/src/vm/src/ns.c b/src/vm/src/ns.c @@ -48,8 +48,13 @@ ns_t* ns_ctx_pop(ns_ctx* ctx) ASSERT((ctx->ptr - 1) >= 0, "ns_ctx underflow"); + ns_t* rv; + ctx->ptr = ctx->ptr - 1; - return ctx->spaces[ctx->ptr]; + + rv = ctx->spaces[ctx->ptr]; + + return rv; } /* Initialize namespace container of size @@ -84,7 +89,13 @@ ns_t* ns_init(ns_addr size) { ns_t* ns = (ns_t*)malloc(sizeof(ns_t)); M_ASSERT(ns); - + + static int inc = 0; + + ns->id = inc; + + inc++; + ns->root = ns_cont_init(size, 0); ns->last = ns->root; diff --git a/src/vm/src/object.c b/src/vm/src/object.c @@ -22,7 +22,7 @@ void object_del(void* object) N_ASSERT(object, "object_del\n"); obj_t* o = object; - + if (o->names != NULL) ns_del(o->names); diff --git a/src/vm/src/proc.c b/src/vm/src/proc.c @@ -36,7 +36,7 @@ void proc_run(rt_t* ctx) { if (ctx->db) { - printf("[%i]:\t", ctx->pc->address); + printf("-[ns-%i] [%i]:\t", ctx->vars->id, ctx->pc->address); bc_print_op(ctx->pc->line); printf("\n"); } @@ -51,19 +51,19 @@ void proc_run(rt_t* ctx) */ void proc_run_to_return(rt_t* ctx) { - N_ASSERT(ctx, "proc_run\n"); + N_ASSERT(ctx, "proc_run_to_return\n"); int n; for (n = 0; pc_safe(ctx->pc); pc_update(ctx->pc)) { if (ctx->db) { - printf("[%i]:\t", ctx->pc->address); + printf("*[ns-%i] [%i]:\t", ctx->vars->id, ctx->pc->address); bc_print_op(ctx->pc->line); printf("\n"); } - if (ctx->pc->line->op == 0x7F) + if (ctx->pc->line->op == 0x7F || ctx->pc->line->op == 0x82) { n++; } diff --git a/src/vm/src/stk.c b/src/vm/src/stk.c @@ -121,7 +121,11 @@ var_cont* stk_pop(stk_t* stack) stack->stack->ptr = stack->stack->ptr - 1; - return stack->stack->data[stack->stack->ptr]; + var_cont* rv = stack->stack->data[stack->stack->ptr]; + + stack->stack->data[stack->stack->ptr] = NULL; + + return rv; } /* Pushes var_cont* to the stack