Class: Duby::AST::Field
- Includes:
- ClassScoped, Named
- Defined in:
- lib/duby/compiler.rb,
lib/duby/ast/class.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, line_number, name, &block) ⇒ Field
constructor
A new instance of Field.
Methods included from ClassScoped
Methods included from Named
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, name, &block) ⇒ Field
Returns a new instance of Field.
130 131 132 133 |
# File 'lib/duby/ast/class.rb', line 130 def initialize(parent, line_number, name, &block) super(parent, line_number, &block) @name = name end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
186 187 188 189 190 191 |
# File 'lib/duby/compiler.rb', line 186 def compile(compiler, expression) compiler.line(line_number) if expression compiler.field(name, inferred_type) end end |
#infer(typer) ⇒ Object
135 136 137 138 139 140 141 142 143 |
# File 'lib/duby/ast/class.rb', line 135 def infer(typer) unless resolved? @inferred_type = typer.field_type(scope, name) @inferred_type ? resolved! : typer.defer(self) end @inferred_type end |