class TPPlus::Nodes::AssignmentNode
Attributes
assignable[R]
identifier[R]
Public Class Methods
new(identifier,assignable)
click to toggle source
# File lib/tp_plus/nodes/assignment_node.rb, line 5 def initialize(identifier,assignable) @identifier = identifier @assignable = assignable end
Public Instance Methods
assignable_string(context,options={})
click to toggle source
# File lib/tp_plus/nodes/assignment_node.rb, line 10 def assignable_string(context,options={}) if @assignable.is_a?(ExpressionNode) options[:mixed_logic] = true if @assignable.contains_expression? options[:mixed_logic] = true if @assignable.op.requires_mixed_logic?(context) options[:mixed_logic] = true if @assignable.op.boolean? options[: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 options[:mixed_logic] = false if @identifier.target_node(context).is_a? PosregNode end elsif @assignable.is_a?(VarNode) options[:mixed_logic] = true if @assignable.target_node(context).is_a? IONode else options[:mixed_logic] = true if @assignable.requires_mixed_logic?(context) options[:mixed_logic] = true if @identifier.requires_mixed_logic?(context) end if options[:mixed_logic] "(#{@assignable.eval(context)})" else @assignable.eval(context) end end
can_be_inlined?()
click to toggle source
# File lib/tp_plus/nodes/assignment_node.rb, line 39 def can_be_inlined? true end
eval(context,options={})
click to toggle source
# File lib/tp_plus/nodes/assignment_node.rb, line 47 def eval(context,options={}) "#{identifier_string(context)}=#{assignable_string(context,options)}" end
identifier_string(context)
click to toggle source
# File lib/tp_plus/nodes/assignment_node.rb, line 43 def identifier_string(context) @identifier.eval(context) end
requires_mixed_logic?(context)
click to toggle source
# File lib/tp_plus/nodes/assignment_node.rb, line 35 def requires_mixed_logic?(context) true end