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
Returns the variable (friendly) name for the register that was passed to the constructor.
Public Class Methods
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
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
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
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
Returns true if the register number should be assumed static.
# File lib/rex/poly/register.rb, line 39 def static? @static end