ブレークポイントを付けられるようにした
This commit is contained in:
@@ -110,6 +110,7 @@ class VM
|
|||||||
bp = 0;//globalを実行なのでbaseは0(グローバル変数をスタックに取るようにしない限り)(挙動的にスタックに確保していなさそう)
|
bp = 0;//globalを実行なのでbaseは0(グローバル変数をスタックに取るようにしない限り)(挙動的にスタックに確保していなさそう)
|
||||||
for(pc = 0; pc < this.currentSlot.code.length; pc++)
|
for(pc = 0; pc < this.currentSlot.code.length; pc++)
|
||||||
{
|
{
|
||||||
|
processBreakPoint;
|
||||||
currentSlot.code[pc].execute(this);
|
currentSlot.code[pc].execute(this);
|
||||||
}
|
}
|
||||||
if(stacki != 0)
|
if(stacki != 0)
|
||||||
@@ -126,10 +127,20 @@ class VM
|
|||||||
this.petitcomputer = petitcomputer;
|
this.petitcomputer = petitcomputer;
|
||||||
bp = 0;//globalを実行なのでbaseは0(グローバル変数をスタックに取るようにしない限り)(挙動的にスタックに確保していなさそう)
|
bp = 0;//globalを実行なのでbaseは0(グローバル変数をスタックに取るようにしない限り)(挙動的にスタックに確保していなさそう)
|
||||||
}
|
}
|
||||||
|
void processBreakPoint()
|
||||||
|
{
|
||||||
|
if (currentSlot.debugInfo.location[pc].isBreakPoint)
|
||||||
|
{
|
||||||
|
//TODO:まともにする
|
||||||
|
writefln("break point\nslot:%d,pc:%d,line:%d", currentSlotNumber, pc, currentSlot.debugInfo.location[pc].location.line);
|
||||||
|
readln();
|
||||||
|
}
|
||||||
|
}
|
||||||
bool runStep()
|
bool runStep()
|
||||||
{
|
{
|
||||||
if(pc < this.currentSlot.code.length)
|
if(pc < this.currentSlot.code.length)
|
||||||
{
|
{
|
||||||
|
processBreakPoint;
|
||||||
currentSlot.code[pc].execute(this);
|
currentSlot.code[pc].execute(this);
|
||||||
pc++;
|
pc++;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -6,25 +6,43 @@ import otya.smilebasic.type;
|
|||||||
import otya.smilebasic.error;
|
import otya.smilebasic.error;
|
||||||
import otya.smilebasic.systemvariable;
|
import otya.smilebasic.systemvariable;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
|
struct DebugData
|
||||||
|
{
|
||||||
|
SourceLocation location;
|
||||||
|
bool isBreakPoint;
|
||||||
|
}
|
||||||
class DebugInfo
|
class DebugInfo
|
||||||
{
|
{
|
||||||
sizediff_t old;
|
sizediff_t old;
|
||||||
std.container.Array!SourceLocation location;
|
std.container.Array!DebugData location;
|
||||||
|
std.container.Array!int line;
|
||||||
this()
|
this()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void addLocation(SourceLocation loc, Code[] code)
|
void addLocation(SourceLocation loc, Code[] code)
|
||||||
{
|
{
|
||||||
|
while (line.length < loc.line)
|
||||||
|
{
|
||||||
|
line ~= location.length;
|
||||||
|
}
|
||||||
for(int i = 0; i < code.length - old; i++)
|
for(int i = 0; i < code.length - old; i++)
|
||||||
{
|
{
|
||||||
location ~= loc;
|
location ~= DebugData (loc, false);
|
||||||
}
|
}
|
||||||
old = location.length;
|
old = location.length;
|
||||||
}
|
}
|
||||||
SourceLocation getLocationByAddress(int addr)
|
SourceLocation getLocationByAddress(int addr)
|
||||||
{
|
{
|
||||||
if(location.length <= addr) return SourceLocation(0, 0, 0);
|
if(location.length <= addr) return SourceLocation(0, 0, 0);
|
||||||
return location[addr];
|
return location[addr].location;
|
||||||
|
}
|
||||||
|
void setBreakPoint(int line)
|
||||||
|
{
|
||||||
|
location[this.line[line - 1]].isBreakPoint = true;
|
||||||
|
}
|
||||||
|
bool isBreakPoint(int line)
|
||||||
|
{
|
||||||
|
return location[this.line[line - 1]].isBreakPoint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class Scope
|
class Scope
|
||||||
|
|||||||
Reference in New Issue
Block a user