Handbook
Glossary
trivial-branch? ( nodes -- value ? )
Vocabulary
compiler
.
cfg
.
builder
Inputs
nodes
a
sequence
of
node
instances
Outputs
value
the pushed value or
f
?
a
boolean
Word description
Checks whether nodes is a trivial branch or not. The branch is counted as trivial if all it does is push a literal value on the stack.
Examples
USING: compiler.cfg.builder compiler.tree prettyprint ; { T{ #push { literal 25 } } } trivial-branch? . .
t 25
Definition
USING:
accessors
compiler.tree
kernel
sequences
;
IN:
compiler.cfg.builder
:
trivial-branch?
( nodes -- value ? )
dup
length
1
=
[
first
dup
#push?
[
literal>>
t
]
[
drop
f
f
]
if
]
[
drop
f
f
]
if
;