C# Class Reko.Core.Frame

Contains the non-global locations accessed by the code inside a procedure.
Variables accessed by the procedure can live in many places: registers, stack, and temporaries.

The frame layout is particularly interesting. On the Intel x86 architecture in real mode we have the following:

Layout offset value +-----------------+ | arg3 | 6 +-----------------+ | arg2 | 4 +-----------------+ | arg1 | 2 +-----------------+ | return address | 0 +-----------------+ | frame pointer | -2 +-----------------+ | local1 | -4 +-----------------+ | local2 | -6 etc.

Note that variables that are stack arguments use offsets based on the state of stack _after_ the return address was pushed. The return address, if passed on the stack, is always considered to be at offset 0.

In addition, support has to be provided for architectures that have separate FPU stacks.

Datei anzeigen Open project: uxmal/reko Class Usage Examples

Public Methods

Method Description
CreateSequence ( System.IO.Storage head, System.IO.Storage tail, DataType dt ) : Identifier
CreateTemporary ( DataType dt ) : Identifier

Creates a temporary variable whose storage and name is guaranteed not to collide with any other variable.

CreateTemporary ( string name, DataType dt ) : Identifier
EnsureFlagGroup ( FlagGroupStorage grf ) : Identifier
EnsureFlagGroup ( FlagRegister freg, uint grfMask, string name, DataType dt ) : Identifier
EnsureFpuStackVariable ( int depth, DataType type ) : Identifier
EnsureIdentifier ( System.IO.Storage stgForeign ) : Identifier
EnsureOutArgument ( Identifier idOrig, DataType outArgumentPointer ) : Identifier
EnsureRegister ( RegisterStorage reg ) : Identifier

Ensures a register access in this function.

EnsureSequence ( System.IO.Storage head, System.IO.Storage tail, DataType dt ) : Identifier
EnsureStackArgument ( int cbOffset, DataType type ) : Identifier
EnsureStackArgument ( int cbOffset, DataType type, string argName ) : Identifier
EnsureStackLocal ( int cbOffset, DataType type ) : Identifier

Makes sure that there is a local variable at the given offset.

EnsureStackLocal ( int cbOffset, DataType type, string name ) : Identifier
EnsureStackVariable ( Constant imm, int cbOffset, DataType type ) : Identifier
EnsureStackVariable ( int byteOffset, DataType type ) : Identifier
ExternalOffset ( Identifier id ) : int

The offset of a variable from the return address, as seen from a caller.

FindFlagGroup ( uint grfMask ) : Identifier
FindFpuStackVariable ( int off ) : Identifier
FindOutArgument ( Identifier idOrig ) : Identifier
FindRegister ( RegisterStorage reg ) : Identifier
FindSequence ( System.IO.Storage n1, System.IO.Storage n2 ) : Identifier
FindStackArgument ( int offset, int size ) : Identifier
FindStackLocal ( int offset, int size ) : Identifier
FindTemporary ( string name ) : Identifier
FormatStackAccessName ( DataType type, string prefix, int cbOffset ) : string
FormatStackAccessName ( DataType type, string prefix, int cbOffset, string nameOverride ) : string
Frame ( PrimitiveType framePointerSize ) : Reko.Core.Expressions

Creates a Frame instance for maintaining the local variables and arguments.

GetStackArgumentSpace ( ) : int

Returns the number of bytes the stack arguments consume on the stack.

Write ( TextWriter text ) : void

Method Details

CreateSequence() public method

public CreateSequence ( System.IO.Storage head, System.IO.Storage tail, DataType dt ) : Identifier
head System.IO.Storage
tail System.IO.Storage
dt DataType
return Identifier

CreateTemporary() public method

Creates a temporary variable whose storage and name is guaranteed not to collide with any other variable.
public CreateTemporary ( DataType dt ) : Identifier
dt DataType
return Identifier

CreateTemporary() public method

public CreateTemporary ( string name, DataType dt ) : Identifier
name string
dt DataType
return Identifier

EnsureFlagGroup() public method

public EnsureFlagGroup ( FlagGroupStorage grf ) : Identifier
grf FlagGroupStorage
return Identifier

EnsureFlagGroup() public method

public EnsureFlagGroup ( FlagRegister freg, uint grfMask, string name, DataType dt ) : Identifier
freg FlagRegister
grfMask uint
name string
dt DataType
return Identifier

EnsureFpuStackVariable() public method

public EnsureFpuStackVariable ( int depth, DataType type ) : Identifier
depth int
type DataType
return Identifier

EnsureIdentifier() public method

public EnsureIdentifier ( System.IO.Storage stgForeign ) : Identifier
stgForeign System.IO.Storage
return Identifier

EnsureOutArgument() public method

public EnsureOutArgument ( Identifier idOrig, DataType outArgumentPointer ) : Identifier
idOrig Identifier
outArgumentPointer DataType
return Identifier

EnsureRegister() public method

Ensures a register access in this function.
public EnsureRegister ( RegisterStorage reg ) : Identifier
reg RegisterStorage
return Identifier

EnsureSequence() public method

public EnsureSequence ( System.IO.Storage head, System.IO.Storage tail, DataType dt ) : Identifier
head System.IO.Storage
tail System.IO.Storage
dt DataType
return Identifier

EnsureStackArgument() public method

public EnsureStackArgument ( int cbOffset, DataType type ) : Identifier
cbOffset int
type DataType
return Identifier

EnsureStackArgument() public method

public EnsureStackArgument ( int cbOffset, DataType type, string argName ) : Identifier
cbOffset int
type DataType
argName string
return Identifier

EnsureStackLocal() public method

Makes sure that there is a local variable at the given offset.
public EnsureStackLocal ( int cbOffset, DataType type ) : Identifier
cbOffset int
type DataType
return Identifier

EnsureStackLocal() public method

public EnsureStackLocal ( int cbOffset, DataType type, string name ) : Identifier
cbOffset int
type DataType
name string
return Identifier

EnsureStackVariable() public method

public EnsureStackVariable ( Constant imm, int cbOffset, DataType type ) : Identifier
imm Constant
cbOffset int
type DataType
return Identifier

EnsureStackVariable() public method

public EnsureStackVariable ( int byteOffset, DataType type ) : Identifier
byteOffset int
type DataType
return Identifier

ExternalOffset() public method

The offset of a variable from the return address, as seen from a caller.
public ExternalOffset ( Identifier id ) : int
id Identifier
return int

FindFlagGroup() public method

public FindFlagGroup ( uint grfMask ) : Identifier
grfMask uint
return Identifier

FindFpuStackVariable() public method

public FindFpuStackVariable ( int off ) : Identifier
off int
return Identifier

FindOutArgument() public method

public FindOutArgument ( Identifier idOrig ) : Identifier
idOrig Identifier
return Identifier

FindRegister() public method

public FindRegister ( RegisterStorage reg ) : Identifier
reg RegisterStorage
return Identifier

FindSequence() public method

public FindSequence ( System.IO.Storage n1, System.IO.Storage n2 ) : Identifier
n1 System.IO.Storage
n2 System.IO.Storage
return Identifier

FindStackArgument() public method

public FindStackArgument ( int offset, int size ) : Identifier
offset int
size int
return Identifier

FindStackLocal() public method

public FindStackLocal ( int offset, int size ) : Identifier
offset int
size int
return Identifier

FindTemporary() public method

public FindTemporary ( string name ) : Identifier
name string
return Identifier

FormatStackAccessName() public method

public FormatStackAccessName ( DataType type, string prefix, int cbOffset ) : string
type DataType
prefix string
cbOffset int
return string

FormatStackAccessName() public method

public FormatStackAccessName ( DataType type, string prefix, int cbOffset, string nameOverride ) : string
type DataType
prefix string
cbOffset int
nameOverride string
return string

Frame() public method

Creates a Frame instance for maintaining the local variables and arguments.
public Frame ( PrimitiveType framePointerSize ) : Reko.Core.Expressions
framePointerSize PrimitiveType The size of the frame pointer must match the size of the /// stack register, if any, or at the least the size of a pointer.
return Reko.Core.Expressions

GetStackArgumentSpace() public method

Returns the number of bytes the stack arguments consume on the stack.
public GetStackArgumentSpace ( ) : int
return int

Write() public method

public Write ( TextWriter text ) : void
text System.IO.TextWriter
return void