summaryrefslogtreecommitdiff
path: root/src/pim/Machine.h
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2013-10-20 14:33:06 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2013-10-20 14:33:06 (GMT)
commite8c53dc3e8d293ef750f3780b999783ae3537ba9 (patch)
treed9158731234905b36cae9991f49bbe99f82cd56a /src/pim/Machine.h
parenteea006ad6f63083782a3decda51b6bf80caa47af (diff)
downloadpowder-e8c53dc3e8d293ef750f3780b999783ae3537ba9.zip
powder-e8c53dc3e8d293ef750f3780b999783ae3537ba9.tar.gz
Remove old unfinished virtual machine and Lua bindings for it
Diffstat (limited to 'src/pim/Machine.h')
-rw-r--r--src/pim/Machine.h120
1 files changed, 0 insertions, 120 deletions
diff --git a/src/pim/Machine.h b/src/pim/Machine.h
deleted file mode 100644
index 0cbac4c..0000000
--- a/src/pim/Machine.h
+++ /dev/null
@@ -1,120 +0,0 @@
-#pragma once
-
-#include <vector>
-#include <string>
-#include <cstring>
-
-class Simulation;
-namespace pim
-{
- union Word
- {
- int Integer;
- float Decimal;
-
- Word(int integer) : Integer(integer) {}
- Word(float decimal) : Decimal(decimal) {}
- Word() {}
- };
- struct Instruction
- {
- 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
- {
-
- #define WORDSIZE 4
-
- //#define OPDEF(name) void op##name(int parameter);
- //#include "Opcodes.inl"
- //#undef OPDEF
-
- Simulation * sim;
-
- Instruction * rom;
- int romSize;
- int romMask;
-
- unsigned char * compiledRom;
- int compiledRomSize;
-
- unsigned char * ram;
- int ramSize;
- int ramMask;
-
- #define CSA(argument) (*((Word*)&ram[framePointer-argument]))
- #define CS() (*((Word*)&ram[callStack]))
- #define PS() (*((Word*)&ram[programStack]))
- #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
- int framePointer; //Points to the bottom (first item) on the current frame of the call stack
-
- //Instruction * instructions;
-
- int programCounter;
-
- void emit(std::string opcode);
- void emit(int constant);
- public:
- VirtualMachine(Simulation * sim);
- int OpcodeArgSize(int opcode);
- void LoadProgram(std::vector<unsigned char> programData);
- void Run();
- void Compile();
- void CallCompiled(std::string entryPoint);
- void CallCompiled(int entryPoint);
- void Call(std::string entryPoint);
- void Call(int entryPoint);
- inline void PSPush(Word word)
- {
- programStack -= WORDSIZE;
- PS() = word;
- }
-
- inline Word PSPop()
- {
- Word word = PS();
- programStack += WORDSIZE;
- return word;
- }
-
- inline void CSPush(Word word)
- {
- callStack -= WORDSIZE;
- CS() = word;
- }
-
- inline Word CSPop()
- {
- Word word = CS();
- callStack += WORDSIZE;
- return word;
- }
- };
-}