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>
<vtls>0</vtls>
<vgc>0</vgc>
<symdebug>1</symdebug>
<symdebug>2</symdebug>
<optimize>0</optimize>
<cpu>0</cpu>
<isX86_64>0</isX86_64>
@@ -72,7 +72,7 @@
<debuglevel>0</debuglevel>
<debugids />
<versionlevel>0</versionlevel>
<versionids>NDirectMode</versionids>
<versionids />
<dump_source>0</dump_source>
<mapverbosity>0</mapverbosity>
<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*/,
int[wstring] globalLabel, DebugInfo dinfo)
{
this.pc = currentSlot.code.length;
this.currentSlot.code ~= code;
}
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
{
bool isDirectMode;
ValueType getType(wstring name)
{
wchar s = name[name.length - 1];
@@ -1050,8 +1051,15 @@ class Compiler
genCode(new EndVM());
return code;
}
void compileDirectMode(VM vm)
{
isDirectMode = true;
compileProgram();
vm.directSlot(code, globalIndex + 1, global, functions, globalScope.data, globalLabel, debugInfo);
}
VM compile()
{
isDirectMode = false;
compileProgram();
VM vm = new VM();
vm.loadSlot(0, code, globalIndex + 1, global, functions, globalScope.data, globalLabel, debugInfo);

View File

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