Class: Duby::AST::FieldDeclaration
- Includes:
- Annotated, ClassScoped, Named, Typed
- Defined in:
- lib/duby/compiler.rb,
lib/duby/ast/class.rb
Instance Attribute Summary
Attributes included from Typed
Attributes included from Named
Attributes included from Annotated
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, annotations = [], &block) ⇒ FieldDeclaration
constructor
A new instance of FieldDeclaration.
Methods included from ClassScoped
Methods included from Named
Methods included from Annotated
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, annotations = [], &block) ⇒ FieldDeclaration
Returns a new instance of FieldDeclaration.
171 172 173 174 175 |
# File 'lib/duby/ast/class.rb', line 171 def initialize(parent, position, name, annotations=[], &block) @annotations = annotations super(parent, position, &block) @name = name end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
231 232 233 |
# File 'lib/duby/compiler.rb', line 231 def compile(compiler, expression) compiler.field_declare(name, inferred_type, annotations) end |
#infer(typer) ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/duby/ast/class.rb', line 177 def infer(typer) unless resolved? resolved! @inferred_type = typer.known_types[type] if @inferred_type resolved! typer.learn_field_type(scope, name, @inferred_type) else typer.defer(self) end end @inferred_type end |