diff options
author | Thomas Huth <thuth@linux.vnet.ibm.com> | 2011-10-17 13:42:53 +0200 |
---|---|---|
committer | Thomas Huth <thuth@linux.vnet.ibm.com> | 2011-11-17 12:09:57 +0100 |
commit | a02ee1cc21077e89d5e9ba80572ed1208c98777d (patch) | |
tree | 569cfdba7a042dc9f3c7ad5590ffa5caa8f93d2a | |
parent | c140913ecec3cbba27793a65a5c7d0562c16a3ba (diff) | |
download | SLOF-a02ee1cc21077e89d5e9ba80572ed1208c98777d.zip SLOF-a02ee1cc21077e89d5e9ba80572ed1208c98777d.tar.gz SLOF-a02ee1cc21077e89d5e9ba80572ed1208c98777d.tar.bz2 |
FCODE evaluator source code beautification and clean-up
Fixed bad indentation and white space damages in the FCODE evaluator source
code. Also removed the redundant definitions of <value>, <variable>, etc. which
are defined in base.fs already.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
-rw-r--r-- | slof/fs/fcode/1275.fs | 124 | ||||
-rw-r--r-- | slof/fs/fcode/big.fs | 58 | ||||
-rw-r--r-- | slof/fs/fcode/core.fs | 35 | ||||
-rw-r--r-- | slof/fs/fcode/evaluator.fs | 22 |
4 files changed, 120 insertions, 119 deletions
diff --git a/slof/fs/fcode/1275.fs b/slof/fs/fcode/1275.fs index ace0933..d4c8cb9 100644 --- a/slof/fs/fcode/1275.fs +++ b/slof/fs/fcode/1275.fs @@ -1,5 +1,5 @@ \ ***************************************************************************** -\ * Copyright (c) 2004, 2008 IBM Corporation +\ * Copyright (c) 2004, 2011 IBM Corporation \ * All rights reserved. \ * This program and the accompanying materials \ * are made available under the terms of the BSD License @@ -10,18 +10,6 @@ \ * IBM Corporation - initial implementation \ ****************************************************************************/ -0 value function-type ' function-type @ constant <value> - variable function-type ' function-type @ constant <variable> -0 constant function-type ' function-type @ constant <constant> -: function-type ; ' function-type @ constant <colon> -create function-type ' function-type @ constant <create> -defer function-type ' function-type @ constant <defer> - -\ variable tmp-buf-current -\ variable orig-here -\ create tmp-buf 10000 allot - -( ---------------------------------------------------- ) : fcode-revision ( -- n ) 00030000 \ major * 65536 + minor @@ -51,7 +39,7 @@ defer function-type ' function-type @ constant <defer> : dest-on-top 0 >r BEGIN dup @ 0= WHILE >r REPEAT - BEGIN r> dup WHILE swap REPEAT + BEGIN r> dup WHILE swap REPEAT drop ; @@ -64,29 +52,39 @@ defer function-type ' function-type @ constant <defer> ; : b?branch ( flag -- ) - ?compile-mode IF - read-fcode-offset ?negative IF dest-on-top postpone until - ELSE postpone if - THEN - ELSE - ?branch IF 2 jump-n-ip - ELSE read-fcode-offset - ?jump-direction 2- jump-n-ip - THEN - THEN - ; immediate + ?compile-mode IF + read-fcode-offset ?negative IF + dest-on-top postpone until + ELSE + postpone if + THEN + ELSE + ?branch IF + 2 jump-n-ip + ELSE + read-fcode-offset + ?jump-direction 2- jump-n-ip + THEN + THEN +; immediate : bbranch ( -- ) - ?compile-mode IF - read-fcode-offset - ?negative IF dest-on-top postpone again - ELSE postpone else - get-ip next-ip fcode@ B2 = IF drop ELSE set-ip THEN - THEN - ELSE - read-fcode-offset ?jump-direction 2- jump-n-ip - THEN - ; immediate + ?compile-mode IF + read-fcode-offset + ?negative IF + dest-on-top postpone again + ELSE + postpone else + get-ip next-ip fcode@ B2 = IF + drop + ELSE + set-ip + THEN + THEN + ELSE + read-fcode-offset ?jump-direction 2- jump-n-ip + THEN +; immediate : b(<mark) ( -- ) ?compile-mode IF postpone begin THEN @@ -126,7 +124,7 @@ defer function-type ' function-type @ constant <defer> : b1(;) ( -- ) ." b1(;)" cr - rpop set-ip + rpop set-ip ; \ : b1(:) ( -- ) @@ -136,7 +134,7 @@ defer function-type ' function-type @ constant <defer> \ ; immediate : b(;) ( -- ) - postpone exit reveal postpone [ + postpone exit reveal postpone [ ; immediate : b(:) ( -- ) @@ -158,27 +156,27 @@ defer function-type ' function-type @ constant <defer> : b(endof) postpone endof - read-fcode-offset drop + read-fcode-offset drop ; immediate : b(do) postpone do - read-fcode-offset drop + read-fcode-offset drop ; immediate : b(?do) postpone ?do - read-fcode-offset drop + read-fcode-offset drop ; immediate : b(loop) postpone loop - read-fcode-offset drop + read-fcode-offset drop ; immediate : b(+loop) postpone +loop - read-fcode-offset drop + read-fcode-offset drop ; immediate : b(leave) @@ -189,7 +187,7 @@ defer function-type ' function-type @ constant <defer> align here next-ip read-fcode# 0 swap set-token ; -: external-token ( -- ) \ named local fcode function +: external-token ( -- ) \ named local fcode function next-ip read-fcode-string header ( str len -- ) \ create a header in the current dictionary entry new-token @@ -226,7 +224,7 @@ defer function-type ' function-type @ constant <defer> ; : undefined-defer - cr cr ." Unititialized defer word has been executed!" cr cr + cr cr ." Unititialized defer word has been executed!" cr cr true fcode-end ! ; @@ -236,7 +234,7 @@ defer function-type ' function-type @ constant <defer> ; : b(create) - <variable> , + <variable> , postpone noop reveal ; @@ -269,13 +267,13 @@ defer function-type ' function-type @ constant <defer> offset16 read-header ; - + : start1 ( -- ) 1 to fcode-spread offset16 read-header ; - + : start2 ( -- ) 2 to fcode-spread offset16 @@ -288,12 +286,12 @@ defer function-type ' function-type @ constant <defer> read-header ; -: end0 ( -- ) - true fcode-end ! +: end0 ( -- ) + true fcode-end ! ; -: end1 ( -- ) - end0 +: end1 ( -- ) + end0 ; : ferror ( -- ) @@ -309,7 +307,7 @@ defer function-type ' function-type @ constant <defer> ; : byte-load ( addr xt -- ) - >r >r + >r >r save-evaluator-state r> r> reset-fcode-end @@ -319,19 +317,21 @@ defer function-type ' function-type @ constant <defer> reset-local-fcodes depth >r evaluate-fcode - r> depth 1- <> IF clear end0 - cr ." Ambiguous stack depth after byte-load!" - cr ." FCode evaluation aborted." cr cr - ELSE restore-evaluator-state - THEN - ['] c@ to fcode-rb@ + r> depth 1- <> IF + clear end0 + cr ." Ambiguous stack depth after byte-load!" + cr ." FCode evaluation aborted." cr cr + ELSE + restore-evaluator-state + THEN + ['] c@ to fcode-rb@ ; create byte-load-test-fcode f1 c, 08 c, 18 c, 69 c, 00 c, 00 c, 00 c, 68 c, -12 c, 16 c, 62 c, 79 c, 74 c, 65 c, 2d c, 6c c, -6f c, 61 c, 64 c, 2d c, 74 c, 65 c, 73 c, 74 c, -2d c, 66 c, 63 c, 6f c, 64 c, 65 c, 21 c, 21 c, +12 c, 16 c, 62 c, 79 c, 74 c, 65 c, 2d c, 6c c, +6f c, 61 c, 64 c, 2d c, 74 c, 65 c, 73 c, 74 c, +2d c, 66 c, 63 c, 6f c, 64 c, 65 c, 21 c, 21 c, 90 c, 92 c, ( a6 c, a7 c, 2e c, ) 00 c, : byte-load-test @@ -347,7 +347,7 @@ f1 c, 08 c, 18 c, 69 c, 00 c, 00 c, 00 c, 68 c, drop true ELSE false - THEN + THEN ; ( ---------------------------------------------------- ) diff --git a/slof/fs/fcode/big.fs b/slof/fs/fcode/big.fs index 00eb570..acd5110 100644 --- a/slof/fs/fcode/big.fs +++ b/slof/fs/fcode/big.fs @@ -1,5 +1,5 @@ \ ***************************************************************************** -\ * Copyright (c) 2004, 2008 IBM Corporation +\ * Copyright (c) 2004, 2011 IBM Corporation \ * All rights reserved. \ * This program and the accompanying materials \ * are made available under the terms of the BSD License @@ -15,31 +15,39 @@ ( ---------------------------------------------------- ) : read-fcode-num16 ( -- n ) - 0 fcode-num ! - ?arch64 IF - read-byte fcode-num 6 + C! - next-ip read-byte fcode-num 7 + C! - ELSE - read-byte fcode-num 2 + C! - next-ip read-byte fcode-num 3 + C! - THEN - fcode-num @ - ; + 0 fcode-num ! + ?arch64 IF + read-byte fcode-num 6 + C! + next-ip + read-byte fcode-num 7 + C! + ELSE + read-byte fcode-num 2 + C! + next-ip + read-byte fcode-num 3 + C! + THEN + fcode-num @ +; : read-fcode-num32 ( -- n ) - 0 fcode-num ! - ?arch64 IF - read-byte fcode-num 4 + C! - next-ip read-byte fcode-num 5 + C! - next-ip read-byte fcode-num 6 + C! - next-ip read-byte fcode-num 7 + C! - ELSE - read-byte fcode-num 0 + C! - next-ip read-byte fcode-num 1 + C! - next-ip read-byte fcode-num 2 + C! - next-ip read-byte fcode-num 3 + C! - THEN - fcode-num @ - ; + 0 fcode-num ! + ?arch64 IF + read-byte fcode-num 4 + C! + next-ip + read-byte fcode-num 5 + C! + next-ip + read-byte fcode-num 6 + C! + next-ip + read-byte fcode-num 7 + C! + ELSE + read-byte fcode-num 0 + C! + next-ip + read-byte fcode-num 1 + C! + next-ip + read-byte fcode-num 2 + C! + next-ip + read-byte fcode-num 3 + C! + THEN + fcode-num @ +; ( ---------------------------------------------------- ) diff --git a/slof/fs/fcode/core.fs b/slof/fs/fcode/core.fs index 79d47c3..c0d0ebe 100644 --- a/slof/fs/fcode/core.fs +++ b/slof/fs/fcode/core.fs @@ -20,7 +20,7 @@ : ?bigendian ( -- true|false ) deadbeef fcode-num ! - fcode-num ?arch64 IF 4 + THEN + fcode-num ?arch64 IF 4 + THEN c@ de = ; @@ -57,12 +57,12 @@ fcode-end @ eva-debug? IF ." saved fcode-end " dup . cr THEN fcode-offset eva-debug? IF ." saved fcode-offset " dup . cr THEN \ local fcodes are currently NOT saved! - fcode-spread eva-debug? IF ." saved fcode-spread " dup . cr THEN + fcode-spread eva-debug? IF ." saved fcode-spread " dup . cr THEN ['] fcode@ behavior eva-debug? IF ." saved fcode@ " dup . cr THEN ; : restore-evaluator-state - eva-debug? IF ." restored fcode@ " dup . cr THEN to fcode@ + eva-debug? IF ." restored fcode@ " dup . cr THEN to fcode@ eva-debug? IF ." restored fcode-spread " dup . cr THEN to fcode-spread \ local fcodes are currently NOT restored! eva-debug? IF ." restored fcode-offset " dup . cr THEN to fcode-offset @@ -99,25 +99,24 @@ token-table-index @ split-immediate ; --1 VALUE break-fcode-addr - +-1 VALUE break-fcode-addr + : exec ( FCode# -- ) - eva-debug? IF dup get-ip 8 u.r ." : " ." [" 3 u.r ." ] " THEN get-ip break-fcode-addr = IF - TRUE fcode-end ! drop EXIT + TRUE fcode-end ! drop EXIT THEN - + get-token 0= IF \ imm == 0 == false ?compile-mode IF - compile, + compile, ELSE - eva-debug? IF dup xt>name type space THEN - execute + eva-debug? IF dup xt>name type space THEN + execute THEN ELSE \ immediate eva-debug? IF dup xt>name type space THEN @@ -140,8 +139,8 @@ : read-header ( adr -- ) next-ip read-byte drop - next-ip read-fcode-num16 drop - next-ip read-fcode-num32 drop + next-ip read-fcode-num16 drop + next-ip read-fcode-num32 drop ; : read-fcode-string ( -- str len ) @@ -160,10 +159,10 @@ ; : step-fcode ( -- ) - break-fcode-addr >r -1 to break-fcode-addr + break-fcode-addr >r -1 to break-fcode-addr fcode@ exec next-ip - r> to break-fcode-addr -; - - + r> to break-fcode-addr +; + + ( ---------------------------------------------------- ) diff --git a/slof/fs/fcode/evaluator.fs b/slof/fs/fcode/evaluator.fs index ac2c983..2f8a56e 100644 --- a/slof/fs/fcode/evaluator.fs +++ b/slof/fs/fcode/evaluator.fs @@ -10,12 +10,6 @@ \ * IBM Corporation - initial implementation \ ****************************************************************************/ -( eva - gordons fcode bytecode evaluator ) - -hex - --1 constant true - 0 constant false variable ip variable fcode-end @@ -101,12 +95,12 @@ include tokens.fs ; : execute-rom-fcode ( addr len | false -- ) - reset-fcode-end - ?dup IF - diagnostic-mode? IF ." , executing ..." cr THEN - dup >r r@ alloc-mem dup >r swap rmove - r@ set-ip evaluate-fcode - diagnostic-mode? IF ." Done." cr THEN - r> r> free-mem - THEN + reset-fcode-end + ?dup IF + diagnostic-mode? IF ." , executing ..." cr THEN + dup >r r@ alloc-mem dup >r swap rmove + r@ set-ip evaluate-fcode + diagnostic-mode? IF ." Done." cr THEN + r> r> free-mem + THEN ; |