我正在使用RemObjects的PascalScript和SynEdit编辑器创建一个内置的脚本引擎。使用PascalScript附带的集成开发环境示例和SynEdit中的集成开发环境示例差不多完成了-但是-我不知道如何询问PascalScript一个编号的源码行是否是“可执行的”。(然后我可以用这个用“Delphi蓝点”来标记SynEdit间隔)。我想我可能需要对ROPS输出进行反汇编?
这里有PascalScript专家吗?谢谢。布莱恩。
发布于 2009-06-26 21:34:17
请看一下Inno Setup的源代码。它确实会在包含可执行代码的行的SynEdit栏区域中显示一个小点,灰色的点表示可执行但尚未执行的行,绿色的点表示至少命中一次的行。
这方面的代码可以在CompForm.pas中找到,查找TLineState类型。信息是在编译器回调的iscbNotifySuccess状态中设置的,你可以在你的集成开发环境中做同样的事情。您可能需要调整代码以处理多个源文件,因为Inno Setup编译器只处理单个源文件中的代码片段。
在Pascal脚本源代码中,您应该看看TPSCustomDebugExec.TranslatePositionEx()方法-它也返回源文件的名称。
发布于 2009-06-26 19:50:57
我不知道它是如何做到的,但PascalScript包中的集成开发环境项目(在\samples\debug下)能够提供单步执行和单步执行(F7和F8)功能,所以从逻辑上讲,它必须有某种方法将PS字节码与脚本代码行关联起来。试着检查一下这个项目,看看它是如何做到的。作为一个额外的好处,它也使用了SynEdit,所以它的想法很容易适应你自己的系统。
发布于 2015-11-06 06:52:18
我知道这是一个古老的问题,但我自己也在做同样的事情,上面的建议并没有真正的帮助。例如,Inno setup没有使用Synedit,它使用的是scintilla编辑器。
此外,TPSCustomDebugExec.TranslatePositionEx()的作用与所需的相反,它从运行时代码位置给出源码行号。
在摸索了一段时间后,我得出结论,最简单的方法是在Pascalscript代码中添加一个函数。
新方法被添加到uPSdebugger单元中的TPSCustomDebugExec类中。
function TPSCustomDebugExec.HasCode(Filename:string; LineNo:integer):boolean;
var i,j:integer; fi:PFunctionInfo; pt:TIfList; r:PPositionData;
begin
result:=false;
for i := 0 to FDebugDataForProcs.Count -1 do
begin
fi := FDebugDataForProcs[i];
pt := fi^.FPositionTable;
for j := 0 to pt.Count -1 do
begin
r:=pt[j];
result:= SameText(r^.FileName,Filename) and (r^.Row=LineNo);
if result then exit
end;
end;
end;并且主编辑器窗体中的绘制间隔回调如下所示
procedure Teditor.PaintGutterGlyphs(ACanvas:TCanvas; AClip:TRect;
FirstLine, LastLine: integer);
var a,b:boolean; LH,LH2,X,Y,ImgIndex:integer;
begin
begin
FirstLine := Ed.RowToLine(FirstLine);
LastLine := Ed.RowToLine(LastLine);
X := 14;
LH := Ed.LineHeight;
LH2:=(LH-imglGutterGlyphs.Height) div 2;
while FirstLine <= LastLine do
begin
Y := LH2+LH*(Ed.LineToRow(FirstLine)-Ed.TopLine);
a:= ce.HasBreakPoint(ce.MainFileName,FirstLine);
b:= ce.Exec.HasCode(ce.MainFileName,FirstLine);
if Factiveline=FirstLine then
begin
if a then
ImgIndex := 2 //Blue arrow+red dot (breakpoint and execution point)
else
ImgIndex := 1; //Blue arrow (current line execution point)
end
else
if b then
begin
if a then
ImgIndex := 3 //Valid Breakpoint marker
else
ImgIndex := 0; //blue dot (has code)
end
else
begin
if a then
ImgIndex := 4 //Invalid breakpoint (No code on this line)
else
ImgIndex := -1; //Empty (No code for line)
end;
if ImgIndex >= 0 then
imglGutterGlyphs.Draw(ACanvas, X,Y,ImgIndex);
Inc(FirstLine);
end;
end;
end;具有行号、代码点、断点、书签和执行点的Synedit如下图所示

https://stackoverflow.com/questions/1049948
复制相似问题