Class: Crabstone::MIPS::Operand

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

Instance Method Summary collapse

Instance Method Details

#imm?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/arch/mips.rb', line 53

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

#mem?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/arch/mips.rb', line 57

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

#reg?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/arch/mips.rb', line 49

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

#valid?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/arch/mips.rb', line 61

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

#valueObject



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

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