Class: Johnson::Visitors::SexpVisitor

Inherits:
Object
  • Object
show all
Defined in:
lib/johnson/visitors/sexp_visitor.rb

Instance Method Summary collapse

Instance Method Details

#accept(target) ⇒ Object



169
170
171
# File 'lib/johnson/visitors/sexp_visitor.rb', line 169

def accept(target)
  target.accept(self)
end

#visit_For(o) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/johnson/visitors/sexp_visitor.rb', line 48

def visit_For(o)
  [ :for,
    o.init && o.init.accept(self),
    o.cond && o.cond.accept(self),
    o.update && o.update.accept(self),
    o.body.accept(self)
  ]
end

#visit_ForIn(o) ⇒ Object



57
58
59
60
61
62
# File 'lib/johnson/visitors/sexp_visitor.rb', line 57

def visit_ForIn(o)
  [ :for_in,
    o.in_cond.accept(self),
    o.body.accept(self)
  ]
end

#visit_Function(o) ⇒ Object

FUNCTION NODES ###



108
109
110
# File 'lib/johnson/visitors/sexp_visitor.rb', line 108

def visit_Function(o)
  [:func_expr, o.name, o.arguments, o.body.accept(self)]
end

#visit_SourceElements(o) ⇒ Object



4
5
6
# File 'lib/johnson/visitors/sexp_visitor.rb', line 4

def visit_SourceElements(o)
  o.value.map { |x| x.accept(self) }
end

#visit_Try(o) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/johnson/visitors/sexp_visitor.rb', line 64

def visit_Try(o)
  [ :try,
    o.cond.accept(self),
    o.b_then ? o.b_then.map { |x| x.accept(self) } : nil,
    o.b_else ? o.b_else.accept(self) : nil
  ]
end