Diff for /gforth/prims2x.fs between versions 1.149 and 1.155

version 1.149, 2004/01/20 19:07:41 version 1.155, 2005/01/26 21:24:15
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 Free Software Foundation, Inc.  \ Copyright (C) 1995,1996,1997,1998,2000,2003,2004 Free Software Foundation, Inc.
   
 \ This file is part of Gforth.  \ This file is part of Gforth.
   
Line 913  variable tail-nextp2 \ xt to execute for Line 913  variable tail-nextp2 \ xt to execute for
   
 : output-label2 ( -- )  : output-label2 ( -- )
     ." LABEL2(" prim prim-c-name 2@ type ." )" cr      ." LABEL2(" prim prim-c-name 2@ type ." )" cr
     ." NEXT_P2;" cr ;      ." NEXT_P1_5;" cr
       ." LABEL3(" prim prim-c-name 2@ type ." )" cr
       ." DO_GOTO;" cr ;
   
 : output-c-tail1 { xt -- }  : output-c-tail1 { xt -- }
     \ the final part of the generated C code, with xt printing LABEL2 or not.      \ the final part of the generated C code, with xt printing LABEL2 or not.
Line 924  variable tail-nextp2 \ xt to execute for Line 926  variable tail-nextp2 \ xt to execute for
     fill-state       fill-state 
     xt execute ;      xt execute ;
   
   : output-c-vm-jump-tail ( -- )
       \ !! this functionality not yet implemented for superinstructions
       output-super-end
       print-debug-results
       stores
       fill-state 
       ." LABEL2(" prim prim-c-name 2@ type ." )" cr
       ." LABEL3(" prim prim-c-name 2@ type ." )" cr
       ." DO_GOTO;" cr ;
   
 : output-c-tail1-no-stores { xt -- }  : output-c-tail1-no-stores { xt -- }
     \ the final part of the generated C code for combinations      \ the final part of the generated C code for combinations
     output-super-end      output-super-end
Line 935  variable tail-nextp2 \ xt to execute for Line 947  variable tail-nextp2 \ xt to execute for
     tail-nextp2 @ output-c-tail1 ;      tail-nextp2 @ output-c-tail1 ;
   
 : output-c-tail2 ( -- )  : output-c-tail2 ( -- )
     ['] output-label2 output-c-tail1 ;      prim prim-c-code 2@ s" VM_JUMP(" search nip nip if
           output-c-vm-jump-tail
       else
           ['] output-label2 output-c-tail1
       endif ;
   
 : output-c-tail-no-stores ( -- )  : output-c-tail-no-stores ( -- )
     tail-nextp2 @ output-c-tail1-no-stores ;      tail-nextp2 @ output-c-tail1-no-stores ;
Line 962  variable tail-nextp2 \ xt to execute for Line 978  variable tail-nextp2 \ xt to execute for
   
 : print-entry ( -- )  : print-entry ( -- )
     ." LABEL(" prim prim-c-name 2@ type ." )" ;      ." LABEL(" prim prim-c-name 2@ type ." )" ;
       
   : prim-type ( addr u -- )
       \ print out a primitive, but avoid "*/"
       2dup s" */" search  nip nip  IF
           bounds ?DO  I c@ dup '* = IF  drop 'x  THEN  emit  LOOP
       ELSE  type  THEN ;
   
 : output-c ( -- )   : output-c ( -- ) 
     print-entry ."  /* " prim prim-name 2@ type      print-entry ."  /* " prim prim-name 2@ prim-type
     ."  ( " prim prim-stack-string 2@ type ." ) "      ."  ( " prim prim-stack-string 2@ type ." ) "
     state-in .state ." -- " state-out .state ."  */" cr      state-in .state ." -- " state-out .state ."  */" cr
     ." /* " prim prim-doc 2@ type ."  */" cr      ." /* " prim prim-doc 2@ type ."  */" cr
Line 1044  variable tail-nextp2 \ xt to execute for Line 1066  variable tail-nextp2 \ xt to execute for
     prim prim-branch?      prim prim-branch?
     prim prim-c-code 2@  s" SUPER_END" search nip nip 0<> or      prim prim-c-code 2@  s" SUPER_END" search nip nip 0<> or
     prim prim-c-code 2@  s" SUPER_CONTINUE" search nip nip 0= and      prim prim-c-code 2@  s" SUPER_CONTINUE" search nip nip 0= and
     negate 0 .r ." , /* " prim prim-name 2@ type ."  */" cr ;      negate 0 .r ." , /* " prim prim-name 2@ prim-type ."  */" cr ;
   
 : gen-arg-parm { item -- }  : gen-arg-parm { item -- }
     item item-stack @ inst-stream = if      item item-stack @ inst-stream = if
Line 1450  variable reprocessed-num 0 reprocessed-n Line 1472  variable reprocessed-num 0 reprocessed-n
   
 : output-part ( p -- )  : output-part ( p -- )
     to prim      to prim
     ." /* " prim prim-name 2@ type ."  ( " prim prim-stack-string 2@ type ." ) */" cr      ." /* " prim prim-name 2@ prim-type ."  ( " prim prim-stack-string 2@ type ." ) */" cr
     ." NAME(" quote prim prim-name 2@ type quote ." )" cr \ debugging      ." NAME(" quote prim prim-name 2@ type quote ." )" cr \ debugging
     ." {" cr      ." {" cr
     print-declarations      print-declarations
Line 1558  variable reprocessed-num 0 reprocessed-n Line 1580  variable reprocessed-num 0 reprocessed-n
     \ prim-num @ 4 .r ." ," ;      \ prim-num @ 4 .r ." ," ;
   
 : output-name-comment ( -- )  : output-name-comment ( -- )
     ."  /* " prim prim-name 2@ type ."  */" ;      ."  /* " prim prim-name 2@ prim-type ."  */" ;
   
 variable offset-super2  0 offset-super2 ! \ offset into the super2 table  variable offset-super2  0 offset-super2 ! \ offset into the super2 table
   
Line 1567  variable offset-super2  0 offset-super2 Line 1589  variable offset-super2  0 offset-super2
     rot 2 .r ." ," swap 2 .r ." ," 2 .r ." , "      rot 2 .r ." ," swap 2 .r ." ," 2 .r ." , "
     prim prim-branch? negate . ." ,"      prim prim-branch? negate . ." ,"
     state-in  state-number @ 2 .r ." ,"      state-in  state-number @ 2 .r ." ,"
     state-out state-number @ 2 .r ." ," ;      state-out state-number @ 2 .r ." ,"
       inst-stream stack-in @ 1 .r ." ,"
   ;
   
 : output-costs-gforth-simple ( -- )  : output-costs-gforth-simple ( -- )
     output-costs-prefix      output-costs-prefix
Line 1583  variable offset-super2  0 offset-super2 Line 1607  variable offset-super2  0 offset-super2
     output-name-comment      output-name-comment
     cr ;      cr ;
   
 : output-costs ( -- )  \  : output-costs ( -- )
     \ description of superinstructions and simple instructions  \      \ description of superinstructions and simple instructions
     ." {" prim compute-costs  \      ." {" prim compute-costs
     rot 2 .r ." ," swap 2 .r ." ," 2 .r ." ,"  \      rot 2 .r ." ," swap 2 .r ." ," 2 .r ." ,"
     offset-super2 @ 5 .r ." ,"  \      offset-super2 @ 5 .r ." ,"
     super2-length dup 2 .r ." }," offset-super2 +!  \      super2-length dup 2 .r ." ," offset-super2 +!
     output-name-comment  \      inst-stream stack-in @ 1 .r ." },"
     cr ;  \      output-name-comment
   \      cr ;
   
 : output-super2-simple ( -- )  : output-super2-simple ( -- )
     prim prim-c-name 2@ prim prim-c-name-orig 2@ d= if      prim prim-c-name 2@ prim prim-c-name-orig 2@ d= if

Removed from v.1.149  
changed lines
  Added in v.1.155


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