Class: TPPlus::Nodes::AccNode

Inherits:
BaseNode
  • Object
show all
Defined in:
lib/tp_plus/nodes/acc_node.rb

Instance Method Summary collapse

Methods inherited from BaseNode

#can_be_inlined?

Constructor Details

#initialize(value) ⇒ AccNode

Returns a new instance of AccNode.



4
5
6
# File 'lib/tp_plus/nodes/acc_node.rb', line 4

def initialize(value)
  @value = value
end

Instance Method Details

#eval(context) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tp_plus/nodes/acc_node.rb', line 8

def eval(context)
  case @value
  when DigitNode
    "ACC#{@value.eval(context)}"
  when VarNode
    if @value.constant?
      "ACC#{@value.eval(context)}"
    else
      "ACC #{@value.eval(context)}"
    end
  else
    raise "invalid acc"
  end
end