Class: Internal::ByteDecoder::Expression::Prefix

Inherits:
Internal::ByteDecoder::Expression show all
Defined in:
lib/decompiler/vm/bytedecoder.rb

Instance Attribute Summary

Attributes inherited from Internal::ByteDecoder::Expression

#pc

Instance Method Summary collapse

Methods inherited from Internal::ByteDecoder::Expression

#<=>, #fmt

Constructor Details

#initialize(pc, op, expr) ⇒ Prefix

Returns a new instance of Prefix.



133
134
135
136
137
# File 'lib/decompiler/vm/bytedecoder.rb', line 133

def initialize(pc, op, expr)
  super(pc)
  @op = op
  @expr = expr
end

Instance Method Details

#precedenceObject



151
152
153
# File 'lib/decompiler/vm/bytedecoder.rb', line 151

def precedence
  return 1
end

#to_sObject



139
140
141
142
143
144
145
146
147
148
149
# File 'lib/decompiler/vm/bytedecoder.rb', line 139

def to_s
  op = @op.to_s
  op.chop! if op[-1] == ?@
  if @op == '!'.intern and @expr.is_a?(Infix) and @expr.op == :== then
    return "#{@expr.fmt(@expr.lhs)} != #{@expr.fmt(@expr.rhs)}"
  elsif self.precedence < @expr.precedence then
    return "#{op}(#{@expr})"
  else
    return "#{op}#{@expr}"
  end
end