Diff for /gforth/prims2x.fs between versions 1.157 and 1.160

version 1.157, 2005/07/28 14:12:33 version 1.160, 2005/12/31 15:46:10
Line 1 Line 1
 \ converts primitives to, e.g., C code   \ converts primitives to, e.g., C code 
   
 \ Copyright (C) 1995,1996,1997,1998,2000,2003,2004 Free Software Foundation, Inc.  \ Copyright (C) 1995,1996,1997,1998,2000,2003,2004,2005 Free Software Foundation, Inc.
   
 \ This file is part of Gforth.  \ This file is part of Gforth.
   
Line 51 Line 51
 \ (stack-in-index-xt and a test for stack==instruction-stream); there  \ (stack-in-index-xt and a test for stack==instruction-stream); there
 \ should be only one.  \ should be only one.
   
   
 \ for backwards compatibility, jaw  \ for backwards compatibility, jaw
 require compat/strcomp.fs  require compat/strcomp.fs
   
Line 102  variable include-skipped-insts Line 103  variable include-skipped-insts
 \ inline arguments (false)  \ inline arguments (false)
 include-skipped-insts off  include-skipped-insts off
   
   2variable threaded-code-pointer-type \ type used for geninst etc.
   s" Inst **" threaded-code-pointer-type 2!
   
 variable immarg \ values for immediate arguments (to be used in IMM_ARG macros)  variable immarg \ values for immediate arguments (to be used in IMM_ARG macros)
 $12340000 immarg !  $12340000 immarg !
   
Line 351  wordlist constant primitives Line 355  wordlist constant primitives
     \ address of number of stack items in effect out      \ address of number of stack items in effect out
     stack-number @ cells prim prim-stacks-out + ;      stack-number @ cells prim prim-stacks-out + ;
   
   : stack-prim-stacks-sync ( stack -- addr )
       prim prim-stacks-sync swap stack-number @ th ;
   
 \ global vars  \ global vars
 variable c-line  variable c-line
 2variable c-filename  2variable c-filename
Line 504  defer inst-stream-f ( -- stack ) Line 511  defer inst-stream-f ( -- stack )
     rdrop ;      rdrop ;
   
 : same-as-in? ( item -- f )  : same-as-in? ( item -- f )
  \ f is true iff the offset and stack of item is the same as on input      \ f is true iff the offset and stack of item is the same as on input
  >r      >r
  r@ item-first @ if      r@ item-stack @ stack-prim-stacks-sync @ if
      rdrop false exit          rdrop false exit
  endif      endif
  r@ item-name 2@ prim prim-items-wordlist @ search-wordlist 0= abort" bug"      r@ item-first @ if
  execute @          rdrop false exit
  dup r@ =      endif
  if \ item first appeared in output      r@ item-name 2@ prim prim-items-wordlist @ search-wordlist 0= abort" bug"
    drop false      execute @
  else      dup r@ =
    dup  item-stack  @ r@ item-stack  @ =       if \ item first appeared in output
    swap item-offset @ r@ item-offset @ = and          drop false
  endif      else
  rdrop ;          dup  item-stack  @ r@ item-stack  @ = 
           swap item-offset @ r@ item-offset @ = and
       endif
       rdrop ;
   
 : item-out-index ( item -- n )  : item-out-index ( item -- n )
     \ n is the index of item (in the out-effect)      \ n is the index of item (in the out-effect)
Line 616  does> ( item -- ) Line 626  does> ( item -- )
             UNLOOP EXIT              UNLOOP EXIT
         endif          endif
         -1 s+loop          -1 s+loop
     \ we did not find a type, abort          \ we did not find a type, abort
           abort
     false s" unknown prefix" ?print-error ;      false s" unknown prefix" ?print-error ;
   
 : declaration ( item -- )  : declaration ( item -- )
Line 650  does> ( item -- ) Line 661  does> ( item -- )
     stack item item-stack !      stack item item-stack !
     item declaration ;      item declaration ;
   
 : stack-prim-stacks-sync ( stack -- addr )  
     prim prim-stacks-sync swap stack-number @ th ;  
   
 : set-prim-stacks-sync ( stack -- )  : set-prim-stacks-sync ( stack -- )
     stack-prim-stacks-sync on ;      stack-prim-stacks-sync on ;
   
Line 667  get-current prefixes set-current Line 675  get-current prefixes set-current
     item-stack @ dup if      item-stack @ dup if
         set-prim-stacks-sync          set-prim-stacks-sync
     else \ prefixless "..." syncs all stacks      else \ prefixless "..." syncs all stacks
         ['] set-prim-stacks-sync map-stacks1          drop ['] set-prim-stacks-sync map-stacks1
     endif ;      endif ;
 set-current  set-current
   
Line 1165  variable tail-nextp2 \ xt to execute for Line 1173  variable tail-nextp2 \ xt to execute for
   
 : output-gen ( -- )  : output-gen ( -- )
     \ generate C code for generating VM instructions      \ generate C code for generating VM instructions
     ." void gen_" prim prim-c-name 2@ type ." (Inst **ctp" gen-args-parm ." )" cr      ." void gen_" prim prim-c-name 2@ type ." ("
       threaded-code-pointer-type 2@ type ." ctp" gen-args-parm ." )" cr
     ." {" cr      ." {" cr
     ."   gen_inst(ctp, vm_prim[" function-number @ 0 .r ." ]);" cr      ."   gen_inst(ctp, " function-number @ 0 .r ." );" cr
     gen-args-gen      gen-args-gen
     ." }" cr ;      ." }" cr ;
   
Line 1800  nl-char singleton eof-char over add-memb Line 1809  nl-char singleton eof-char over add-memb
 (( letter (( letter || digit )) **  (( letter (( letter || digit )) **
 )) <- c-ident ( -- )  )) <- c-ident ( -- )
   
 (( ` # ?? (( letter || digit || ` : )) ++ (( ` . ` . ` . )) ??  (( ` . ` . ` .
   )) <- sync-stack ( -- )
   
   (( ` # ?? (( letter || digit || ` : )) ++ sync-stack ??
   || sync-stack
 )) <- stack-ident ( -- )  )) <- stack-ident ( -- )
   
 (( nowhitebq nowhite ** ))  (( nowhitebq nowhite ** ))

Removed from v.1.157  
changed lines
  Added in v.1.160


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>