Class: RVM::Interpreter::SimpleAssignment
- Inherits:
-
Assignment
- Object
- Element
- Assignment
- RVM::Interpreter::SimpleAssignment
- Defined in:
- lib/rvm/optimisation.rb
Overview
it to be a string from the beginning
Instance Attribute Summary
Attributes inherited from Element
Instance Method Summary collapse
-
#execute(env) ⇒ Object
The simple assignemnt only evaluates the value and sets the variable with the given name in the Environment.
-
#initialize(name, value, pos = nil) ⇒ SimpleAssignment
constructor
A Assignment is initialized wiht 2 to 3 parameters.
- #optimize ⇒ Object
Methods inherited from Assignment
Constructor Details
#initialize(name, value, pos = nil) ⇒ SimpleAssignment
A Assignment is initialized wiht 2 to 3 parameters.
- name
-
The name of the variable to store, it will be executed, usually this will be a Constant, unless dynamic naming is needed by the implemented language.
- value
-
The value that will be assigned to the variable, for a = 1 + 1 ‘1+1’ would be the value to assign, so as this already suggests the value will be executed.
- pos
-
The position within the source code of the definition - for deugging purpose.
20 21 22 23 24 |
# File 'lib/rvm/optimisation.rb', line 20 def initialize name, value, pos = nil @pos = pos @name = name @value = value end |
Instance Method Details
#execute(env) ⇒ Object
The simple assignemnt only evaluates the value and sets the variable with the given name in the Environment.
29 30 31 32 |
# File 'lib/rvm/optimisation.rb', line 29 def execute env RVM::debug "Executing SimpleAssignment at #{@pos}..." if $DEBUG env[@name] = @value.execute env end |
#optimize ⇒ Object
34 35 36 37 |
# File 'lib/rvm/optimisation.rb', line 34 def optimize @value = @value.optimize self end |