Class: Kumi::Support::NASTPrinter
- Inherits:
-
Object
- Object
- Kumi::Support::NASTPrinter
- Defined in:
- lib/kumi/support/nast_printer.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(indent: 0) ⇒ NASTPrinter
constructor
A new instance of NASTPrinter.
- #print(nir_module) ⇒ Object
Constructor Details
#initialize(indent: 0) ⇒ NASTPrinter
Returns a new instance of NASTPrinter.
10 11 12 |
# File 'lib/kumi/support/nast_printer.rb', line 10 def initialize(indent: 0) @indent = indent end |
Class Method Details
.print(nir_module) ⇒ Object
6 7 8 |
# File 'lib/kumi/support/nast_printer.rb', line 6 def self.print(nir_module) new.print(nir_module) end |
Instance Method Details
#print(nir_module) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kumi/support/nast_printer.rb', line 14 def print(nir_module) return "nil" unless nir_module lines = [] lines << "(NAST" nir_module.decls.each do |name, decl| lines << indent("(#{decl.kind.upcase} #{name}") lines << indent(print_node(decl.body), 2) lines << indent(")") end lines << ")" lines.join("\n") end |