Class: Crabstone::Sparc::Operand

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/arch/sparc.rb

Instance Method Summary collapse

Instance Method Details

#imm?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/arch/sparc.rb', line 52

def imm?
    self[:type] == OP_IMM
end

#mem?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/arch/sparc.rb', line 56

def mem?
    self[:type] == OP_MEM
end

#reg?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/arch/sparc.rb', line 48

def reg?
    self[:type] == OP_REG
end

#valid?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/arch/sparc.rb', line 60

def valid?
    [OP_MEM, OP_IMM, OP_REG].include? self[:type]
end

#valueObject



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/arch/sparc.rb', line 35

def value
    case self[:type]
    when OP_REG
        self[:value][:reg]
    when OP_IMM
        self[:value][:imm]
    when OP_MEM
        self[:value][:mem]
    else
        nil
    end
end