Working on TZCollection.Error ASM code
Posted: 16.06.2008, 19:04
Hello!
As I'm seeing these days, people have some problems with the assembly code in TZCollection.Error, which raises an error at the calling address.
ASM code in a multi-platform component isn't the best thing in the world, so I've did some research to find how eliminate it, or at least if it's possible to do that.
As I said, I think that this code just return a pointer for some address, so the exception can be raised at the right point. The TZCollection object inherits these procedure from VCL TList. The following is defined under classes.pas (delphi7):
Yes, exactly the same code. And as TCollection in VCL inherits from TList, it was just copied.
Then, we think: There's no special classes.pas in delphi7 for CLX, and I don't have any kylix at hand. Then I moved to Lazarus. The closest I can take is:
TList.Error is now renamed to TFPList.Error, at the file /objpas/classes/lists.inc, and implemented as follows:
Yep, no ASM, but two functions instead. I'm close, but I cannot find where these functions are implemented!!
I just found their documentation:
http://www.freepascal.org/docs-html/rtl ... _addr.html
http://www.freepascal.org/docs-html/rtl ... frame.html
When I looked at it, it says: "Source position: systemh.inc line 700", but systemh.inc is just a file that include other files, depending on the platform as I can imagine.
Anyone can help me in my "quest"?
Besides, google out there, I've found an article about porting ZeosLib to FPC64, but it's in russian! I've tried with google translator, but cannot got the right point. Anyone that can read russian, please?
Here's the article:
http://freepascal.ru/forum/viewtopic.php?f=6&t=3284
If it's done in lazarus, we can take it as basis and rework it in Zeos, then make it more compatible
As I'm seeing these days, people have some problems with the assembly code in TZCollection.Error, which raises an error at the calling address.
ASM code in a multi-platform component isn't the best thing in the world, so I've did some research to find how eliminate it, or at least if it's possible to do that.
As I said, I think that this code just return a pointer for some address, so the exception can be raised at the right point. The TZCollection object inherits these procedure from VCL TList. The following is defined under classes.pas (delphi7):
Code: Select all
class procedure TList.Error(const Msg: string; Data: Integer);
function ReturnAddr: Pointer;
asm
MOV EAX,[EBP+4]
end;
begin
raise EListError.CreateFmt(Msg, [Data]) at ReturnAddr;
end;
Yes, exactly the same code. And as TCollection in VCL inherits from TList, it was just copied.
Then, we think: There's no special classes.pas in delphi7 for CLX, and I don't have any kylix at hand. Then I moved to Lazarus. The closest I can take is:
TList.Error is now renamed to TFPList.Error, at the file /objpas/classes/lists.inc, and implemented as follows:
Code: Select all
class procedure TFPList.Error(const Msg: string; Data: PtrInt);
begin
Raise EListError.CreateFmt(Msg,[Data]) at get_caller_addr(get_frame);
end;
I just found their documentation:
http://www.freepascal.org/docs-html/rtl ... _addr.html
http://www.freepascal.org/docs-html/rtl ... frame.html
When I looked at it, it says: "Source position: systemh.inc line 700", but systemh.inc is just a file that include other files, depending on the platform as I can imagine.
Anyone can help me in my "quest"?
Besides, google out there, I've found an article about porting ZeosLib to FPC64, but it's in russian! I've tried with google translator, but cannot got the right point. Anyone that can read russian, please?
Here's the article:
http://freepascal.ru/forum/viewtopic.php?f=6&t=3284
If it's done in lazarus, we can take it as basis and rework it in Zeos, then make it more compatible