# Compilation
+STATE, STATE_CFA = defNewVar("STATE", 0)
+
HEADER = defPrimWord("HEADER", () -> begin
wordLen = popPS()
return NEXT
end)
-STATE, STATE_CFA = defNewVar("STATE", 0)
-
LBRAC = defPrimWord("[", () -> begin
mem[STATE] = 0
return NEXT
HIDDEN,
EXIT])
+CREATE = defWord("CREATE",
+ [WORD,
+ HEADER,
+ LIT, DOVAR, COMMA, EXIT]);
+
COLON = defWord(":",
[WORD,
HEADER,
['] EXIT , ( append the codeword EXIT )
;
-: ALLOT ( n -- addr )
- HERE @ SWAP ( here n )
+: ALLOT ( n -- )
HERE +! ( adds n to HERE, after this the old value of HERE is still on the stack )
;
: VARIABLE
+ CREATE
1 CELLS ALLOT ( allocate 1 cell of memory, push the pointer to this memory )
- WORD HEADER ( make the dictionary entry (the name follows VARIABLE) )
- DOCOL , ( append DOCOL (the codeword field of this word) )
- ['] LIT , ( append the codeword LIT )
- , ( append the pointer to the new memory )
- ['] EXIT , ( append the codeword EXIT )
;