Class: Duby::AST::String
- Includes:
- Literal
- Defined in:
- lib/duby/compiler.rb,
lib/duby/ast/literal.rb
Instance Attribute Summary
Attributes included from Literal
Attributes included from Typed
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #compile(compiler, expression) ⇒ Object
- #infer(typer) ⇒ Object
-
#initialize(parent, line_number, literal) ⇒ String
constructor
A new instance of String.
Methods included from Literal
Methods inherited from Node
#[], #each, #expr?, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s
Constructor Details
#initialize(parent, line_number, literal) ⇒ String
Returns a new instance of String.
51 52 53 54 |
# File 'lib/duby/ast/literal.rb', line 51 def initialize(parent, line_number, literal) super(parent, line_number) @literal = literal end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/duby/compiler.rb', line 15 def compile(compiler, expression) if expression compiler.line(line_number) compiler.string(literal) end end |
#infer(typer) ⇒ Object
56 57 58 59 60 |
# File 'lib/duby/ast/literal.rb', line 56 def infer(typer) return @inferred_type if resolved? resolved! @inferred_type ||= typer.string_type end |