Class: Malady::AST::LetNode
Instance Attribute Summary collapse
-
#bindings ⇒ Object
readonly
Returns the value of attribute bindings.
-
#identifiers ⇒ Object
readonly
Returns the value of attribute identifiers.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Attributes inherited from FnNode
Attributes inherited from Node
Instance Method Summary collapse
-
#bytecode(g) ⇒ Object
A LetNode is basically a closure with its arguments applied to the bindings.
-
#initialize(filename, line, bindings, body) ⇒ LetNode
constructor
A new instance of LetNode.
Methods inherited from FnNode
Methods inherited from Node
Constructor Details
#initialize(filename, line, bindings, body) ⇒ LetNode
Returns a new instance of LetNode.
257 258 259 260 261 262 |
# File 'lib/malady/ast.rb', line 257 def initialize(filename, line, bindings, body) @bindings = bindings @identifiers = @bindings.map(&:first) @values = @bindings.map(&:last) super(filename, line, identifiers, body) end |
Instance Attribute Details
#bindings ⇒ Object (readonly)
Returns the value of attribute bindings.
255 256 257 |
# File 'lib/malady/ast.rb', line 255 def bindings @bindings end |
#identifiers ⇒ Object (readonly)
Returns the value of attribute identifiers.
255 256 257 |
# File 'lib/malady/ast.rb', line 255 def identifiers @identifiers end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
255 256 257 |
# File 'lib/malady/ast.rb', line 255 def values @values end |
Instance Method Details
#bytecode(g) ⇒ Object
A LetNode is basically a closure with its arguments applied to the bindings
265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/malady/ast.rb', line 265 def bytecode(g) super(g) # compile bindings' values @values.each do |val| val.bytecode(g) end # send :call to the block g.send :call, @bindings.count end |