Class: Mirah::Compiler::ASTCompiler
- Inherits:
-
Object
- Object
- Mirah::Compiler::ASTCompiler
- Defined in:
- lib/mirah/compiler.rb
Instance Attribute Summary collapse
-
#compiler_class ⇒ Object
Returns the value of attribute compiler_class.
-
#logging ⇒ Object
Returns the value of attribute logging.
Instance Method Summary collapse
- #compile_ast(ast, &block) ⇒ Object
- #compile_asts(nodes) ⇒ Object
-
#initialize(compiler_class, logging) ⇒ ASTCompiler
constructor
A new instance of ASTCompiler.
Constructor Details
#initialize(compiler_class, logging) ⇒ ASTCompiler
Returns a new instance of ASTCompiler.
28 29 30 31 |
# File 'lib/mirah/compiler.rb', line 28 def initialize(compiler_class, logging) @compiler_class = compiler_class @logging = logging end |
Instance Attribute Details
#compiler_class ⇒ Object
Returns the value of attribute compiler_class.
33 34 35 |
# File 'lib/mirah/compiler.rb', line 33 def compiler_class @compiler_class end |
#logging ⇒ Object
Returns the value of attribute logging.
33 34 35 |
# File 'lib/mirah/compiler.rb', line 33 def logging @logging end |
Instance Method Details
#compile_ast(ast, &block) ⇒ Object
47 48 49 50 51 |
# File 'lib/mirah/compiler.rb', line 47 def compile_ast(ast, &block) compiler = compiler_class.new ast.compile(compiler, false) compiler.generate(&block) end |
#compile_asts(nodes) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/mirah/compiler.rb', line 35 def compile_asts(nodes) results = [] puts "Compiling..." if logging nodes.each do |ast| puts " #{ast.position.file}" if logging compile_ast(ast) do |filename, builder| results << CompilerResult.new(filename, builder.class_name, builder.generate) end end results end |