Class: Mirah::AST::FieldAssignment
- Includes:
- Annotated, ClassScoped, Named, Valued
- Defined in:
- lib/mirah/ast/class.rb,
lib/mirah/compiler/class.rb,
lib/mirah/jvm/source_generator/precompile.rb
Instance Attribute Summary collapse
-
#static ⇒ Object
Returns the value of attribute static.
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, expression) ⇒ Object
-
#initialize(parent, position, name, annotations = [], static = false, &block) ⇒ FieldAssignment
constructor
A new instance of FieldAssignment.
Methods included from ClassScoped
Methods included from Named
#string_value, #to_s, #validate_name
Methods included from Annotated
Methods inherited from Node
#<<, ===, #[], #[]=, #_dump, _load, #_set_parent, child, child_name, #child_nodes, #each, #empty?, #inferred_type!, #initialize_copy, #insert, #inspect, #inspect_children, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #string_value, #temp, #to_s, #top_level?, #validate_child, #validate_children
Constructor Details
#initialize(parent, position, name, annotations = [], static = false, &block) ⇒ FieldAssignment
Returns a new instance of FieldAssignment.
248 249 250 251 252 253 |
# File 'lib/mirah/ast/class.rb', line 248 def initialize(parent, position, name, annotations=[], static = false, &block) @annotations = annotations super(parent, position, &block) self.name = name @static = static end |
Instance Attribute Details
#static ⇒ Object
Returns the value of attribute static.
246 247 248 |
# File 'lib/mirah/ast/class.rb', line 246 def static @static end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/mirah/compiler/class.rb', line 47 def compile(compiler, expression) compiler.line(line_number) compiler.field_assign(name, inferred_type, expression, value, annotations, static) rescue Exception => ex raise Mirah::InternalCompilerError.wrap(ex, self) end |
#expr?(compiler) ⇒ Boolean
200 201 202 |
# File 'lib/mirah/jvm/source_generator/precompile.rb', line 200 def expr?(compiler) false end |
#infer(typer, expression) ⇒ Object
255 256 257 258 259 260 261 262 263 264 |
# File 'lib/mirah/ast/class.rb', line 255 def infer(typer, expression) resolve_if(typer) do @annotations.each {|a| a.infer(typer, true)} if @annotations if static typer.learn_static_field_type(class_scope, name, typer.infer(value, true)) else typer.learn_field_type(class_scope, name, typer.infer(value, true)) end end end |