Class: Mirah::AST::ToString
- Defined in:
- lib/mirah/ast/literal.rb,
lib/mirah/compiler/literal.rb,
lib/mirah/jvm/source_generator/precompile.rb
Instance Attribute Summary
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #compile(compiler, expression) ⇒ Object
- #expr?(compiler) ⇒ Boolean
- #infer(typer, expression) ⇒ Object
-
#initialize(parent, position) ⇒ ToString
constructor
A new instance of ToString.
- #temp(compiler, value = nil) ⇒ Object
Methods inherited from Node
#<<, ===, #[], #[]=, #_dump, _load, #_set_parent, child, child_name, #child_nodes, #each, #empty?, #inferred_type!, #initialize_copy, #insert, #inspect, #inspect_children, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #string_value, #to_s, #top_level?, #validate_child, #validate_children
Constructor Details
#initialize(parent, position) ⇒ ToString
Returns a new instance of ToString.
127 128 129 |
# File 'lib/mirah/ast/literal.rb', line 127 def initialize(parent, position) super(parent, position) end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
60 61 62 63 64 |
# File 'lib/mirah/compiler/literal.rb', line 60 def compile(compiler, expression) compiler.to_string(body, expression) rescue Exception => ex raise Mirah::InternalCompilerError.wrap(ex, self) end |
#expr?(compiler) ⇒ Boolean
160 161 162 |
# File 'lib/mirah/jvm/source_generator/precompile.rb', line 160 def expr?(compiler) body.expr?(compiler) end |
#infer(typer, expression) ⇒ Object
131 132 133 134 135 136 137 138 |
# File 'lib/mirah/ast/literal.rb', line 131 def infer(typer, expression) unless resolved? body.infer(typer, true) resolved! if body.resolved? @inferred_type ||= typer.string_type end @inferred_type end |