mirror of
https://github.com/nineties/planckforth
synced 2024-12-25 21:58:22 +01:00
commit
20b5a8a123
3 changed files with 66 additions and 1 deletions
34
bootstrap.fs
34
bootstrap.fs
|
@ -2511,6 +2511,38 @@ need-defined (read)
|
|||
@ &latest !
|
||||
;
|
||||
|
||||
( === Private and Export === )
|
||||
|
||||
\ Words defined between private{ ... }private
|
||||
\ are invisible outside of this scope.
|
||||
\ You can export words using 'export'.
|
||||
\ : name .... ; export
|
||||
|
||||
: private{
|
||||
align
|
||||
latest ,
|
||||
here cell- &latest !
|
||||
s" private-marker" dup strlen
|
||||
c, strcpy, align
|
||||
;
|
||||
|
||||
: }private
|
||||
s" private-marker" find! name>link &latest !
|
||||
;
|
||||
|
||||
: export
|
||||
\ Move latest to the boottm of the dictionary.
|
||||
latest
|
||||
begin dup name>link while
|
||||
name>link
|
||||
repeat
|
||||
latest
|
||||
( last latest )
|
||||
dup name>link &latest !
|
||||
0 over !
|
||||
swap !
|
||||
;
|
||||
|
||||
( === Primitive Instructions === )
|
||||
|
||||
: insn:docol docol ;
|
||||
|
@ -2553,7 +2585,7 @@ need-defined (read)
|
|||
include included source >in
|
||||
next-arg shift-args arg argv argc version runtime copyright
|
||||
|
||||
[if] [unless] [else] [then] defined?
|
||||
[if] [unless] [else] [then] defined? private{ }private export
|
||||
open-file close-file write-file flush-file
|
||||
read-file key-file read-line
|
||||
R/W W/O R/O EOF
|
||||
|
|
|
@ -13,5 +13,7 @@ include test/utilities.fs
|
|||
include test/errorreport.fs
|
||||
include test/coreexttest.fs
|
||||
|
||||
include test/export.fs
|
||||
|
||||
report-errors
|
||||
report-and-exit
|
||||
|
|
31
test/export.fs
Normal file
31
test/export.fs
Normal file
|
@ -0,0 +1,31 @@
|
|||
\ planckforth -
|
||||
\ Copyright (C) 2021 nineties
|
||||
|
||||
testing private and export
|
||||
|
||||
: f1 ;
|
||||
private{
|
||||
|
||||
: f2 ;
|
||||
|
||||
T{ defined? f1 -> true }T
|
||||
T{ defined? f2 -> true }T
|
||||
|
||||
private{
|
||||
|
||||
: f3 ;
|
||||
|
||||
T{ defined? f2 -> true }T
|
||||
T{ defined? f3 -> true }T
|
||||
|
||||
}private
|
||||
|
||||
T{ defined? f1 -> true }T
|
||||
T{ defined? f2 -> true }T
|
||||
T{ defined? f3 -> false }T
|
||||
|
||||
}private
|
||||
|
||||
T{ defined? f1 -> true }T
|
||||
T{ defined? f2 -> false }T
|
||||
T{ defined? f3 -> false }T
|
Loading…
Reference in a new issue