Class: Duby::AST::FieldAssignment
- Includes:
- Annotated, ClassScoped, Named, Valued
- Defined in:
- lib/duby/compiler.rb,
lib/duby/ast/class.rb,
lib/duby/jvm/source_generator/precompile.rb
Instance Attribute Summary
Attributes included from Valued
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
- #expr?(compiler) ⇒ Boolean
- #infer(typer) ⇒ Object
-
#initialize(parent, position, name, annotations = [], &block) ⇒ FieldAssignment
constructor
A new instance of FieldAssignment.
Methods included from ClassScoped
Methods included from Named
Methods included from Annotated
Methods inherited from Node
#<<, ===, #[], #_set_parent, child, child_name, #each, #empty?, #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) ⇒ FieldAssignment
Returns a new instance of FieldAssignment.
200 201 202 203 204 |
# File 'lib/duby/ast/class.rb', line 200 def initialize(parent, position, name, annotations=[], &block) @annotations = annotations super(parent, position, &block) @name = name end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
237 238 239 240 |
# File 'lib/duby/compiler.rb', line 237 def compile(compiler, expression) compiler.line(line_number) compiler.field_assign(name, inferred_type, expression, value, annotations) end |
#expr?(compiler) ⇒ Boolean
176 177 178 |
# File 'lib/duby/jvm/source_generator/precompile.rb', line 176 def expr?(compiler) false end |
#infer(typer) ⇒ Object
206 207 208 209 210 211 212 213 214 |
# File 'lib/duby/ast/class.rb', line 206 def infer(typer) unless resolved? @inferred_type = typer.learn_field_type(scope, name, typer.infer(value)) @inferred_type ? resolved! : typer.defer(self) end @inferred_type end |