Class: Duby::AST::FieldAssignment
- Includes:
- 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 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, line_number, name, &block) ⇒ FieldAssignment
constructor
A new instance of FieldAssignment.
Methods included from ClassScoped
Methods included from Named
Methods inherited from Node
#[], #each, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s
Constructor Details
#initialize(parent, line_number, name, &block) ⇒ FieldAssignment
Returns a new instance of FieldAssignment.
109 110 111 112 113 |
# File 'lib/duby/ast/class.rb', line 109 def initialize(parent, line_number, name, &block) super(parent, line_number, &block) @value = children[0] @name = name end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
179 180 181 182 |
# File 'lib/duby/compiler.rb', line 179 def compile(compiler, expression) compiler.line(line_number) compiler.field_assign(name, inferred_type, expression, value) end |
#expr?(compiler) ⇒ Boolean
144 145 146 |
# File 'lib/duby/jvm/source_generator/precompile.rb', line 144 def expr?(compiler) false end |
#infer(typer) ⇒ Object
115 116 117 118 119 120 121 122 123 |
# File 'lib/duby/ast/class.rb', line 115 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 |