1
0

変数の使えないダイレクトモードを実装

This commit is contained in:
otya128
2016-02-22 22:23:36 +09:00
parent 0deea64fc4
commit 76aea0c4e6
4 changed files with 185 additions and 159 deletions

View File

@@ -14,7 +14,7 @@
<verbose>0</verbose> <verbose>0</verbose>
<vtls>0</vtls> <vtls>0</vtls>
<vgc>0</vgc> <vgc>0</vgc>
<symdebug>1</symdebug> <symdebug>2</symdebug>
<optimize>0</optimize> <optimize>0</optimize>
<cpu>0</cpu> <cpu>0</cpu>
<isX86_64>0</isX86_64> <isX86_64>0</isX86_64>
@@ -72,7 +72,7 @@
<debuglevel>0</debuglevel> <debuglevel>0</debuglevel>
<debugids /> <debugids />
<versionlevel>0</versionlevel> <versionlevel>0</versionlevel>
<versionids>NDirectMode</versionids> <versionids />
<dump_source>0</dump_source> <dump_source>0</dump_source>
<mapverbosity>0</mapverbosity> <mapverbosity>0</mapverbosity>
<createImplib>0</createImplib> <createImplib>0</createImplib>

View File

@@ -60,6 +60,7 @@ class VM
void directSlot(Code[] code, int len, VMVariable[wstring] globalTable, Function[wstring] functions, DataTable gdt/*GNU Debugging Tools*/, void directSlot(Code[] code, int len, VMVariable[wstring] globalTable, Function[wstring] functions, DataTable gdt/*GNU Debugging Tools*/,
int[wstring] globalLabel, DebugInfo dinfo) int[wstring] globalLabel, DebugInfo dinfo)
{ {
this.pc = currentSlot.code.length;
this.currentSlot.code ~= code; this.currentSlot.code ~= code;
} }
void loadSlot(int slot, Code[] code, int len, VMVariable[wstring] globalTable, Function[wstring] functions, DataTable gdt/*GNU Debugging Tools*/, void loadSlot(int slot, Code[] code, int len, VMVariable[wstring] globalTable, Function[wstring] functions, DataTable gdt/*GNU Debugging Tools*/,

View File

@@ -163,6 +163,7 @@ class Function
} }
class Compiler class Compiler
{ {
bool isDirectMode;
ValueType getType(wstring name) ValueType getType(wstring name)
{ {
wchar s = name[name.length - 1]; wchar s = name[name.length - 1];
@@ -1050,8 +1051,15 @@ class Compiler
genCode(new EndVM()); genCode(new EndVM());
return code; return code;
} }
void compileDirectMode(VM vm)
{
isDirectMode = true;
compileProgram();
vm.directSlot(code, globalIndex + 1, global, functions, globalScope.data, globalLabel, debugInfo);
}
VM compile() VM compile()
{ {
isDirectMode = false;
compileProgram(); compileProgram();
VM vm = new VM(); VM vm = new VM();
vm.loadSlot(0, code, globalIndex + 1, global, functions, globalScope.data, globalLabel, debugInfo); vm.loadSlot(0, code, globalIndex + 1, global, functions, globalScope.data, globalLabel, debugInfo);

View File

@@ -233,8 +233,8 @@ class PetitComputer
rect.y = 0; rect.y = 0;
rect.w = src.w; rect.w = src.w;
rect.h = src.h; rect.h = src.h;
// SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND); // SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND);
// SDL_SetSurfaceBlendMode(src, SDL_BLENDMODE_BLEND); // SDL_SetSurfaceBlendMode(src, SDL_BLENDMODE_BLEND);
ubyte sr, sg, sb, sa; ubyte sr, sg, sb, sa;
SDL_GetRGBA((cast(uint*)src.pixels)[0], src.format, &sr, &sg, &sb, &sa); SDL_GetRGBA((cast(uint*)src.pixels)[0], src.format, &sr, &sg, &sb, &sa);
@@ -740,7 +740,6 @@ class PetitComputer
glBindFramebufferEXT(GL_FRAMEBUFFER, old); glBindFramebufferEXT(GL_FRAMEBUFFER, old);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
drawflag = false; drawflag = false;
this.chScreen(0, 0, 400, 240);
glEnable(GL_ALPHA_TEST); glEnable(GL_ALPHA_TEST);
} }
Button[] buttonTable; Button[] buttonTable;
@@ -802,7 +801,7 @@ class PetitComputer
DerelictGL.load(); DerelictGL.load();
DerelictGL3.load(); DerelictGL3.load();
bool renderprofile = true; bool renderprofile;// = true;
try try
{ {
version(Windows) version(Windows)
@@ -894,6 +893,7 @@ class PetitComputer
} }
glLoadIdentity(); glLoadIdentity();
renderGraphic(); renderGraphic();
chScreen(0, 0, 400, 240);
if(xscreenmode == 1) if(xscreenmode == 1)
{ {
chScreen(0, 240, 400, 240); chScreen(0, 240, 400, 240);
@@ -1058,6 +1058,7 @@ class PetitComputer
Parser parser; Parser parser;
otya.smilebasic.vm.VM vm; otya.smilebasic.vm.VM vm;
bool running; bool running;
bool directMode = false;
//デバッグ用 //デバッグ用
version(NDirectMode) version(NDirectMode)
{ {
@@ -1131,16 +1132,9 @@ class PetitComputer
} }
} }
else else
{/*
if(!vm)
{ {
import otya.smilebasic.vm; directMode = true;
vm = new VM(); /*vm.code.append(parser.compiler.compileProgram());*/
vm.init(this);
}
auto prg = input("", true);
parser = new Parser(prg);
vm.code.append(parser.compiler.compileProgram());*/
version(none) version(none)
do do
{ {
@@ -1179,6 +1173,23 @@ class PetitComputer
} while(!quit); } while(!quit);
} }
if(quit) return; if(quit) return;
do
{
if(directMode)
{
if(!vm)
{
import otya.smilebasic.vm;
vm = (new Parser("")).compile;
vm.init(this);
}
auto prg = input("", true);
parser = new Parser(prg);
auto cc = parser.compiler;
cc.compileDirectMode(vm);
vm.dump();
running = true;
}
//vm.dump; //vm.dump;
this.vm = vm; this.vm = vm;
bg[0].put(0,0,1); bg[0].put(0,0,1);
@@ -1208,6 +1219,10 @@ class PetitComputer
printConsole(loc.line, ":", loc.pos, ":", parser.getLine(loc)); printConsole(loc.line, ":", loc.pos, ":", parser.getLine(loc));
} }
} }
if(!running)
{
if(directMode) break;
}
} }
catch(SmileBasicError sbe) catch(SmileBasicError sbe)
{ {
@@ -1255,6 +1270,7 @@ class PetitComputer
break; break;
} }
} }
} while(directMode);
scope(exit) scope(exit)
{ {
writeln("quit"); writeln("quit");
@@ -1306,12 +1322,13 @@ class PetitComputer
CSRX--; CSRX--;
continue; continue;
} }
printConsole(key);
if(key == '\r') if(key == '\r')
{ {
k = key; k = key;
printConsole("\n");
break; break;
} }
printConsole(key);
buffer ~= key; buffer ~= key;
} }
clearKeyBuffer(); clearKeyBuffer();