Class: Rex::Poly::LogicalRegister
- Inherits:
-
Object
- Object
- Rex::Poly::LogicalRegister
- Defined in:
- lib/rex/poly/register.rb
Overview
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.
Direct Known Subclasses
Defined Under Namespace
Classes: X86
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the variable (friendly) name for the register that was passed to the constructor.
Class Method Summary collapse
-
.regnum_set ⇒ Object
This class method is meant to return an array of register numbers that can be used to pool from.
Instance Method Summary collapse
-
#initialize(name, regnum = nil) ⇒ LogicalRegister
constructor
Initializes the register’s name and number, if assigned.
-
#regnum ⇒ Object
Returns the register number that has currently been assigned.
-
#regnum=(val) ⇒ Object
Sets the register number to the value specified.
-
#static? ⇒ Boolean
Returns true if the register number should be assumed static.
Constructor Details
#initialize(name, regnum = nil) ⇒ LogicalRegister
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’.
31 32 33 34 35 |
# File 'lib/rex/poly/register.rb', line 31 def initialize(name, regnum = nil) @name = name @regnum = regnum @static = (regnum) ? true : false end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the variable (friendly) name for the register that was passed to the constructor.
70 71 72 |
# File 'lib/rex/poly/register.rb', line 70 def name @name end |
Class Method Details
.regnum_set ⇒ Object
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.
21 22 23 |
# File 'lib/rex/poly/register.rb', line 21 def self.regnum_set nil end |
Instance Method Details
#regnum ⇒ Object
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.
60 61 62 63 64 |
# File 'lib/rex/poly/register.rb', line 60 def regnum raise InvalidRegisterError.new(self), "Register has not been assigned" if (@regnum == nil) @regnum end |
#regnum=(val) ⇒ Object
Sets the register number to the value specified. If the register number is declared static, a RuntimeError exception is raised.
48 49 50 51 52 |
# File 'lib/rex/poly/register.rb', line 48 def regnum=(val) raise RuntimeError, "Attempted to assign regnum to static register" if (static?) @regnum = val end |
#static? ⇒ Boolean
Returns true if the register number should be assumed static.
40 41 42 |
# File 'lib/rex/poly/register.rb', line 40 def static? @static end |