Main Page Class Hierarchy Compound List File List Compound Members
Interpreter Class Reference
Detailed Description
private functions of class interpreter<Word,int> Impments the list of C-machine instructions and their implementations
Hidden assumptions:
Assumptions on parameter class Int: It must posess following methods:
- operator++(Word &)
- operator--(Word &)
- operator+ (Int&)
- operator- (Int&)
- operator--(Int &)
- operator++(Int &)
- operator< (Int&)
- operator<=(Int &)
- operator==(Int &)
- operator!=(Int &)
- Int(int&)
- char(Int&)
Assumptions on parameter class Word: It must posess following methods:
- operator++(Word &)
- operator--(Word &)
- operator- (Word&) unary minus
- operator *=(Word &)
- operator+=(Word &)
- operator-=(Word &)
- operator/=(Word &)
- operator%=(Word &)
- operator<<(Word &)
- operator>>(Word &)
- operator||(Word &)
- operator &&(Word &)
- operator! () unary negotation
- operator &=(Word &)
- operator|=(Word &)
- operator^=(Word &)
- operator~ () unary complement
- operator==(Word &)
- operator!=(Word &)
- operator< (Word&)
- operator<=(Word &)
- operator> (Word&)
- operator>=(Word &)
- operator= (Word&)
- operator= (Int&)
- Word(Int&)
- Word(int&)
Visible (class) variables are:
- Int PC, FP
- Heap heap
- Freestore freeStore
- Control *pControl(onOutput(char*,Int&), onInput(Int&), onComlete())
Heap and Code methods verifyXXX have following semantics:
- if everything is OK they return TRUE
- if something is WRONG they return FALSE
- they dont change state of Heap/Code
For efficiency reasons we always use newSP as value for new SP value because it has been already calculated. So it is CRUCIAL that
- SP points to last stack record which is used
- newSP points to last stack record after succesful operation (the operation itselt doesn' have to be succesful)
We also assume that SP and newSP are valid stack addresses ie.
- no STACK UNDERFLOW
- no STACK_OVERFLOW
If operation has two or more arguments in stack then the last argument is on top, ie. op(x,y) = op(heap[SP-1],heap[SP]).
For unification the first argument of every operation is newSP, even it does't need it.
Operation mark raises SP to SP+4 we assume that this is still smallereq. EP ie. EP is correctly calculated.
In operation alloc_memory we assume that Freestore method malloc is clever enough to release memory when needed. If allocation doesn't succeed we return NULL=(Word)0.
Operations load, store, loada, storea, loadr, storer will raise Error when address is NULL
Operation loadq is RENAMED to push.
Operation move starts coping from top to bottom and newer produces uncorrect result.
If the operation doesn't succeed the state of interpreter remains same as before executing operation.
List of all possible errors:
- STACK_OVERFLOW
- DIVISION_BY_ZERO
- MODULUS_IS_ZERO
- READ_FROM_NULL_POINTER
- WRONG_HEAP_ADDRESS
- WRITE_TO_NULL_POINTER
- WRONG_JUMP_ADDRESS
- WRONG_CALL_ADDRESS
- WRONG_HEAP_INTERVALL
- CALL_UNDERFLOW
- CORRUPTED_FRAME
- READ_FROM_STACK_FRAME
- WRITE_TO_STACK_FRAME
The documentation for this class was generated from the following file:
Generated on Tue Oct 12 01:39:17 1999 by
1.2.18