From e8c53dc3e8d293ef750f3780b999783ae3537ba9 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sun, 20 Oct 2013 15:33:06 +0100 Subject: [PATCH] Remove old unfinished virtual machine and Lua bindings for it --- src/cat/LuaScriptInterface.cpp | 99 -- src/cat/LuaScriptInterface.h | 11 - src/pim/Generator.cpp | 518 ----------- src/pim/Generator.h | 178 ---- src/pim/Machine.cpp | 637 ------------- src/pim/Machine.h | 120 --- src/pim/Opcodes.h | 12 - src/pim/Opcodes.inl | 28 - src/pim/Parser.cpp | 653 -------------- src/pim/Parser.h | 79 -- src/pim/Scanner.cpp | 199 ----- src/pim/Scanner.h | 22 - src/pim/Token.cpp | 51 -- src/pim/Token.h | 83 -- src/tests/PowderInteractionMachine.cpp | 21 - src/tests/VirtualMachineTest.cpp | 16 - src/tests/test.qvm | Bin 2340 -> 0 bytes src/virtualmachine/Exceptions.h | 100 --- src/virtualmachine/JustInTime.cpp | 1144 ------------------------ src/virtualmachine/Operations.cpp | 356 -------- src/virtualmachine/Operations.inl | 60 -- src/virtualmachine/Syscalls.cpp | 99 -- src/virtualmachine/Syscalls.inl | 14 - src/virtualmachine/VirtualMachine.cpp | 405 --------- src/virtualmachine/VirtualMachine.h | 282 ------ tptlibrary/file.c | 15 - tptlibrary/tpt_syscalls.asm | 16 - tptlibrary/tpt_syscalls.h | 20 - 28 files changed, 5238 deletions(-) delete mode 100644 src/pim/Generator.cpp delete mode 100644 src/pim/Generator.h delete mode 100644 src/pim/Machine.cpp delete mode 100644 src/pim/Machine.h delete mode 100644 src/pim/Opcodes.h delete mode 100644 src/pim/Opcodes.inl delete mode 100644 src/pim/Parser.cpp delete mode 100644 src/pim/Parser.h delete mode 100644 src/pim/Scanner.cpp delete mode 100644 src/pim/Scanner.h delete mode 100644 src/pim/Token.cpp delete mode 100644 src/pim/Token.h delete mode 100644 src/tests/PowderInteractionMachine.cpp delete mode 100644 src/tests/VirtualMachineTest.cpp delete mode 100644 src/tests/test.qvm delete mode 100644 src/virtualmachine/Exceptions.h delete mode 100644 src/virtualmachine/JustInTime.cpp delete mode 100644 src/virtualmachine/Operations.cpp delete mode 100644 src/virtualmachine/Operations.inl delete mode 100644 src/virtualmachine/Syscalls.cpp delete mode 100644 src/virtualmachine/Syscalls.inl delete mode 100644 src/virtualmachine/VirtualMachine.cpp delete mode 100644 src/virtualmachine/VirtualMachine.h delete mode 100644 tptlibrary/file.c delete mode 100644 tptlibrary/tpt_syscalls.asm delete mode 100644 tptlibrary/tpt_syscalls.h diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index d1319f71b..d7f683503 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -23,10 +23,6 @@ #include "client/HTTP.h" #include "PowderToy.h" -//#include "virtualmachine/VirtualMachine.h" -#include "pim/Parser.h" -#include "pim/Machine.h" - #include "LuaBit.h" #include "LuaWindow.h" @@ -118,7 +114,6 @@ LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m): initInterfaceAPI(); initRendererAPI(); initElementsAPI(); - initVirtualMachineAPI(); initGraphicsAPI(); initFileSystemAPI(); @@ -1873,49 +1868,6 @@ void LuaScriptInterface::initElementsAPI() } } -pim::VirtualMachine * LuaScriptInterface::updateVirtualMachines[PT_NUM]; - -int LuaScriptInterface::updateVM(UPDATE_FUNC_ARGS) -{ - pim::VirtualMachine * machine = updateVirtualMachines[parts[i].type]; - - machine->CSPush(i); - machine->CSPush(x); - machine->CSPush(y); - machine->Call(0); - - - /*vm::VirtualMachine * vMachine = updateVirtualMachines[parts[i].type]; - - vm::word w; - int argAddr = 0, argCount = 5; - vMachine->sim = sim; - - vMachine->OpPUSH(w); //Pointless null in stack - w.int4 = (argCount + 2) * sizeof(vm::word); - vMachine->OpENTER(w); - argAddr = 8; - - //Arguments - w.int4 = i; vMachine->Marshal(argAddr, w); argAddr += 4; - w.int4 = x; vMachine->Marshal(argAddr, w); argAddr += 4; - w.int4 = y; vMachine->Marshal(argAddr, w); argAddr += 4; - w.int4 = nt; vMachine->Marshal(argAddr, w); argAddr += 4; - w.int4 = surround_space; vMachine->Marshal(argAddr, w); argAddr += 4; - - w.int4 = 0; - vMachine->Push(w); - - vMachine->OpCALL(w); - vMachine->Run(); - w.int4 = (argCount + 2) * sizeof(vm::word); - vMachine->OpLEAVE(w); - vMachine->OpPOP(w); //Pop pointless null - vMachine->End();*/ - - return 0; -} - int LuaScriptInterface::elements_loadDefault(lua_State * l) { int args = lua_gettop(l); @@ -2238,11 +2190,6 @@ int LuaScriptInterface::elements_property(lua_State * l) else lua_el_mode[id] = 1; } - else if(lua_type(l, 3) == LUA_TLIGHTUSERDATA) - { - updateVirtualMachines[id] = (pim::VirtualMachine*)lua_touserdata(l, 3); - luacon_sim->elements[id].Update = &updateVM; - } else if(lua_type(l, 3) == LUA_TBOOLEAN && !lua_toboolean(l, 3)) { lua_el_func[id] = 0; @@ -2347,52 +2294,6 @@ int LuaScriptInterface::elements_free(lua_State * l) return 0; } -void LuaScriptInterface::initVirtualMachineAPI() -{ - //Methods - struct luaL_reg vmAPIMethods [] = { - {"loadProgram", virtualMachine_loadProgram}, - {NULL, NULL} - }; - luaL_register(l, "virtualMachine", vmAPIMethods); - - //elem shortcut - lua_getglobal(l, "virtualMachine"); - lua_setglobal(l, "vm"); -} - -int LuaScriptInterface::virtualMachine_loadProgram(lua_State * l) -{ - /*luaL_checktype(l, 1, LUA_TSTRING); - - vm::VirtualMachine * newVM = new vm::VirtualMachine(1); - try - { - const char * tempString = lua_tostring(l, 1); - int tempStringLength = lua_strlen(l, 1); - std::vector programData(tempString, tempString+tempStringLength); - newVM->LoadProgram(programData); - } - catch(std::exception & e) - { - return luaL_error(l, "Unable to load program"); - } - lua_pushlightuserdata(l, newVM);*/ - std::string programSource(lua_tostring(l, 1)); - std::stringstream input(programSource); - - - pim::compiler::Parser * parser = new pim::compiler::Parser(input); - - std::vector programData = parser->Compile(); - - pim::VirtualMachine * machine = new pim::VirtualMachine(luacon_sim); - machine->LoadProgram(programData); - - lua_pushlightuserdata(l, machine); - return 1; -} - void LuaScriptInterface::initGraphicsAPI() { //Methods diff --git a/src/cat/LuaScriptInterface.h b/src/cat/LuaScriptInterface.h index eda6832a0..a443a9de4 100644 --- a/src/cat/LuaScriptInterface.h +++ b/src/cat/LuaScriptInterface.h @@ -16,10 +16,6 @@ namespace ui class Window; } -namespace pim -{ - class VirtualMachine; -} class Tool; //Because lua only has bindings for C, we're going to have to go outside "outside" the LuaScriptInterface, this means we can only have one instance :( @@ -115,9 +111,6 @@ class LuaScriptInterface: public CommandInterface static int renderer_debugHUD(lua_State * l); //Elements - static pim::VirtualMachine * updateVirtualMachines[PT_NUM]; - static int updateVM(UPDATE_FUNC_ARGS); - // void initElementsAPI(); static int elements_allocate(lua_State * l); static int elements_element(lua_State * l); @@ -132,10 +125,6 @@ class LuaScriptInterface: public CommandInterface static int interface_addComponent(lua_State * l); static int interface_removeComponent(lua_State * l); - //VM - void initVirtualMachineAPI(); - static int virtualMachine_loadProgram(lua_State * l); - void initGraphicsAPI(); static int graphics_textSize(lua_State * l); static int graphics_drawText(lua_State * l); diff --git a/src/pim/Generator.cpp b/src/pim/Generator.cpp deleted file mode 100644 index 3292c8aa2..000000000 --- a/src/pim/Generator.cpp +++ /dev/null @@ -1,518 +0,0 @@ -//Code generator for bytecode -#include -#include -#include "Format.h" -#include "Generator.h" -#include "Opcodes.h" -namespace pim -{ - namespace compiler - { - Generator::Generator() : - output(std::cout), - labelCounter(0), - programCounter(0) - { - - } - - void Generator::defineLabel(std::string label) - { - Label newLabel; - newLabel.Name = label; - newLabel.Position = programCounter;//program.size(); - labelPositions.push_back(newLabel); - } - - void Generator::writeOpcode(int opcode) - { - programCounter++; - program.push_back(opcode); - } - - void Generator::writeConstant(std::string constant) - { - writeConstant(format::StringToNumber(constant)); - } - - void Generator::writeConstant(int constant) - { - program.push_back(constant & 0xFF); - program.push_back((constant>>8) & 0xFF); - program.push_back((constant>>16) & 0xFF); - program.push_back((constant>>24) & 0xFF); - } - - void Generator::writeConstantPlaceholder(std::string label) - { - placeholders.push_back(Placeholder(program.size(), label)); - program.push_back(0); - program.push_back(0); - program.push_back(0); - program.push_back(0); - } - - void Generator::writeConstantPlaceholder(int * value) - { - valuePlaceholders.push_back(ValuePlaceholder(program.size(), value)); - program.push_back(0); - program.push_back(0); - program.push_back(0); - program.push_back(0); - } - - void Generator::writeConstantPropertyPlaceholder(std::string property) - { - propertyPlaceholders.push_back(PropertyPlaceholder(program.size(), property)); - program.push_back(0); - program.push_back(0); - program.push_back(0); - program.push_back(0); - } - - void Generator::writeConstantMacroPlaceholder(std::string macro) - { - macroPlaceholders.push_back(MacroPlaceholder(program.size(), macro)); - program.push_back(0); - program.push_back(0); - program.push_back(0); - program.push_back(0); - } - - std::vector Generator::Finish() - { - //All compile time labels, macros, etc - for(std::vector::iterator iter = placeholders.begin(), end = placeholders.end(); iter != end; ++iter) - { - bool found = false; - Placeholder cPosition = *iter; - for(std::vector