Add "enum"

This commit is contained in:
Koichi Nakamura 2021-12-08 06:11:20 +09:00
parent ec930cd3a1
commit a41845693f
2 changed files with 20 additions and 0 deletions

View file

@ -40,4 +40,18 @@ end-struct cons-cell%
: car first @ ; export
: cdr second @ ; export
( === Enum === )
\ 0
\ enum A
\ enum B
\ drop
\ 0 constant A
\ 1 constant B
: enum ( n "name" -- n )
dup constant 1+
; export
}private

View file

@ -1013,4 +1013,10 @@ T{ cons0 cdr -> 1 }T
cons0 free
\ ------------------------------------------------------------------------
testing enum
T{ 0 enum e0 enum e1 enum e2 drop -> }T
T{ e0 -> 0 }T
T{ e1 -> 1 }T
T{ e2 -> 2 }T