The Lambda Lab
/
projects
/
forth.jl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
68255a6
)
CREATE, ALLOT and VARIABLE now work as they should.
author
Tim Vaughan
<tgvaughan@gmail.com>
Mon, 2 May 2016 02:11:33 +0000
(14:11 +1200)
committer
Tim Vaughan
<tgvaughan@gmail.com>
Mon, 2 May 2016 02:11:33 +0000
(14:11 +1200)
src/forth.jl
patch
|
blob
|
history
src/lib.4th
patch
|
blob
|
history
diff --git
a/src/forth.jl
b/src/forth.jl
index
c1ca1a0
..
98999a3
100644
(file)
--- a/
src/forth.jl
+++ b/
src/forth.jl
@@
-768,6
+768,8
@@
end)
# Compilation
# Compilation
+STATE, STATE_CFA = defNewVar("STATE", 0)
+
HEADER = defPrimWord("HEADER", () -> begin
wordLen = popPS()
HEADER = defPrimWord("HEADER", () -> begin
wordLen = popPS()
@@
-786,8
+788,6
@@
COMMA = defPrimWord(",", () -> begin
return NEXT
end)
return NEXT
end)
-STATE, STATE_CFA = defNewVar("STATE", 0)
-
LBRAC = defPrimWord("[", () -> begin
mem[STATE] = 0
return NEXT
LBRAC = defPrimWord("[", () -> begin
mem[STATE] = 0
return NEXT
@@
-810,6
+810,11
@@
HIDE = defWord("HIDE",
HIDDEN,
EXIT])
HIDDEN,
EXIT])
+CREATE = defWord("CREATE",
+ [WORD,
+ HEADER,
+ LIT, DOVAR, COMMA, EXIT]);
+
COLON = defWord(":",
[WORD,
HEADER,
COLON = defWord(":",
[WORD,
HEADER,
diff --git
a/src/lib.4th
b/src/lib.4th
index
28aa451
..
9e40b2d
100644
(file)
--- a/
src/lib.4th
+++ b/
src/lib.4th
@@
-478,18
+478,13
@@
['] EXIT , ( append the codeword EXIT )
;
['] 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
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 )
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 )
;
;