]> git.mdlowis.com Git - projs/onward.git/commitdiff
Fixed a bug in create
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 4 Dec 2014 17:54:19 +0000 (12:54 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 4 Dec 2014 17:54:19 +0000 (12:54 -0500)
source/onward.c
source/onward.ft

index eb8809541f4445565a2734e7a41c6ffad5e98b18..3b67f6fae372f1a14d443e7353e6ff7fcf3b1025 100755 (executable)
@@ -209,7 +209,9 @@ defcode("create", create, &exec, 0u) {
     char* name = (char*)onward_aspop();
     /* Copy the name to a more permanent location */
     size_t str_size = strlen(name) + 1;
-    size_t new_size = str_size + (sizeof(value_t) - (str_size % sizeof(value_t)));
+    size_t new_size = (str_size % sizeof(value_t))
+                        ? ((str_size + (sizeof(value_t) - 1)) & ~sizeof(value_t))
+                        : str_size;
     name = memcpy((void*)here, name, str_size);
     here += new_size;
     /* Start populating the word definition */
index aa4a58d2d682b604a82a329a3981d32a8fcb2e56..98951dcdaebc7f0b18227d2dac18fecc92862de3 100644 (file)
@@ -17,7 +17,7 @@
    CELLSZ +        \ Add offset to get to the flags field
    dup @           \ Fetch the current value
    F_IMMEDIATE | ! \ Set the immediate bit
-; immediate
+; immediate \ Use the immediate word to make the immediate word immediate :D
 
 : [compile] immediate
     word find ,
     ' lit , , \ Compile the top item on the stack as a literal
 ;
 
+: allot here @ dup rot + here swap ! ;
+
+: cells CELLSZ * ;
+
+: variable
+    1 cells allot
+    word create
+    [compile] literal
+    0 ,
+;
+
 : const word create [compile] literal 0 , ;
 
 : dump word find dumpw ;
 \ Comment Words
 \ -----------------------------------------------------------------------------
 : #  [compile] \ ;
+
 : #! [compile] \ ;
 
 : ( immediate