#loc to replace current source location

parent 33365372
......@@ -2136,6 +2136,9 @@ X has? f83headerstring [IF]
[IFDEF] loadfilename# loadfilename# off [THEN]
s" kernel/main.fs" h-add-included-file ;
: tsourcepos1 ( -- xpos )
[IFDEF] replace-sourcepos1
replace-sourcepos1 0 to replace-sourcepos1 ?dup ?EXIT
[THEN]
[IFDEF] loadfilename# loadfilename# @
[ELSE] sourcefilename str>loadfilename# [THEN]
sourceline#
......@@ -4033,6 +4036,10 @@ Variable outfile-fd
: KB 400 * ;
[IFDEF] #loc
' #loc alias #loc
[THEN]
\ \ [IF] [ELSE] [THEN] ... 14sep97jaw
\ it is useful to define our own structures and not to rely
......
......@@ -324,3 +324,12 @@ Defer view ( "name" -- ) \ gforth
' view alias locate ( "name" -- ) \ forth inc
\G directly view the source in the curent terminal
\ insert a different location
: #loc ( nline nchar "file" -- )
\G set next word's location to @var{nline nchar} in @var{"file"}
parse-name 2dup str>loadfilename# dup 0< IF
drop add-included-file included-files $[]# 1-
ELSE nip nip THEN
-rot encode-pos1 to replace-sourcepos1 ;
\ No newline at end of file
......@@ -141,8 +141,11 @@ variable next-prelude
: encode-pos1 ( nfile nline nchar -- xpos )
encode-pos $7fffff min swap 23 lshift or ;
0 Value replace-sourcepos1
: current-sourcepos1 ( -- xpos )
current-sourcepos3 encode-pos1 ;
replace-sourcepos1 dup IF 0 to replace-sourcepos1 EXIT THEN
drop current-sourcepos3 encode-pos1 ;
: view, ( -- ) current-sourcepos1 , ;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment