class Rex::Poly::LogicalRegister

This class represents a register that is used in the context of one or more logical blocks. The register number is assigned on demand or is statically specified if passed in to the constructor.

Attributes

name[R]

Returns the variable (friendly) name for the register that was passed to the constructor.

Public Class Methods

new(name, regnum = nil) click to toggle source

Initializes the register’s name and number, if assigned. If a register number is specified, the instance will be assumed to have a statically assigned register number. The name is meant to be used as a symbolic variable name, such as ‘counter’ or ‘key’.

# File lib/rex/poly/register.rb, line 30
def initialize(name, regnum = nil)
  @name   = name
  @regnum = regnum
  @static = (regnum) ? true : false
end
regnum_set() click to toggle source

This class method is meant to return an array of register numbers that can be used to pool from. Architecture specific classes must implement this method on their own.

# File lib/rex/poly/register.rb, line 20
def self.regnum_set
  nil
end

Public Instance Methods

regnum() click to toggle source

Returns the register number that has currently been assigned. If no register number is assigned, an InvalidRegisterError exception is raised. This exception can be used to assign the LogicalRegister instance a register number on demand.

# File lib/rex/poly/register.rb, line 59
def regnum
  raise InvalidRegisterError.new(self), "Register has not been assigned" if (@regnum == nil)

  @regnum
end
regnum=(val) click to toggle source

Sets the register number to the value specified. If the register number is declared static, a RuntimeError exception is raised.

# File lib/rex/poly/register.rb, line 47
def regnum=(val)
  raise RuntimeError, "Attempted to assign regnum to static register" if (static?)

  @regnum = val
end
static?() click to toggle source

Returns true if the register number should be assumed static.

# File lib/rex/poly/register.rb, line 39
def static?
  @static
end