Class: Duby::AST::Constant
- Includes:
- Named
- Defined in:
- lib/duby/ast.rb,
lib/duby/compiler.rb
Instance Attribute Summary
Attributes included from Named
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #compile(compiler, expression) ⇒ Object
- #infer(typer) ⇒ Object
-
#initialize(parent, position, name) ⇒ Constant
constructor
A new instance of Constant.
Methods included from Named
Methods inherited from Node
#<<, ===, #[], #_set_parent, child, child_name, #each, #empty?, #expr?, #initialize_copy, #insert, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s
Constructor Details
#initialize(parent, position, name) ⇒ Constant
Returns a new instance of Constant.
353 354 355 356 |
# File 'lib/duby/ast.rb', line 353 def initialize(parent, position, name) @name = name super(parent, position, []) end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
90 91 92 93 94 95 |
# File 'lib/duby/compiler.rb', line 90 def compile(compiler, expression) if expression compiler.line(line_number) compiler.constant(self) end end |
#infer(typer) ⇒ Object
358 359 360 361 362 |
# File 'lib/duby/ast.rb', line 358 def infer(typer) @inferred_type ||= begin typer.type_reference(name, false, true) end end |