[Pas2js] Compiler Options as Hints in Pas sources?
Michael Van Canneyt
michael at freepascal.org
Fri Dec 21 08:47:18 CET 2018
On Thu, 20 Dec 2018, Sergei Vertiev wrote:
> Hi All pas2js gurus!
> What if i want to use modules/functions/classes (generated from Pas
> sources by pas2js) from manually written JS code?
> Does really such scenario assumed somehow? Is there some best
> practices concerning this?
>
> In this case i probably will have some modules/functions/classes not
> used from other Pas modules but intended to be used directly from JS
> code.
>
> But all declarations, not used in other Pas modules, are simply
> ignored by pas2js,
> probably because of following optimization swithes:
> -OoRemoveNotUsedPrivates[-] : Default is enabled
> -OoRemoveNotUsedDeclarations[-] : Default enabled for programs with -Jc
>
> Is there some way to specify some pas2js Compiler hints in some PAS
> sources for set this optimization OFF?
> E.g. something like this.
> {$modeswitch $OoRemoveNotUsedDeclarations-}
> or may be
> {$pas2js -OoRemoveNotUsedDeclarations-} would be better...
For the moment, you will have to use -O-
But implementing some switch should be possible. I don't think this should
be a mode switch (they control language features) but an optimization
switch, as they exist in FPC itself:
https://www.freepascal.org/docs-html/current/prog/progsu58.html
Michael.
More information about the Pas2js
mailing list