Method: PartialRuby::Context#packet

Defined in:
lib/partialruby.rb

#packet(code) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/partialruby.rb', line 87

def packet(code)
  tree = nil

  begin
    tree = RubyParser.new.parse code
  rescue
    raise SyntaxError
  end

  context = PartialRuby::PureRubyContext.new

  @preprocessors.each do |preprocessor|
    tree = preprocessor.call(tree)
  end

  emulationcode = context.emul tree

  PartialRuby::Packet.new(emulationcode)
end