|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.cornell.cs.sam.core.SamMemory
public class SamMemory
Memory implementation: Integer Array - Alternating data/type fields, 32-bit wide - Even addresses contain type - Odd addresses contain data
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface edu.cornell.cs.sam.core.Memory |
|---|
Memory.Data, Memory.Type |
| Field Summary |
|---|
| Fields inherited from interface edu.cornell.cs.sam.core.Memory |
|---|
MEMORYLIMIT, STACKLIMIT, UNIT_SIZE |
| Constructor Summary | |
|---|---|
SamMemory(Sys sys)
|
|
| 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 heap)
Set the HeapAllocator object associated with this memory. |
void |
setMem(int pos,
int data,
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 data)
Stores the given value in memory |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SamMemory(Sys sys)
| Method Detail |
|---|
public Sys getSystem()
Memory
getSystem in interface Memorypublic void setSystem(Sys sys)
Memory
setSystem in interface Memorysys - The Sys objectpublic HeapAllocator getHeapAllocator()
Memory
getHeapAllocator in interface Memorypublic void setHeapAllocator(HeapAllocator heap)
Memory
setHeapAllocator in interface Memoryheap - The allocatorpublic void init()
Memory
init in interface Memory
public Memory.Data getMem(int pos)
throws SystemException
Memory
getMem in interface Memorypos - The memory address
SystemException - if there is an error accessing memory
public int getValue(int pos)
throws SystemException
Memory
getValue in interface Memorypos - The memory address
SystemException - if there is an error accessing memory
public Memory.Type getType(int pos)
throws SystemException
Memory
getType in interface Memorypos - The memory address
SystemException - if there is an error accessing memory
public void setMem(int pos,
Memory.Data data)
throws SystemException
Memory
setMem in interface Memorydata - The data object to set
SystemException - if there is an error accessing memory
public void setMem(int pos,
int data,
Memory.Type type)
throws SystemException
Memory
setMem in interface Memorydata - The value to storetype - The type of this value
SystemException - if there is an error accessing memory
public void setValue(int pos,
int data)
throws SystemException
Memory
setValue in interface Memorydata - The value to store
SystemException - if there is an error accessing memory
public void setType(int pos,
Memory.Type type)
throws SystemException
Memory
setType in interface Memorytype - The type to set
SystemException - if there is an error accessing memorypublic java.util.List<Memory.Data> getAllocation(HeapAllocator.Allocation alloc)
Memory
getAllocation in interface Memoryalloc - The heap allocation
public java.util.List<Memory.Data> getStack()
Memory
getStack in interface Memory
public Memory.Data pop()
throws SystemException
Memory
pop in interface MemorySystemException - if there is an error accessing the stack
public int popValue()
throws SystemException
Memory
popValue in interface MemorySystemException - if there is an error accessing the stack
public void push(Memory.Data data)
throws SystemException
Memory
push in interface Memorydata - The data object to push on the stack
SystemException - if there is an error accessing the stack
public void push(int value,
Memory.Type type)
throws SystemException
Memory
push in interface Memoryvalue - The value to push on the stacktype - The type of this value
SystemException - if there is an error accessing the stack
public float popFLOAT()
throws SystemException
Memory
popFLOAT in interface MemorySystemException - if there is an error accessing the stack
public void pushFLOAT(float fl)
throws SystemException
Memory
pushFLOAT in interface Memoryfl - The floating point number to push
SystemException - if there is an error accessing the stack
public int popINT()
throws SystemException
Memory
popINT in interface MemorySystemException - if there is an error accessing the stack
public void pushINT(int i)
throws SystemException
Memory
pushINT in interface Memoryi - The integer to push
SystemException - if there is an error accessing the stack
public char popCH()
throws SystemException
Memory
popCH in interface MemorySystemException - if there is an error accessing the stack
public void pushCH(char ch)
throws SystemException
Memory
pushCH in interface Memorych - The character to push
SystemException - if there is an error accessing the stack
public int popPA()
throws SystemException
Memory
popPA in interface MemorySystemException - if there is an error accessing the stack
public void pushPA(int pa)
throws SystemException
Memory
pushPA in interface Memorypa - The program address to push
SystemException - if there is an error accessing the stack
public int popMA()
throws SystemException
Memory
popMA in interface MemorySystemException - if there is an error accessing the stack
public void pushMA(int ma)
throws SystemException
Memory
pushMA in interface Memoryma - The address to push
SystemException - if there is an error accessing the stack
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||