Class: Rubex::AST::Statement::Assign
- Defined in:
- lib/rubex/ast/statement/assign.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #analyse_statement(local_scope) ⇒ Object
- #generate_code(code, local_scope) ⇒ Object
-
#initialize(lhs, rhs, location) ⇒ Assign
constructor
A new instance of Assign.
Methods inherited from Base
Constructor Details
#initialize(lhs, rhs, location) ⇒ Assign
Returns a new instance of Assign.
5 6 7 8 9 |
# File 'lib/rubex/ast/statement/assign.rb', line 5 def initialize(lhs, rhs, location) super(location) @lhs = lhs @rhs = rhs end |
Instance Method Details
#analyse_statement(local_scope) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rubex/ast/statement/assign.rb', line 11 def analyse_statement(local_scope) if @lhs.is_a?(Rubex::AST::Expression::Name) @lhs.analyse_declaration @rhs, local_scope else @lhs.analyse_types(local_scope) end @lhs.allocate_temps local_scope @rhs.analyse_for_target_type(@lhs.type, local_scope) @rhs = Helpers.to_lhs_type(@lhs, @rhs) @rhs.allocate_temps local_scope @lhs.release_temps local_scope @rhs.release_temps local_scope end |
#generate_code(code, local_scope) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/rubex/ast/statement/assign.rb', line 26 def generate_code(code, local_scope) super @rhs.generate_evaluation_code code, local_scope @lhs.generate_assignment_code @rhs, code, local_scope @rhs.generate_disposal_code code end |