edu.cornell.cs.sam.core
Interface Memory

All Known Implementing Classes:
SamMemory

public interface Memory

The Memory interface provides low-level memory access methods


Nested Class Summary
static class Memory.Data
          Represents memory data
static class Memory.Type
          Represents memory type
 
Field Summary
static int MEMORYLIMIT
          The upper limit of memory
static int STACKLIMIT
          The upper limit of the stack
static int UNIT_SIZE
          Memory unit size in bits
 
Method Summary
 java.util.List<Memory.Data> getAllocation(HeapAllocator.Allocation alloc)
          Returns an array containing the data for the given allocation.
 HeapAllocator getHeapAllocator()
          Get the Heap Allocator object associated with this memory.
 Memory.Data getMem(int pos)
          Returns the data object at the requested memory position
 java.util.List<Memory.Data> getStack()
          Returns a list containing the current stack
 Sys getSystem()
          Return the Sys object associated with this memory.
 Memory.Type getType(int pos)
          Returns the type at the requested memory position
 int getValue(int pos)
          Returns the value at the requested memory position
 void init()
          Initializes memory to default state
 Memory.Data pop()
          Pops a data object off the stack
 char popCH()
          Pops a character off the stack
 float popFLOAT()
          Pops a floating pointer number off the stack
 int popINT()
          Pops an integer off the stack
 int popMA()
          Pops a memory address off the stack
 int popPA()
          Pops a program address off the stack
 int popValue()
          Pops a value off the stack
 void push(int value, Memory.Type type)
          Pushes a value/type pair on the stack
 void push(Memory.Data data)
          Pushes a data object on the stack
 void pushCH(char ch)
          Pushes a character on the stack
 void pushFLOAT(float fl)
          Pushes a floating pointer number on the stack
 void pushINT(int i)
          Pushes an integer on the stack
 void pushMA(int ma)
          Pushes a memory address on the stack
 void pushPA(int pa)
          Pushes a program address on the stack
 void setHeapAllocator(HeapAllocator ha)
          Set the HeapAllocator object associated with this memory.
 void setMem(int pos, int value, Memory.Type type)
          Stores the given value/type pair in memory
 void setMem(int pos, Memory.Data data)
          Stores the given data object in memory
 void setSystem(Sys sys)
          Set the Sys object associated with this memory.
 void setType(int pos, Memory.Type type)
          Sets this location to the given type
 void setValue(int pos, int value)
          Stores the given value in memory
 

Field Detail

MEMORYLIMIT

static final int MEMORYLIMIT
The upper limit of memory

See Also:
Constant Field Values

STACKLIMIT

static final int STACKLIMIT
The upper limit of the stack

See Also:
Constant Field Values

UNIT_SIZE

static final int UNIT_SIZE
Memory unit size in bits

See Also:
Constant Field Values
Method Detail

init

void init()
Initializes memory to default state


getSystem

Sys getSystem()
Return the Sys object associated with this memory.

Returns:
The Sys object

setSystem

void setSystem(Sys sys)
Set the Sys object associated with this memory.

Parameters:
sys - The Sys object

setHeapAllocator

void setHeapAllocator(HeapAllocator ha)
Set the HeapAllocator object associated with this memory.

Parameters:
ha - The allocator

getHeapAllocator

HeapAllocator getHeapAllocator()
Get the Heap Allocator object associated with this memory.

Returns:
The heap allocator

setMem

void setMem(int pos,
            Memory.Data data)
            throws SystemException
Stores the given data object in memory

Parameters:
addr - The address in memory
data - The data object to set
Throws:
SystemException - if there is an error accessing memory

setMem

void setMem(int pos,
            int value,
            Memory.Type type)
            throws SystemException
Stores the given value/type pair in memory

Parameters:
addr - The address in memory
value - The value to store
type - The type of this value
Throws:
SystemException - if there is an error accessing memory

setValue

void setValue(int pos,
              int value)
              throws SystemException
Stores the given value in memory

Parameters:
addr - The address in memory
value - The value to store
Throws:
SystemException - if there is an error accessing memory

setType

void setType(int pos,
             Memory.Type type)
             throws SystemException
Sets this location to the given type

Parameters:
addr - The address in memory
type - The type to set
Throws:
SystemException - if there is an error accessing memory

getMem

Memory.Data getMem(int pos)
                   throws SystemException
Returns the data object at the requested memory position

Parameters:
pos - The memory address
Returns:
The data object stored at the specified position
Throws:
SystemException - if there is an error accessing memory

getValue

int getValue(int pos)
             throws SystemException
Returns the value at the requested memory position

Parameters:
pos - The memory address
Returns:
The value stored at the specified position
Throws:
SystemException - if there is an error accessing memory

getType

Memory.Type getType(int pos)
                    throws SystemException
Returns the type at the requested memory position

Parameters:
pos - The memory address
Returns:
The type stored at the specified position
Throws:
SystemException - if there is an error accessing memory

getAllocation

java.util.List<Memory.Data> getAllocation(HeapAllocator.Allocation alloc)
Returns an array containing the data for the given allocation.

Parameters:
alloc - The heap allocation
Returns:
The list of data for this allocation.

getStack

java.util.List<Memory.Data> getStack()
Returns a list containing the current stack

Returns:
The list of data.

push

void push(Memory.Data data)
          throws SystemException
Pushes a data object on the stack

Parameters:
data - The data object to push on the stack
Throws:
SystemException - if there is an error accessing the stack

push

void push(int value,
          Memory.Type type)
          throws SystemException
Pushes a value/type pair on the stack

Parameters:
value - The value to push on the stack
type - The type of this value
Throws:
SystemException - if there is an error accessing the stack

pushINT

void pushINT(int i)
             throws SystemException
Pushes an integer on the stack

Parameters:
i - The integer to push
Throws:
SystemException - if there is an error accessing the stack

pushCH

void pushCH(char ch)
            throws SystemException
Pushes a character on the stack

Parameters:
ch - The character to push
Throws:
SystemException - if there is an error accessing the stack

pushMA

void pushMA(int ma)
            throws SystemException
Pushes a memory address on the stack

Parameters:
ma - The address to push
Throws:
SystemException - if there is an error accessing the stack

pushPA

void pushPA(int pa)
            throws SystemException
Pushes a program address on the stack

Parameters:
pa - The program address to push
Throws:
SystemException - if there is an error accessing the stack

pushFLOAT

void pushFLOAT(float fl)
               throws SystemException
Pushes a floating pointer number on the stack

Parameters:
fl - The floating point number to push
Throws:
SystemException - if there is an error accessing the stack

pop

Memory.Data pop()
                throws SystemException
Pops a data object off the stack

Returns:
The data object popped off the stack
Throws:
SystemException - if there is an error accessing the stack

popValue

int popValue()
             throws SystemException
Pops a value off the stack

Returns:
The value popped off the stack
Throws:
SystemException - if there is an error accessing the stack

popINT

int popINT()
           throws SystemException
Pops an integer off the stack

Returns:
The integer popped off the stack
Throws:
SystemException - if there is an error accessing the stack

popCH

char popCH()
           throws SystemException
Pops a character off the stack

Returns:
The character popped off the stack
Throws:
SystemException - if there is an error accessing the stack

popMA

int popMA()
          throws SystemException
Pops a memory address off the stack

Returns:
The memory address popped off the stack
Throws:
SystemException - if there is an error accessing the stack

popPA

int popPA()
          throws SystemException
Pops a program address off the stack

Returns:
The program address popped off the stack
Throws:
SystemException - if there is an error accessing the stack

popFLOAT

float popFLOAT()
               throws SystemException
Pops a floating pointer number off the stack

Returns:
The floating pointer number popped off the stack
Throws:
SystemException - if there is an error accessing the stack