replace swap drop by nip

This commit is contained in:
Koichi Nakamura 2021-01-09 17:19:51 +09:00
parent 4ed2d629db
commit 5d43fa67ed

View file

@ -547,7 +547,7 @@ alias-builtin xor ^
: swap sp@ cell + dup @ >r ! r> ; \ ( a b -- b a ) : swap sp@ cell + dup @ >r ! r> ; \ ( a b -- b a )
: rot >r swap r> swap ; \ ( a b c -- b c a ) : rot >r swap r> swap ; \ ( a b c -- b c a )
: -rot swap >r swap r> ; \ ( a b c -- c a b ) : -rot swap >r swap r> ; \ ( a b c -- c a b )
: nip swap drop ; \ ( a b -- a ) : nip swap drop ; \ ( a b -- b )
: over >r dup r> swap ; \ ( a b -- a b a ) : over >r dup r> swap ; \ ( a b -- a b a )
: tuck dup -rot ; \ ( a b -- b a b ) : tuck dup -rot ; \ ( a b -- b a b )
: pick cells sp@ + cell + @ ; \ ( wu ... x0 u -- xu ... x0 xu ) : pick cells sp@ + cell + @ ; \ ( wu ... x0 u -- xu ... x0 xu )
@ -1030,7 +1030,7 @@ decimal \ set default to decimal
'a' 'z' rangeof 'a' - 10 + endof 'a' 'z' rangeof 'a' - 10 + endof
'A' 'Z' rangeof 'A' - 10 + endof 'A' 'Z' rangeof 'A' - 10 + endof
\ failed to convert \ failed to convert
2drop r> r> swap drop false 2drop r> r> nip false
exit exit
endcase endcase
2dup 2dup
@ -1039,7 +1039,7 @@ decimal \ set default to decimal
\ ( base n 0 base n ) \ ( base n 0 base n )
within unless within unless
\ failed to convert \ failed to convert
2drop r> r> swap drop false 2drop r> r> nip false
exit exit
then then
\ ( base addr n acc ) \ ( base addr n acc )
@ -1047,9 +1047,7 @@ decimal \ set default to decimal
3 pick * + 3 pick * +
repeat repeat
\ success \ success
swap drop nip nip true
swap drop
true
; ;
\ Parse string as number. \ Parse string as number.
@ -1258,7 +1256,7 @@ create word-buffer s" 64" >number drop cell+ allot drop
dup find \ lookup dictionary dup find \ lookup dictionary
?dup if ?dup if
\ Found the word \ Found the word
swap drop nip
state @ if state @ if
\ compile mode \ compile mode
dup cell+ c@ immediate-bit and if dup cell+ c@ immediate-bit and if
@ -1638,7 +1636,7 @@ stdin_ push-inputstream
dup find \ lookup dictionary dup find \ lookup dictionary
?dup if ?dup if
\ Found the word \ Found the word
swap drop nip
state @ if state @ if
\ compile mode \ compile mode
dup cell+ c@ immediate-bit and if dup cell+ c@ immediate-bit and if