From: Tim Vaughan Date: Mon, 2 May 2016 12:34:20 +0000 (+1200) Subject: Working on CREATE/DOES> X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=7cc4407fe0b3da1af97f444bb03d874e868a7152;p=forth.jl.git Working on CREATE/DOES> --- diff --git a/src/forth.jl b/src/forth.jl index 98999a3..e571758 100644 --- a/src/forth.jl +++ b/src/forth.jl @@ -810,11 +810,6 @@ HIDE = defWord("HIDE", HIDDEN, EXIT]) -CREATE = defWord("CREATE", - [WORD, - HEADER, - LIT, DOVAR, COMMA, EXIT]); - COLON = defWord(":", [WORD, HEADER, @@ -841,6 +836,28 @@ TICK = defWord("'", BTICK = defWord("[']", [FROMR, DUP, INCR, TOR, FETCH, EXIT]) +# CREATE and DOES> + +CREATE = defWord("CREATE", + [WORD, + HEADER, + LIT, DOVAR, COMMA, EXIT]); + +DODOES = defPrim(() -> begin + pushRS(reg.IP) + reg.IP = reg.W + 1 + return NEXT +end, name="DOCOL") + +defConst("DODOES", DODOES) + +FROMDOES_PAREN = defWord("(DOES>)", + [DODOES, LAST, FETCH, TOCFA, STORE, EXIT]) + +FROMDOES = defWord("DOES>", + [BTICK, FROMDOES_PAREN, COMMA, BTICK, EXIT, COMMA, + BTICK, LIT, COMMA, LATEST, FETCH, TODFA, COMMA], flags=F_IMMED) + # Strings