Do not compile unused procedures
Do not compile unused procedures
when using generic includes with lots of functions the small exe filesize can go away. i known i can use TB
Re: Do not compile unused procedures
I've been asking Fred for this for years. 

I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
i think it makes sense to turn pb into a two pass compiler...
in pass 1 look for all procedure and variable declarations (oh my, no more 'declare' statements... heaven...) and create a list of all called procedures
then, in pass 2, only compile what is used
i do think that makes sense, or doesn't it?
in pass 1 look for all procedure and variable declarations (oh my, no more 'declare' statements... heaven...) and create a list of all called procedures
then, in pass 2, only compile what is used
i do think that makes sense, or doesn't it?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
> i think it makes sense to turn pb into a two pass compiler
I think there are two main reasons why this hasn't been done (and this is
just my own speculation, and not fact):
(1) The extra slowdown that will be caused due to two passes. IMO: big deal.
(2) The "bad reputation" the compiler will get, because it can no longer be
classed as a "single pass" compiler. Frankly, I think a two pass compiler
would be more successful if advertised as two pass, because it would show
potential purchasers that it's more in-depth and thorough with its checking
than a single pass compiler.
Better code optimization, etc.
> in pass 1 look for all procedure and variable declarations (oh my, no more
> 'declare' statements... heaven...) and create a list of all called procedures
Very easy to do; I even wrote a little tool that does that so I can see what's
unused before I create my exes. I think there's a plugin for jaPBe that does
this also.
I think there are two main reasons why this hasn't been done (and this is
just my own speculation, and not fact):
(1) The extra slowdown that will be caused due to two passes. IMO: big deal.
(2) The "bad reputation" the compiler will get, because it can no longer be
classed as a "single pass" compiler. Frankly, I think a two pass compiler
would be more successful if advertised as two pass, because it would show
potential purchasers that it's more in-depth and thorough with its checking
than a single pass compiler.

> in pass 1 look for all procedure and variable declarations (oh my, no more
> 'declare' statements... heaven...) and create a list of all called procedures
Very easy to do; I even wrote a little tool that does that so I can see what's
unused before I create my exes. I think there's a plugin for jaPBe that does
this also.
Last edited by PB on Tue May 03, 2005 1:51 am, edited 3 times in total.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
imho,
An optional 1st pass could add so many optional features such as this and more (see the forum for other possibilities).
You could add a directive to the beginning of the source such as "PrePass" or similar to perform this extra pass.
Thus it remains a single pass compiler (by default).
-Anthony
An optional 1st pass could add so many optional features such as this and more (see the forum for other possibilities).
You could add a directive to the beginning of the source such as "PrePass" or similar to perform this extra pass.
Thus it remains a single pass compiler (by default).
-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
I agree with Justin about that a 2 pass compiler will be useful to remove none used functions.
It will be also useful to analyse correctly variable status.
Because, currently we meet the following problem with global variables:
The result is a= 10 and not 30.
But we can keep the current one pass compilation, and its speed efficiency, by giving to it the list of functions really used and variables status.
In fact, this list can be created during the code writing thinks to the editor capability rather than during a dedicated compiler pass.
For example, actually, JaPBe raises directly the list of all the functions and variables that are available in the code (which are used or not).
We can imagine distinguishing the used functions and referencing variable status, then giving this list to the single pass compiler.
Thus, this way of working needs two improvements:
- At the editor level: Its capability to raise the appropriate list of functions and variables (and any else). Let us note that the PureBasic standard editor already lists the procedures of a code.
- At the compiler level: its capability into receiving and analyzing the given list. The syntax would be similar to those of the already available compiler options.
This idea joins PB one.
It will be also useful to analyse correctly variable status.
Because, currently we meet the following problem with global variables:
Code: Select all
Procedure test()
a + 20
EndProcedure
Global a.l
a=10
test()
Debug a
But we can keep the current one pass compilation, and its speed efficiency, by giving to it the list of functions really used and variables status.
In fact, this list can be created during the code writing thinks to the editor capability rather than during a dedicated compiler pass.
For example, actually, JaPBe raises directly the list of all the functions and variables that are available in the code (which are used or not).
We can imagine distinguishing the used functions and referencing variable status, then giving this list to the single pass compiler.
Thus, this way of working needs two improvements:
- At the editor level: Its capability to raise the appropriate list of functions and variables (and any else). Let us note that the PureBasic standard editor already lists the procedures of a code.
- At the compiler level: its capability into receiving and analyzing the given list. The syntax would be similar to those of the already available compiler options.
This idea joins PB one.