class RenameRewriter

Look for rename statements and define the necessary scratch collections

Public Class Methods

new(bud_instance) click to toggle source
Calls superclass method
# File lib/bud/rewrite.rb, line 315
def initialize(bud_instance)
  super()
  self.require_empty = false
  self.expected = Sexp
  @bud_instance = bud_instance
end

Public Instance Methods

process_call(exp) click to toggle source
# File lib/bud/rewrite.rb, line 332
def process_call(exp)
  tag, recv, op, *args = exp

  if op == :rename
    raise Bud::CompileError, "reduce takes two arguments" unless args.size == 2
    namelit, schemahash = args
    register_scratch(namelit[1], schemahash)
  end

  return s(tag, process(recv), op, *(args.map{|a| process(a)}))
end
register_scratch(name, schemahash) click to toggle source
# File lib/bud/rewrite.rb, line 322
def register_scratch(name, schemahash)
  # define a scratch with the name and schema in this rename block
  hash, key_array, val_array = schemahash
  key_array ||= []
  val_array ||= []
  key_cols = key_array.map{|i| i[1] if i.class <= Sexp}.compact
  val_cols = val_array.map{|i| i[1] if i.class <= Sexp}.compact
  @bud_instance.scratch(name, key_cols=>val_cols)
end