--- gforth/prims2x.fs 2003/01/20 17:07:38 1.129 +++ gforth/prims2x.fs 2003/05/11 17:17:14 1.137 @@ -1,6 +1,6 @@ \ converts primitives to, e.g., C code -\ Copyright (C) 1995,1996,1997,1998,2000 Free Software Foundation, Inc. +\ Copyright (C) 1995,1996,1997,1998,2000,2003 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -51,8 +51,15 @@ \ (stack-in-index-xt and a test for stack==instruction-stream); there \ should be only one. +\ for backwards compatibility, jaw +require compat/strcomp.fs + warnings off +\ redefinitions of kernel words not present in gforth-0.6.1 +: latestxt lastcfa @ ; +: latest last @ ; + [IFUNDEF] try include startup.fs [THEN] @@ -63,7 +70,7 @@ warnings off \ warnings on include ./gray.fs -32 constant max-effect \ number of things on one side of a stack effect +128 constant max-effect \ number of things on one side of a stack effect 4 constant max-stacks \ the max. number of stacks (including inst-stream). 255 constant maxchar maxchar 1+ constant eof-char @@ -608,7 +615,7 @@ wordlist constant type-names \ this is h get-current type-names set-current stack-type 2dup nextname stack-type-name set-current - stack-pointer lastxt >body stack-name nextname make-stack ; + stack-pointer latestxt >body stack-name nextname make-stack ; stack inst-stream IP Cell ' inst-in-index inst-stream stack-in-index-xt ! @@ -631,11 +638,9 @@ stack inst-stream IP Cell : compute-offset-out ( addr1 addr2 -- ) ['] stack-out compute-offset ; -: clear-stack ( stack -- ) - dup stack-in off stack-out off ; - : compute-offsets ( -- ) - ['] clear-stack map-stacks + prim prim-stacks-in max-stacks cells erase + prim prim-stacks-out max-stacks cells erase prim prim-effect-in prim prim-effect-in-end @ ['] compute-offset-in map-items prim prim-effect-out prim prim-effect-out-end @ ['] compute-offset-out map-items inst-stream stack-out @ 0= s" # can only be on the input side" ?print-error ; @@ -1328,25 +1333,25 @@ print-token ! getinput member? ; ' testchar? test-vector ! -: checksyncline ( -- ) +: checksynclines ( -- ) \ when input points to a newline, check if the next line is a \ sync line. If it is, perform the appropriate actions. - rawinput @ >r - s" #line " r@ over compare if - rdrop 1 line +! EXIT - endif - 0. r> 6 chars + 20 >number drop >r drop line ! r> ( c-addr ) - dup c@ bl = if - char+ dup c@ [char] " <> 0= s" sync line syntax" ?print-error - char+ dup 100 [char] " scan drop swap 2dup - save-mem filename 2! - char+ - endif - dup c@ nl-char <> 0= s" sync line syntax" ?print-error - skipsynclines @ if - dup char+ rawinput ! - rawinput @ c@ cookedinput @ c! - endif - drop ; + rawinput @ begin >r + s" #line " r@ over compare if + rdrop 1 line +! EXIT + endif + 0. r> 6 chars + 20 >number drop >r drop line ! r> ( c-addr ) + dup c@ bl = if + char+ dup c@ [char] " <> 0= s" sync line syntax" ?print-error + char+ dup 100 [char] " scan drop swap 2dup - save-mem filename 2! + char+ + endif + dup c@ nl-char <> 0= s" sync line syntax" ?print-error + skipsynclines @ if + char+ dup rawinput ! + rawinput @ c@ cookedinput @ c! + endif + again ; : ?nextchar ( f -- ) s" syntax error, wrong char" ?print-error @@ -1355,10 +1360,11 @@ print-token ! 1 chars rawinput +! 1 chars cookedinput +! nl-char = if - checksyncline + checksynclines rawinput @ line-start ! endif - rawinput @ c@ cookedinput @ c! + rawinput @ c@ + cookedinput @ c! endif ; : charclass ( set "name" -- ) @@ -1503,13 +1509,24 @@ warnings @ [IF] \ process the string at addr u over dup rawinput ! dup line-start ! cookedinput ! + endrawinput ! - checksyncline + checksynclines primitives2something ; +: unixify ( c-addr u1 -- c-addr u2 ) + \ delete crs from the string + bounds tuck tuck ?do ( c-addr1 ) + i c@ dup #cr <> if + over c! char+ + else + drop + endif + loop + over - ; + : process-file ( addr u xt-simple x-combined -- ) output-combined ! output ! save-mem 2dup filename 2! - slurp-file + slurp-file unixify warnings @ if ." ------------ CUT HERE -------------" cr endif primfilter ;