| \ compiler definitions 14sep97jaw |
\ compiler definitions 14sep97jaw |
| |
|
| \ Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc. |
\ Copyright (C) 1995,1996,1997,1998,2000 Free Software Foundation, Inc. |
| |
|
| \ This file is part of Gforth. |
\ This file is part of Gforth. |
| |
|
| \ \ literals 17dec92py |
\ \ literals 17dec92py |
| |
|
| : Literal ( compilation n -- ; run-time -- n ) \ core |
: Literal ( compilation n -- ; run-time -- n ) \ core |
| \G Compile appropriate code such that, at run-time, @i{n} is placed |
\G Compilation semantics: compile the run-time semantics.@* |
| \G on the stack. Interpretation semantics are undefined. |
\G Run-time Semantics: push @i{n}.@* |
| |
\G Interpretation semantics: undefined. |
| [ [IFDEF] lit, ] |
[ [IFDEF] lit, ] |
| lit, |
lit, |
| [ [ELSE] ] |
[ [ELSE] ] |
| |
|
| [IFUNDEF] compile, |
[IFUNDEF] compile, |
| : compile, ( xt -- ) \ core-ext compile-comma |
: compile, ( xt -- ) \ core-ext compile-comma |
| \G Compile the word represented by the execution token, @i{xt}, |
\G Compile the word represented by the execution token @i{xt} |
| \G into the current definition. |
\G into the current definition. |
| A, ; |
A, ; |
| [THEN] |
[THEN] |
| COMP' swap POSTPONE Aliteral POSTPONE ALiteral ; immediate restrict |
COMP' swap POSTPONE Aliteral POSTPONE ALiteral ; immediate restrict |
| |
|
| : postpone, ( w xt -- ) \ gforth postpone-comma |
: postpone, ( w xt -- ) \ gforth postpone-comma |
| \g Compile the compilation semantics represented by @i{w xt}. |
\g Compile the compilation semantics represented by the |
| |
\g compilation token @i{w xt}. |
| dup ['] execute = |
dup ['] execute = |
| if |
if |
| drop compile, |
drop compile, |
| |
|
| [THEN] |
[THEN] |
| |
|
| : Defers ( "name" -- ) \ gforth |
: Defers ( compilation "name" -- ; run-time ... -- ... ) \ gforth |
| |
\G Compiles the present contents of the deferred word @i{name} |
| |
\G into the current definition. I.e., this produces static |
| |
\G binding as if @i{name} was not deferred. |
| ' >body @ compile, ; immediate |
' >body @ compile, ; immediate |
| |
|
| :noname |
:noname |
| |
|
| :noname ' >body @ ; |
:noname ' >body @ ; |
| :noname ' >body postpone ALiteral postpone @ ; |
:noname ' >body postpone ALiteral postpone @ ; |
| interpret/compile: What's ( "name" -- addr ) \ gforth |
interpret/compile: What's ( interpretation "name" -- xt; compilation "name" -- ; run-time -- xt ) \ gforth |
| |
\G @i{Xt} is the XT that is currently assigned to @i{name}. |
| |
|
| \ \ interpret/compile: |
\ \ interpret/compile: |
| |
|