[Pas2js] Disable optimization in specific units/blocks

silvioprog silvioprog at gmail.com
Fri Jan 11 19:54:46 CET 2019


On Fri, Jan 11, 2019 at 3:15 PM Mattias Gaertner via Pas2js <
pas2js at lists.freepascal.org> wrote:
[...]

> As I already wrote, the reason that this fails, is *because* pas2js
> leaves your asm in peace.
> You want the opposite. pas2js should parse the asm and replace
> Pascal references with JS references.
>

Almost that, but no need to parse the JS, just not remove it from the final
script. For example, I could use an include:

$ cat my-boring-polyfill-but-very-required.js
SomeClass.prototype.fooBar = (function() {
  alert("Oh yes, baby!");
});

$ cat myawesomeprogram.pp
program myawesomeprogram;

procedure fooBar;
asm
  {$I 'my-boring-polyfiil-but-very-required.js'}
end;

(just explaining, I don't tried includes yet ...)

then the compiler just include 'my-boring-polyfill-but-very-required.js'
and keep it in the final script, without parsing/removing it.

I understood that the only way to do that is by adding some dummy code in
the asm block or doing some explicit reference to the Pascal code, so maybe
I'm dreaming high desiring a better alternative to solve this. 😀

For example:
> ---snip---
> type
>   TDemo = class Name: string end;
> var
>   D: TDemo;
> {$parse-asm-pas}
> asm
>   window.Myfunction1 = Myfunction(pas(D.Name));
> end;
> ---snap---
>

It sounds good (by using directive). Any plans to support something like
this (in future)?

best,

-- 
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20190111/38d6a970/attachment-0001.html>


More information about the Pas2js mailing list