[fpc-pascal] Re: Get all caller adresses of a given
function/procedure before executing
lazarus at mfriebe.de
Tue Aug 14 14:36:44 CEST 2012
On 14/08/2012 13:19, Rainer Stratmann wrote:
> It was more or less exactly the way I did it before with little exaggerating
> as you notice :-)
> Even now I save 50% codesize in comparison to resourcestring.
If you don't like resource string, inho there are 2 alternatives that
are (IMHO) better:
plain array with all text constants. You can break it into one array per
unit, and have a register a search-handler via the unit's initialization.
const MySnippets: Array [1..xxx] of string = ('text', '...', ... ];
For more readability (but it adds source code (should not add more to exe)
MySnippets: Array [1..xxx] of string = (snip1, '...', ... ];
(actually, I havent testet if the compiler takes the 2nd
Since you seem to want something that is easier to type.
Instead of analysing the exe, write your own pre-precessor.
The pre-processor can scan the source, create a temporary copy in which
it replaces the text in ls() with a reference to the "MySnippets" array.
It also creates and includes a unit with that array.
It then calls the compiler on the temporary created sources....
At least it will keep working even if fpc internals change. And it is
cross platform (includes cross-CPU)
More information about the fpc-pascal