--- gforth/kernel/int.fs 2011/11/24 18:12:12 1.185 +++ gforth/kernel/int.fs 2012/12/31 15:25:19 1.195 @@ -1,6 +1,6 @@ \ definitions needed for interpreter only -\ Copyright (C) 1995-2000,2004,2005,2007,2009,2010 Free Software Foundation, Inc. +\ Copyright (C) 1995-2000,2004,2005,2007,2009,2010,2012 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -143,7 +143,7 @@ has? os 0= [IF] WHILE \ there are characters left dup r> - WHILE \ the last >number parsed something - dup 1- dpl ! over c@ [char] . = + dup 1- dpl ! over c@ dp-char @ = WHILE \ the current char is '.' 1 /string REPEAT THEN \ there are unparseable characters left @@ -457,7 +457,7 @@ const Create ??? 0 , 3 , char ? c, char name>string dup $20 $1 within if rdrop 2drop false exit \ realistically the name is short then - cfaligned 2dup bounds ?do \ should be a printable string + over + cfaligned over - 2dup bounds ?do \ should be a printable string i c@ bl < if 2drop unloop rdrop false exit then @@ -650,7 +650,6 @@ Defer parser1 ( c-addr u -- ... xt) : parser ( c-addr u -- ... ) \ text-interpret the word/number c-addr u, possibly producing a number parser1 execute ; - has? ec [IF] ' (name) Alias parse-name : no.extensions 2drop -&13 throw ; @@ -681,11 +680,17 @@ Defer interpreter-notfound1 ( c-addr cou Defer before-word ( -- ) \ gforth \ called before the text interpreter parses the next word ' noop IS before-word + +Defer before-line ( -- ) \ gforth +\ called before the text interpreter parses the next line +' noop IS before-line + [THEN] has? backtrace [IF] : interpret1 ( ... -- ... ) rp@ backtrace-rp0 ! + [ has? EC 0= [IF] ] before-line [ [THEN] ] BEGIN ?stack [ has? EC 0= [IF] ] before-word [ [THEN] ] parse-name dup WHILE @@ -882,7 +887,7 @@ has? os [IF] [ has? OS [IF] ] >stderr [ [THEN] ] cr ." Can't print to stdout, leaving" cr \ if stderr does not work either, already DoError causes a hang - 2 (bye) + -2 (bye) endif [ [THEN] ] refill WHILE interpret prompt @@ -964,12 +969,14 @@ Defer dobacktrace ( -- ) ELSE .error THEN ; +[IFUNDEF] umin : umin ( u1 u2 -- u ) 2dup u> if swap then drop ; +[THEN] Defer mark-start Defer mark-end @@ -1066,11 +1073,18 @@ Defer mark-end [ [ELSE] ] r> >tib ! [ [THEN] ] ; +: do-execute ( xt -- ) \ Gforth + \G C calling us + catch dup IF DoError cr THEN (bye) ; + +: do-find ( addr u -- ) + find-name dup IF name>int THEN (bye) ; + \ \ Cold Boot 13feb93py -: (bootmessage) ( -- ) +: gforth ( -- ) ." Gforth " version-string type - ." , Copyright (C) 1995-2011 Free Software Foundation, Inc." cr + ." , Copyright (C) 1995-2012 Free Software Foundation, Inc." cr ." Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'" [ has? os [IF] ] cr ." Type `bye' to exit" @@ -1085,7 +1099,7 @@ has? file [IF] defer process-args [THEN] -' (bootmessage) IS bootmessage +' gforth IS bootmessage has? os [IF] Defer 'cold ( -- ) \ gforth tick-cold @@ -1110,8 +1124,7 @@ Defer 'cold ( -- ) \ gforth tick-cold process-args loadline off [ [THEN] ] - bootmessage - quit ; + 1 (bye) ; has? new-input 0= [IF] : clear-tibstack ( -- ) @@ -1130,7 +1143,14 @@ has? new-input 0= [IF] : boot ( path n **argv argc -- ) [ has? no-userspace 0= [IF] ] - main-task up! + next-task 0= IF main-task up! + ELSE + next-task @ 0= IF + throw-entry main-task udp @ throw-entry next-task - + /string >r swap r> move + next-task dup next-task 2! normal-dp dpp ! + THEN + THEN [ [THEN] ] [ has? os [IF] ] os-boot @@ -1163,7 +1183,7 @@ has? new-input 0= [IF] cold [ [THEN] ] [ has? os [IF] ] - 1 (bye) \ !! determin exit code from throw code? + -1 (bye) \ !! determin exit code from throw code? [ [THEN] ] ;