module Atomy::Compiler
Public Instance Methods
compile(node, mod, state = LocalState.new)
click to toggle source
# File lib/atomy/compiler.rb, line 8 def compile(node, mod, state = LocalState.new) package(mod.file, 0, state) do |gen| mod.compile(gen, node) end end
construct_block(code, binding)
click to toggle source
# File lib/atomy/compiler.rb, line 45 def construct_block(code, binding) code = code.dup code.scope = binding.lexical_scope code.name = binding.variables.method.name code.scope.script = Rubinius::CompiledCode::Script.new(code, code.file.to_s, true) block = Rubinius::BlockEnvironment.new block.under_context(binding.variables, code) block end
generate(file, line = 0, state = LocalState.new) { |gen| ... }
click to toggle source
# File lib/atomy/compiler.rb, line 24 def generate(file, line = 0, state = LocalState.new) gen = CodeTools::Generator.new gen.file = file gen.set_line(line) gen.push_state(state) yield gen gen.ret gen.close gen.local_count = gen.state.scope.local_count gen.local_names = gen.state.scope.local_names gen.encode gen end
package(file, line = 0, state = LocalState.new, &blk)
click to toggle source
# File lib/atomy/compiler.rb, line 14 def package(file, line = 0, state = LocalState.new, &blk) generate(file, line, state, &blk).package(Rubinius::CompiledCode).tap do |code| if ENV["DEBUG"] printer = CodeTools::Compiler::MethodPrinter.new printer.bytecode = true printer.print_method(code) end end end