Class: Duby::AST::StringConcat

Inherits:
Node
  • Object
show all
Defined in:
lib/duby/compiler.rb,
lib/duby/ast/literal.rb,
lib/duby/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

#<<, ===, #[], #_set_parent, child, child_name, #each, #empty?, #initialize_copy, #insert, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s

Constructor Details

#initialize(parent, position, &block) ⇒ StringConcat

Returns a new instance of StringConcat.



86
87
88
# File 'lib/duby/ast/literal.rb', line 86

def initialize(parent, position, &block)
  super(parent, position, &block)
end

Instance Method Details

#compile(compiler, expression) ⇒ Object



33
34
35
# File 'lib/duby/compiler.rb', line 33

def compile(compiler, expression)
  compiler.build_string(children, expression)
end

#expr?(compiler) ⇒ Boolean

Returns:



146
147
148
# File 'lib/duby/jvm/source_generator/precompile.rb', line 146

def expr?(compiler)
  children.all? {|x| x.expr?(compiler)}
end

#infer(typer) ⇒ Object



90
91
92
93
94
95
96
97
98
# File 'lib/duby/ast/literal.rb', line 90

def infer(typer)
  unless resolved?
    resolved = true
    children.each {|node| node.infer(typer); resolved &&= node.resolved?}
    resolved! if resolved
    @inferred_type ||= typer.string_type
  end
  @inferred_type
end