1
0

変数周りのバグ取った

This commit is contained in:
otya128
2016-02-22 23:26:44 +09:00
parent 5f0078a8f9
commit 32af97aa8f
3 changed files with 31 additions and 7 deletions

View File

@@ -56,9 +56,14 @@ class VM
slots[i] = new VMSlot();
}
}
int currentSlotNumber()
{
return slot;
}
void setCurrentSlot(int slot)
{
currentSlot = slots[slot];
this.slot = slot;
}
void directSlot(int start, Code[] code, int len, VMVariable[wstring] globalTable, Function[wstring] functions, DataTable gdt/*GNU Debugging Tools*/,
int[wstring] globalLabel, DebugInfo dinfo)

View File

@@ -23,6 +23,7 @@ class DebugInfo
}
SourceLocation getLocationByAddress(int addr)
{
if(location.length <= addr) return SourceLocation(0, 0, 0);
return location[addr];
}
}
@@ -1062,6 +1063,7 @@ class Compiler
auto start = vm.currentSlot.code.length;
this.code = vm.currentSlot.code;
globalIndex = vm.currentSlot.global.length;
functions = vm.currentSlot.functions;
compileProgram();
vm.directSlot(start, code, globalIndex + 1, global, functions, globalScope.data, globalLabel, debugInfo);
}

View File

@@ -820,6 +820,7 @@ class PetitComputer
buttonTable[SDL_SCANCODE_LEFT] = Button.LEFT;
buttonTable[SDL_SCANCODE_RIGHT] = Button.RIGHT;
buttonTable[SDL_SCANCODE_SPACE] = Button.A;
buttonTable[SDL_SCANCODE_ESCAPE] = Button.START;
if(!window)
{
write("can't create window: ");
@@ -1000,6 +1001,10 @@ class PetitComputer
{
auto key = event.key.keysym.sym;
button |= buttonTable[event.key.keysym.scancode];
if(Button.START & buttonTable[event.key.keysym.scancode])
{
stop();
}
if(key == SDLK_BACKSPACE)
{
keybuffermutex.lock();
@@ -1041,6 +1046,13 @@ class PetitComputer
SDL_Window* window;
otya.smilebasic.vm.VM vm;
int maincnt;
bool running;
bool stopflg;
void stop()
{
running = false;
stopflg = true;
}
void run()
{
keybuffer = new wchar[128];
@@ -1057,7 +1069,6 @@ class PetitComputer
auto startTicks = SDL_GetTicks();
Parser parser;
otya.smilebasic.vm.VM vm;
bool running;
bool directMode = false;
//デバッグ用
version(NDirectMode)
@@ -1195,7 +1206,7 @@ class PetitComputer
try
{
printConsole(sbe.getErrorMessage, "\n");
printConsole(sbe.getErrorMessage2, "\n");
if(sbe.getErrorMessage2.length) printConsole(sbe.getErrorMessage2, "\n");
//printConsole(sbe.to!string);
writeln(sbe.to!string);
writeln(sbe.getErrorMessage2);
@@ -1254,10 +1265,6 @@ class PetitComputer
printConsole(loc.line, ":", loc.pos, ":", parser.getLine(loc));
}
}
if(!running)
{
if(directMode) break;
}
}
catch(SmileBasicError sbe)
{
@@ -1265,7 +1272,7 @@ class PetitComputer
try
{
printConsole(sbe.getErrorMessage, "\n");
printConsole(sbe.getErrorMessage2, "\n");
if(sbe.getErrorMessage2.length) printConsole(sbe.getErrorMessage2, "\n");
//printConsole(sbe.to!string);
writeln(sbe.to!string);
writeln(sbe.getErrorMessage2);
@@ -1291,6 +1298,16 @@ class PetitComputer
writeln(t);
}
}
if(!running || stopflg)
{
if(stopflg)
{
loc = vm.currentLocation;
printConsole("Break on ", vm.currentSlotNumber, ":", loc.line, "\n");
stopflg = false;
}
if(directMode) break;
}
//elapse = SDL_GetTicks() - startTicks;
} //while(elapse <= 1000 / 60);
if(vsyncFrame)