Methods
A
I
N
S
Attributes
[R] body
[R] comm
[R] defopes
[R] is_sc
[R] name
[R] nextsc
[R] opes
[R] optimized
[R] orig
[R] pops
[R] pushsc
[R] rets
[R] sc
[R] sp_inc
[R] tvars
[R] type
[R] unifs
Class Public methods
new(name, opes, pops, rets, comm, body, tvars, sp_inc, orig = self, defopes = [], type = nil, nsc = [], psc = [[], []])
# File tool/instruction.rb, line 11
def initialize name, opes, pops, rets, comm, body, tvars, sp_inc,
               orig = self, defopes = [], type = nil,
               nsc = [], psc = [[], []]

  @name = name
  @opes = opes # [[type, name], ...]
  @pops = pops # [[type, name], ...]
  @rets = rets # [[type, name], ...]
  @comm = comm # {:c => category, :e => en desc, :j => ja desc}
  @body = body # '...'

  @orig    = orig
  @defopes = defopes
  @type    = type
  @tvars   = tvars

  @nextsc = nsc
  @pushsc = psc
  @sc     = []
  @unifs  = []
  @optimized = []
  @is_sc  = false
  @sp_inc = sp_inc
end
Instance Public methods
add_optimized(insn)
# File tool/instruction.rb, line 59
def add_optimized insn
  @optimized << insn
end
add_sc(sci)
# File tool/instruction.rb, line 36
def add_sc sci
  @sc << sci
  sci.set_sc
end
add_unif(insns)
# File tool/instruction.rb, line 55
def add_unif insns
  @unifs << insns
end
inspect()
# File tool/instruction.rb, line 93
def inspect
  "#<Instruction:#{@name}>"
end
set_sc()
# File tool/instruction.rb, line 51
def set_sc
  @is_sc = true
end
sp_increase_c_expr()
# File tool/instruction.rb, line 63
def sp_increase_c_expr
  if(pops.any?{|t, v| v == '...'} ||
     rets.any?{|t, v| v == '...'})
    # user definision
    raise "no sp increase definition" if @sp_inc.nil?
    ret = "int inc = 0;\n"

    @opes.each_with_index{|(t, v), i|
      if (t == 'rb_num_t' && ((re = /\b#{v}\b/n) =~ @sp_inc)) ||
         (@defopes.any?{|t, val| re =~ val})
        ret << "        int #{v} = FIX2INT(opes[#{i}]);\n"
      elsif (t == 'CALL_INFO' && ((re = /\b#{v}\b/n) =~ @sp_inc))
        ret << "        CALL_INFO #{v} = (CALL_INFO)(opes[#{i}]);\n"
      end
    }

    @defopes.each_with_index{|((t, var), val), i|
      if t == 'rb_num_t' && val != '*' && /\b#{var}\b/ =~ @sp_inc
        ret << "        #{t} #{var} = #{val};\n"
      end
    }

    ret << "        #{@sp_inc};\n"
    ret << "        return depth + inc;"
    ret
  else
    "return depth + #{rets.size - pops.size};"
  end
end