diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-09-23 10:39:20 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-09-23 10:39:20 (GMT) |
| commit | 1905e497442bc39cf8896e54812718064a52d621 (patch) | |
| tree | ca472ca41bbe8ebfb15e71deb62670141fb4369a /src/pim/Machine.h | |
| parent | 644c1307124dffd13268445d0aebaed13a090c78 (diff) | |
| download | powder-1905e497442bc39cf8896e54812718064a52d621.zip powder-1905e497442bc39cf8896e54812718064a52d621.tar.gz | |
Macros and property setting
Diffstat (limited to 'src/pim/Machine.h')
| -rw-r--r-- | src/pim/Machine.h | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/pim/Machine.h b/src/pim/Machine.h index a40dd51..42147dd 100644 --- a/src/pim/Machine.h +++ b/src/pim/Machine.h @@ -2,6 +2,7 @@ #include <vector> #include <string> +#include <cstring> class Simulation; namespace pim @@ -20,6 +21,29 @@ namespace pim int Opcode; Word Parameter; }; + class InvalidProgramException: public std::exception + { + public: + InvalidProgramException() { } + const char * what() const throw() + { + return "Invalid program"; + } + ~InvalidProgramException() throw() {}; + }; + class UnresolvedValueException: public std::exception + { + char * error; + public: + UnresolvedValueException(std::string value) { + error = strdup(std::string("Unresolved value: " + value).c_str()); + } + const char * what() const throw() + { + return error; + } + ~UnresolvedValueException() throw() {}; + }; class VirtualMachine { @@ -42,7 +66,7 @@ namespace pim #define CSA(argument) (*((Word*)&ram[framePointer-argument])) #define CS() (*((Word*)&ram[callStack])) #define PS() (*((Word*)&ram[programStack])) - #define PPROP(index, property) (*((Word*)(&sim->parts[(index)]+property))) + #define PPROP(index, property) (*((Word*)(((char*)&sim->parts[(index)])+property))) int programStack; //Points to the item on top of the Program Stack int callStack; //Points to the item on top of the call stack |
