|
|||||||||
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 Memory
public void setSystem(Sys sys)
Memory
setSystem
in interface Memory
sys
- The Sys objectpublic HeapAllocator getHeapAllocator()
Memory
getHeapAllocator
in interface Memory
public void setHeapAllocator(HeapAllocator heap)
Memory
setHeapAllocator
in interface Memory
heap
- The allocatorpublic void init()
Memory
init
in interface Memory
public Memory.Data getMem(int pos) throws SystemException
Memory
getMem
in interface Memory
pos
- The memory address
SystemException
- if there is an error accessing memorypublic int getValue(int pos) throws SystemException
Memory
getValue
in interface Memory
pos
- The memory address
SystemException
- if there is an error accessing memorypublic Memory.Type getType(int pos) throws SystemException
Memory
getType
in interface Memory
pos
- The memory address
SystemException
- if there is an error accessing memorypublic void setMem(int pos, Memory.Data data) throws SystemException
Memory
setMem
in interface Memory
data
- The data object to set
SystemException
- if there is an error accessing memorypublic void setMem(int pos, int data, Memory.Type type) throws SystemException
Memory
setMem
in interface Memory
data
- The value to storetype
- The type of this value
SystemException
- if there is an error accessing memorypublic void setValue(int pos, int data) throws SystemException
Memory
setValue
in interface Memory
data
- The value to store
SystemException
- if there is an error accessing memorypublic void setType(int pos, Memory.Type type) throws SystemException
Memory
setType
in interface Memory
type
- 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 Memory
alloc
- 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 Memory
SystemException
- if there is an error accessing the stackpublic int popValue() throws SystemException
Memory
popValue
in interface Memory
SystemException
- if there is an error accessing the stackpublic void push(Memory.Data data) throws SystemException
Memory
push
in interface Memory
data
- The data object to push on the stack
SystemException
- if there is an error accessing the stackpublic void push(int value, Memory.Type type) throws SystemException
Memory
push
in interface Memory
value
- The value to push on the stacktype
- The type of this value
SystemException
- if there is an error accessing the stackpublic float popFLOAT() throws SystemException
Memory
popFLOAT
in interface Memory
SystemException
- if there is an error accessing the stackpublic void pushFLOAT(float fl) throws SystemException
Memory
pushFLOAT
in interface Memory
fl
- The floating point number to push
SystemException
- if there is an error accessing the stackpublic int popINT() throws SystemException
Memory
popINT
in interface Memory
SystemException
- if there is an error accessing the stackpublic void pushINT(int i) throws SystemException
Memory
pushINT
in interface Memory
i
- The integer to push
SystemException
- if there is an error accessing the stackpublic char popCH() throws SystemException
Memory
popCH
in interface Memory
SystemException
- if there is an error accessing the stackpublic void pushCH(char ch) throws SystemException
Memory
pushCH
in interface Memory
ch
- The character to push
SystemException
- if there is an error accessing the stackpublic int popPA() throws SystemException
Memory
popPA
in interface Memory
SystemException
- if there is an error accessing the stackpublic void pushPA(int pa) throws SystemException
Memory
pushPA
in interface Memory
pa
- The program address to push
SystemException
- if there is an error accessing the stackpublic int popMA() throws SystemException
Memory
popMA
in interface Memory
SystemException
- if there is an error accessing the stackpublic void pushMA(int ma) throws SystemException
Memory
pushMA
in interface Memory
ma
- 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 |