version 1.167, 2009/03/24 08:55:29
|
version 1.177, 2011/11/11 18:29:09
|
Line 1
|
Line 1
|
\ CROSS.FS The Cross-Compiler 06oct92py |
\ CROSS.FS The Cross-Compiler 06oct92py |
\ Idea and implementation: Bernd Paysan (py) |
\ Idea and implementation: Bernd Paysan (py) |
|
|
\ Copyright (C) 1995,1996,1997,1998,1999,2000,2003,2004,2005,2006,2007 Free Software Foundation, Inc. |
\ Copyright (C) 1995,1996,1997,1998,1999,2000,2003,2004,2005,2006,2007,2009,2010 Free Software Foundation, Inc. |
|
|
\ This file is part of Gforth. |
\ This file is part of Gforth. |
|
|
Line 765 Plugin ?do, ( -- ?do-token )
|
Line 765 Plugin ?do, ( -- ?do-token )
|
Plugin for, ( -- for-token ) |
Plugin for, ( -- for-token ) |
Plugin loop, ( do-token / ?do-token -- ) |
Plugin loop, ( do-token / ?do-token -- ) |
Plugin +loop, ( do-token / ?do-token -- ) |
Plugin +loop, ( do-token / ?do-token -- ) |
|
Plugin -loop, ( do-token / ?do-token -- ) |
Plugin next, ( for-token ) |
Plugin next, ( for-token ) |
Plugin leave, ( -- ) |
Plugin leave, ( -- ) |
Plugin ?leave, ( -- ) |
Plugin ?leave, ( -- ) |
Line 1726 T has? relocate H
|
Line 1727 T has? relocate H
|
|
|
Ghost (do) Ghost (?do) 2drop |
Ghost (do) Ghost (?do) 2drop |
Ghost (for) drop |
Ghost (for) drop |
Ghost (loop) Ghost (+loop) 2drop |
Ghost (loop) Ghost (+loop) Ghost (-loop) 2drop drop |
Ghost (next) drop |
Ghost (next) drop |
Ghost (does>) Ghost (does>1) Ghost (does>2) 2drop drop |
Ghost !does drop |
Ghost compile, drop |
Ghost compile, drop |
Ghost (.") Ghost (S") Ghost (ABORT") 2drop drop |
Ghost (.") Ghost (S") Ghost (ABORT") 2drop drop |
Ghost (C") Ghost c(abort") Ghost type 2drop drop |
Ghost (C") Ghost c(abort") Ghost type 2drop drop |
Line 2412 T 2 cells H Value xt>body
|
Line 2413 T 2 cells H Value xt>body
|
there xt>body + ca>native T a, H 1 fillcfa ; ' (doprim,) plugin-of doprim, |
there xt>body + ca>native T a, H 1 fillcfa ; ' (doprim,) plugin-of doprim, |
|
|
: (doeshandler,) ( -- ) |
: (doeshandler,) ( -- ) |
T cfalign H [G'] :doesjump addr, T 0 , H ; ' (doeshandler,) plugin-of doeshandler, |
T H ; ' (doeshandler,) plugin-of doeshandler, |
|
|
: (dodoes,) ( does-action-ghost -- ) |
: (dodoes,) ( does-action-ghost -- ) |
]comp [G'] :dodoes addr, comp[ |
]comp [G'] :dodoes addr, comp[ |
addr, |
addr, |
\ the relocator in the c engine, does not like the |
|
\ does-address to marked for relocation |
|
[ T e? ec H 0= [IF] ] T here H tcell - reloff [ [THEN] ] |
|
2 fillcfa ; ' (dodoes,) plugin-of dodoes, |
2 fillcfa ; ' (dodoes,) plugin-of dodoes, |
|
|
: (dlit,) ( n -- ) compile lit td, ; ' (dlit,) plugin-of dlit, |
: (dlit,) ( n -- ) compile lit td, ; ' (dlit,) plugin-of dlit, |
Line 2652 T has? primcentric H [IF]
|
Line 2650 T has? primcentric H [IF]
|
>TARGET |
>TARGET |
Cond: DOES> |
Cond: DOES> |
T here H [ T has? primcentric H [IF] ] 5 [ [ELSE] ] 4 [ [THEN] ] T cells |
T here H [ T has? primcentric H [IF] ] 5 [ [ELSE] ] 4 [ [THEN] ] T cells |
H + alit, compile (does>2) compile ;s |
H + alit, compile !does compile ;s |
doeshandler, resolve-does>-part |
doeshandler, resolve-does>-part |
;Cond |
;Cond |
|
|
Line 2949 by (Field)
|
Line 2947 by (Field)
|
T 1 cells H dup ; |
T 1 cells H dup ; |
>CROSS |
>CROSS |
|
|
|
\ ABI-CODE support |
|
Builder (ABI-CODE) |
|
Build: ;Build |
|
by: :doabicode noop ;DO |
|
|
|
BUILDER (;abi-code) |
|
Build: ;Build |
|
by: :do;abicode noop ;DO |
|
|
\ Input-Methods 01py |
\ Input-Methods 01py |
|
|
Builder input-method |
Builder input-method |
Line 2959 Builder input-var
|
Line 2966 Builder input-var
|
Build: ( m v size -- m v' ) over T , H + ;Build |
Build: ( m v size -- m v' ) over T , H + ;Build |
DO: abort" Not in cross mode" ;DO |
DO: abort" Not in cross mode" ;DO |
|
|
|
\ Mini-OOF |
|
|
|
\ Builder method |
|
\ Build: ( m v -- m' v ) over T , swap cell+ swap H ;Build |
|
\ DO: abort" Not in cross mode" ;DO |
|
|
|
\ Builder var |
|
\ Build: ( m v size -- m v+size ) over T , H + ;Build |
|
\ DO: ( o -- addr ) T @ H + ;DO |
|
|
|
\ Builder end-class |
|
\ Build: ( addr m v -- ) |
|
\ T here >r , dup , 2 cells H ?DO T ['] noop , 1 cells H +LOOP |
|
\ T cell+ dup cell+ r> rot @ 2 cells /string move H ;Build |
|
\ by: Variable |
|
|
|
\ : defines ( xt class -- ) T ' >body @ + ! H ; |
|
|
\ Peephole optimization 05sep01jaw |
\ Peephole optimization 05sep01jaw |
|
|
\ this section defines different compilation |
\ this section defines different compilation |
Line 3227 Cond: ENDCASE endcase, ;Cond
|
Line 3252 Cond: ENDCASE endcase, ;Cond
|
1to compile (+loop) loop] |
1to compile (+loop) loop] |
compile unloop skiploop] ; ' (+loop,) plugin-of +loop, |
compile unloop skiploop] ; ' (+loop,) plugin-of +loop, |
|
|
|
: (-loop,) ( target-addr -- ) |
|
1to compile (-loop) loop] |
|
compile unloop skiploop] ; ' (-loop,) plugin-of -loop, |
|
|
: (next,) |
: (next,) |
compile (next) loop] compile unloop ; ' (next,) plugin-of next, |
compile (next) loop] compile unloop ; ' (next,) plugin-of next, |
|
|
Line 3236 Cond: FOR for, ;Cond
|
Line 3265 Cond: FOR for, ;Cond
|
|
|
Cond: LOOP 1 ncontrols? loop, ;Cond |
Cond: LOOP 1 ncontrols? loop, ;Cond |
Cond: +LOOP 1 ncontrols? +loop, ;Cond |
Cond: +LOOP 1 ncontrols? +loop, ;Cond |
|
Cond: -LOOP 1 ncontrols? -loop, ;Cond |
Cond: NEXT 1 ncontrols? next, ;Cond |
Cond: NEXT 1 ncontrols? next, ;Cond |
|
|
\ String words 23feb93py |
\ String words 23feb93py |
Line 3310 Cond: postpone ( -- ) \ name
|
Line 3340 Cond: postpone ( -- ) \ name
|
hex |
hex |
|
|
>CROSS |
>CROSS |
Create magic s" Gforth3x" here over allot swap move |
Create magic s" Gforth4x" here over allot swap move |
|
|
bigendian 1+ \ strangely, in magic big=0, little=1 |
bigendian 1+ \ strangely, in magic big=0, little=1 |
tcell 1 = 0 and or |
tcell 1 = 0 and or |