class Malady::AST::LetNode

Attributes

bindings[R]
identifiers[R]
values[R]

Public Class Methods

new(filename, line, bindings, body) click to toggle source
Calls superclass method Malady::AST::FnNode::new
# 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

Public Instance Methods

bytecode(g) click to toggle source

A LetNode is basically a closure with its arguments applied to the bindings

Calls superclass method Malady::AST::FnNode#bytecode
# 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