[fpc-pascal] Re: Get all caller adresses of a given function/procedure before executing

Rainer Stratmann RainerStratmann at t-online.de
Wed Aug 15 16:43:10 CEST 2012

Am Wednesday 15 August 2012 16:19:04 schrieb Marco van de Voort:
> > > If your source (main) language has a word with two meanings, how will
> > > you translate to a language where there is a word for each meaning?
> >
> > Then I can put an additional identifier like already mentioned.
> > ls( '~ID1~word' );
> > ls( '~ID2~word' );
> > In this case ID1 or ID2 is the identifier instead of 'word'.
> >
> > But in all cases 'word' is the result of the translation of the original
> > language.
> >
> > > IIRC dxgettext has only solutions for that when you recognize this
> > > early and add special code. This means that sometimes you can't simply
> > > ship a translation, but also have to
> >
> > In my case it can also be possible that there are not all words
> > translated yet. Then the original text is shown or englich one. The
> > translation can be made later. That is (also) an advantage.
> No it can't, since if two the same texts translate to a different texts in
> another language, you need to add the identifiers and rebuild,
> distribute/migrate etc.

Look at the top. The programmer must be aware of the two meanings and add a 
unique identifyer in front of the text. What you want to discuss here is 
specific and (more or less) deep. You want from me immediately a solution to 
all this kind of specific things.

> ITE doesn't have this limitation, since the fully qualified identifier is
> what uniquely identifies the text, not the content.
See above. You can also add a unique identifier if you want.
> The editor has some 
> features so that you don't have to translate something as "settings" twice.
> Moreover, ITE support widening and moving of components. (essentially
> anything published in forms is editable without recompilation)
> > > (dx)gettext also has support for stuff like multiples, textdomains.
> > > Some of it is not very well supported in the editor (gorm) though.
> >
> > I will use a browser as editor. So the utf8 (and unicode?) converting is
> > made automatically by the browser.  I have some code for converting ascii
> > <-> utf8.
> What do you assume about the codepage of literals? Do you pass the right
> -Fc parameters for that?

Please explain it more.

> > > It comes with source scanner tools to harvest strings from the code.
> >
> > Another step more that means more work and less easiness (less
> > userfriendly).
> Explain. You need to scan some way too.

Yes at programstart with searching the opcode for calls and loading the pchar 
const in EAX.

Post from 11.08.2012 which is searching the caller adresses of a given 
function (parameter proc_adr). With another piece of code I can get the 
pointer of all pchars if this proc has one pchar parameter.

It works!

procedure i_really_know_what_i_am_doing( p_opcode : pbyte ; count : longint ; 
proc_adr : pointer );
 call_opcode = $e8;
 caller_adr_pc_offset = 5;
 p_reladress : pdword; // call works with a relative adress after the opcode
 x , caller_adress , jmp_adr_abs : dword;
 for x := 1 to count do begin
  if p_opcode^ = call_opcode then begin
   p_reladress := pdword( p_opcode + 1 );                       // after 
opcode = relative adress to procedure/function to call
   caller_adress := dword( p_opcode + caller_adr_pc_offset );
   jmp_adr_abs := caller_adress + p_reladress^;                 // absolute 
adress = programcounter + 5 + relative adress
   if jmp_adr_abs = dword( proc_adr )
    then add_caller_adress_to_table( caller_adress );           // if call 
proc_adr then found!
  inc( p_opcode );

> How do you handle combining translations btw? (e.g. general framework and
> customer specific part on top of that?)

Until now I did not come in contact with that.
I don't know if it is necessary for me.
So I don't need to spend the time now for that.
But I am confident that there will be a solution for that.

More information about the fpc-pascal mailing list