]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
codesize flag now tracks number of bytecodes in the command and comma now uses/update...
authorMichael D. Lowis <mike@mdlowis.com>
Mon, 21 Apr 2014 20:53:55 +0000 (16:53 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Mon, 21 Apr 2014 20:53:55 +0000 (16:53 -0400)
source/slvm/main.c

index 93c28c6fbb81550dc0b524cea1f960c41dc67156..78de55185f12a99cd274f6f45c44c2bcb4aad5f5 100644 (file)
@@ -260,7 +260,7 @@ defcode("create", create, 0, 0, &rbrack){
     /* Initialize the flags (hidden and non-immediate by default) */
     word->flags.f_immed  = 0;
     word->flags.f_hidden = 1;
-    word->flags.codesize = 0;
+    word->flags.codesize = 1;
     /* Initialize the name, codeword, and bytecode */
     word->name     = name;
     word->codeword = &docolon;
@@ -280,8 +280,8 @@ defcode(",", comma, 0, 0, &create){
     *((long*)here_val) = *(ArgStackPtr);
     ArgStackPtr--;
     /* Resize the code section and relocate if necessary */
-    long currsize = sizeof(long) + (here_val - (long)word->code);
-    word->code    = (long*)realloc(word->code, currsize + sizeof(long));
+    word->flags.codesize++;
+    word->code    = (long*)realloc(word->code, word->flags.codesize * sizeof(long));
     /* Update "here" and terminate the code section */
     here_val = (long)(((long*)here_val) + 1);
     *((long*)here_val) = (long)&ret;