変数周りのバグ取った
This commit is contained in:
@@ -56,9 +56,14 @@ class VM
|
|||||||
slots[i] = new VMSlot();
|
slots[i] = new VMSlot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int currentSlotNumber()
|
||||||
|
{
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
void setCurrentSlot(int slot)
|
void setCurrentSlot(int slot)
|
||||||
{
|
{
|
||||||
currentSlot = slots[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*/,
|
void directSlot(int start, 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)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class DebugInfo
|
|||||||
}
|
}
|
||||||
SourceLocation getLocationByAddress(int addr)
|
SourceLocation getLocationByAddress(int addr)
|
||||||
{
|
{
|
||||||
|
if(location.length <= addr) return SourceLocation(0, 0, 0);
|
||||||
return location[addr];
|
return location[addr];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1062,6 +1063,7 @@ class Compiler
|
|||||||
auto start = vm.currentSlot.code.length;
|
auto start = vm.currentSlot.code.length;
|
||||||
this.code = vm.currentSlot.code;
|
this.code = vm.currentSlot.code;
|
||||||
globalIndex = vm.currentSlot.global.length;
|
globalIndex = vm.currentSlot.global.length;
|
||||||
|
functions = vm.currentSlot.functions;
|
||||||
compileProgram();
|
compileProgram();
|
||||||
vm.directSlot(start, code, globalIndex + 1, global, functions, globalScope.data, globalLabel, debugInfo);
|
vm.directSlot(start, code, globalIndex + 1, global, functions, globalScope.data, globalLabel, debugInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -820,6 +820,7 @@ class PetitComputer
|
|||||||
buttonTable[SDL_SCANCODE_LEFT] = Button.LEFT;
|
buttonTable[SDL_SCANCODE_LEFT] = Button.LEFT;
|
||||||
buttonTable[SDL_SCANCODE_RIGHT] = Button.RIGHT;
|
buttonTable[SDL_SCANCODE_RIGHT] = Button.RIGHT;
|
||||||
buttonTable[SDL_SCANCODE_SPACE] = Button.A;
|
buttonTable[SDL_SCANCODE_SPACE] = Button.A;
|
||||||
|
buttonTable[SDL_SCANCODE_ESCAPE] = Button.START;
|
||||||
if(!window)
|
if(!window)
|
||||||
{
|
{
|
||||||
write("can't create window: ");
|
write("can't create window: ");
|
||||||
@@ -1000,6 +1001,10 @@ class PetitComputer
|
|||||||
{
|
{
|
||||||
auto key = event.key.keysym.sym;
|
auto key = event.key.keysym.sym;
|
||||||
button |= buttonTable[event.key.keysym.scancode];
|
button |= buttonTable[event.key.keysym.scancode];
|
||||||
|
if(Button.START & buttonTable[event.key.keysym.scancode])
|
||||||
|
{
|
||||||
|
stop();
|
||||||
|
}
|
||||||
if(key == SDLK_BACKSPACE)
|
if(key == SDLK_BACKSPACE)
|
||||||
{
|
{
|
||||||
keybuffermutex.lock();
|
keybuffermutex.lock();
|
||||||
@@ -1041,6 +1046,13 @@ class PetitComputer
|
|||||||
SDL_Window* window;
|
SDL_Window* window;
|
||||||
otya.smilebasic.vm.VM vm;
|
otya.smilebasic.vm.VM vm;
|
||||||
int maincnt;
|
int maincnt;
|
||||||
|
bool running;
|
||||||
|
bool stopflg;
|
||||||
|
void stop()
|
||||||
|
{
|
||||||
|
running = false;
|
||||||
|
stopflg = true;
|
||||||
|
}
|
||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
keybuffer = new wchar[128];
|
keybuffer = new wchar[128];
|
||||||
@@ -1057,7 +1069,6 @@ class PetitComputer
|
|||||||
auto startTicks = SDL_GetTicks();
|
auto startTicks = SDL_GetTicks();
|
||||||
Parser parser;
|
Parser parser;
|
||||||
otya.smilebasic.vm.VM vm;
|
otya.smilebasic.vm.VM vm;
|
||||||
bool running;
|
|
||||||
bool directMode = false;
|
bool directMode = false;
|
||||||
//デバッグ用
|
//デバッグ用
|
||||||
version(NDirectMode)
|
version(NDirectMode)
|
||||||
@@ -1195,7 +1206,7 @@ class PetitComputer
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
printConsole(sbe.getErrorMessage, "\n");
|
printConsole(sbe.getErrorMessage, "\n");
|
||||||
printConsole(sbe.getErrorMessage2, "\n");
|
if(sbe.getErrorMessage2.length) printConsole(sbe.getErrorMessage2, "\n");
|
||||||
//printConsole(sbe.to!string);
|
//printConsole(sbe.to!string);
|
||||||
writeln(sbe.to!string);
|
writeln(sbe.to!string);
|
||||||
writeln(sbe.getErrorMessage2);
|
writeln(sbe.getErrorMessage2);
|
||||||
@@ -1254,10 +1265,6 @@ 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)
|
||||||
{
|
{
|
||||||
@@ -1265,7 +1272,7 @@ class PetitComputer
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
printConsole(sbe.getErrorMessage, "\n");
|
printConsole(sbe.getErrorMessage, "\n");
|
||||||
printConsole(sbe.getErrorMessage2, "\n");
|
if(sbe.getErrorMessage2.length) printConsole(sbe.getErrorMessage2, "\n");
|
||||||
//printConsole(sbe.to!string);
|
//printConsole(sbe.to!string);
|
||||||
writeln(sbe.to!string);
|
writeln(sbe.to!string);
|
||||||
writeln(sbe.getErrorMessage2);
|
writeln(sbe.getErrorMessage2);
|
||||||
@@ -1291,6 +1298,16 @@ class PetitComputer
|
|||||||
writeln(t);
|
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;
|
//elapse = SDL_GetTicks() - startTicks;
|
||||||
} //while(elapse <= 1000 / 60);
|
} //while(elapse <= 1000 / 60);
|
||||||
if(vsyncFrame)
|
if(vsyncFrame)
|
||||||
|
|||||||
Reference in New Issue
Block a user