Class: Mirah::AST::ToString

Inherits:
Node
  • Object
show all
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

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

Returns:



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

#temp(compiler, value = nil) ⇒ Object



164
165
166
# File 'lib/mirah/jvm/source_generator/precompile.rb', line 164

def temp(compiler, value=nil)
  TempValue.new(body, compiler, value)
end