[Pas2js] Disable optimization in specific units/blocks

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Jan 11 19:15:18 CET 2019


On Fri, 11 Jan 2019 14:21:50 -0300
silvioprog <silvioprog at gmail.com> wrote:

>[....] A good option would be
> ("*please_leave_my_asm_function_in_peace*" just to make it comical):
> 
> *{$please_leave_my_asm_function_in_peace ON}*
> procedure foo;
> asm
>   alert('leave me in peace, compiler!');
> end;
> *{$endif}*

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

will convert the asm block to

---snip---
  window.Myfunction1 = Myfunction($mod.D.Name);
---snap---

And the compiler knows that D and D.Name are used.

Note: this is just a demo, not a proposal.

Mattias


More information about the Pas2js mailing list