Class: Mirah::AST::String
- Inherits:
-
Node
- Object
- Node
- Mirah::AST::String
show all
- Includes:
- Literal, Scoped
- Defined in:
- lib/mirah/ast/literal.rb,
lib/mirah/compiler/literal.rb
Instance Attribute Summary
Attributes included from Literal
#literal
Attributes included from Typed
#type
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary
collapse
Methods included from Scoped
#containing_scope, #scope
Methods included from Literal
#string_value, #to_s
Methods inherited from Node
#<<, ===, #[], #[]=, #_dump, _load, #_set_parent, child, child_name, #child_nodes, #each, #empty?, #expr?, #inferred_type!, #initialize_copy, #insert, #inspect, #inspect_children, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #string_value, #temp, #to_s, #top_level?, #validate_child, #validate_children
Constructor Details
#initialize(parent, line_number, literal) ⇒ String
Returns a new instance of String.
88
89
90
91
|
# File 'lib/mirah/ast/literal.rb', line 88
def initialize(parent, line_number, literal)
super(parent, line_number)
@literal = literal
end
|
Instance Method Details
#compile(compiler, expression) ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'lib/mirah/compiler/literal.rb', line 41
def compile(compiler, expression)
if expression
compiler.line(line_number)
compiler.string(literal)
end
rescue Exception => ex
raise Mirah::InternalCompilerError.wrap(ex, self)
end
|
#infer(typer, expression) ⇒ Object
93
94
95
96
97
|
# File 'lib/mirah/ast/literal.rb', line 93
def infer(typer, expression)
return @inferred_type if resolved?
resolved!
@inferred_type ||= typer.string_type
end
|
#toString ⇒ Object
103
104
105
|
# File 'lib/mirah/ast/literal.rb', line 103
def toString
@literal
end
|
#type_reference(typer) ⇒ Object
99
100
101
|
# File 'lib/mirah/ast/literal.rb', line 99
def type_reference(typer)
typer.type_reference(scope, @literal)
end
|