Class: TPPlus::Nodes::AssignmentNode
- Defined in:
- lib/tp_plus/nodes/assignment_node.rb
Instance Attribute Summary collapse
-
#assignable ⇒ Object
readonly
Returns the value of attribute assignable.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Instance Method Summary collapse
- #assignable_string(context, options = {}) ⇒ Object
- #can_be_inlined? ⇒ Boolean
- #eval(context, options = {}) ⇒ Object
- #identifier_string(context) ⇒ Object
-
#initialize(identifier, assignable) ⇒ AssignmentNode
constructor
A new instance of AssignmentNode.
- #requires_mixed_logic?(context) ⇒ Boolean
Constructor Details
#initialize(identifier, assignable) ⇒ AssignmentNode
Returns a new instance of AssignmentNode.
5 6 7 8 |
# File 'lib/tp_plus/nodes/assignment_node.rb', line 5 def initialize(identifier,assignable) @identifier = identifier @assignable = assignable end |
Instance Attribute Details
#assignable ⇒ Object (readonly)
Returns the value of attribute assignable.
4 5 6 |
# File 'lib/tp_plus/nodes/assignment_node.rb', line 4 def assignable @assignable end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
4 5 6 |
# File 'lib/tp_plus/nodes/assignment_node.rb', line 4 def identifier @identifier end |
Instance Method Details
#assignable_string(context, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tp_plus/nodes/assignment_node.rb', line 10 def assignable_string(context,={}) if @assignable.is_a?(ExpressionNode) [:mixed_logic] = true if @assignable.contains_expression? [:mixed_logic] = true if @assignable.op.requires_mixed_logic?(context) [:mixed_logic] = true if @assignable.op.boolean? [:mixed_logic] = true if @assignable.boolean_result? # this is a hack that fixes issue #12 # PR[a]=PR[b]+PR[c]+PR[d] (no parens) if @identifier.is_a? VarNode [:mixed_logic] = false if @identifier.target_node(context).is_a? PosregNode end elsif @assignable.is_a?(VarNode) [:mixed_logic] = true if @assignable.target_node(context).is_a? IONode else [:mixed_logic] = true if @assignable.requires_mixed_logic?(context) [:mixed_logic] = true if @identifier.requires_mixed_logic?(context) end if [:mixed_logic] "(#{@assignable.eval(context)})" else @assignable.eval(context) end end |
#can_be_inlined? ⇒ Boolean
39 40 41 |
# File 'lib/tp_plus/nodes/assignment_node.rb', line 39 def can_be_inlined? true end |
#eval(context, options = {}) ⇒ Object
47 48 49 |
# File 'lib/tp_plus/nodes/assignment_node.rb', line 47 def eval(context,={}) "#{identifier_string(context)}=#{assignable_string(context,)}" end |
#identifier_string(context) ⇒ Object
43 44 45 |
# File 'lib/tp_plus/nodes/assignment_node.rb', line 43 def identifier_string(context) @identifier.eval(context) end |
#requires_mixed_logic?(context) ⇒ Boolean
35 36 37 |
# File 'lib/tp_plus/nodes/assignment_node.rb', line 35 def requires_mixed_logic?(context) true end |