<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">On Fri, Jan 11, 2019 at 3:15 PM Mattias Gaertner via Pas2js <<a href="mailto:pas2js@lists.freepascal.org">pas2js@lists.freepascal.org</a>> wrote:</div><div dir="ltr">[...]</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
As I already wrote, the reason that this fails, is *because* pas2js<br>
leaves your asm in peace.<br>
You want the opposite. pas2js should parse the asm and replace<br>
Pascal references with JS references.<br></blockquote><div><br></div><div>Almost that, but no need to parse the JS, just not remove it from the final script. For example, I could use an include:</div><div><br></div><div><font face="monospace, monospace" size="1">$ cat my-boring-polyfill-but-very-required.js</font></div><div><font face="monospace, monospace" size="1">SomeClass.prototype.fooBar = (function() {</font></div><div><font face="monospace, monospace" size="1">  alert("Oh yes, baby!");</font></div><div><font face="monospace, monospace" size="1">});</font></div><div><font face="monospace, monospace" size="1"><br></font></div><div><font face="monospace, monospace" size="1">$ cat myawesomeprogram.pp</font></div><div><font face="monospace, monospace" size="1">program myawesomeprogram;</font></div><div><font face="monospace, monospace" size="1"><br></font></div><div><font face="monospace, monospace" size="1">procedure fooBar;</font></div><div><font face="monospace, monospace" size="1">asm</font></div><div><font face="monospace, monospace" size="1">  {$I 'my-boring-polyfiil-but-very-required.js'}</font></div><div><font face="monospace, monospace" size="1">end;</font></div><div><br></div><div>(just explaining, I don't tried includes yet ...)</div><div><br></div><div>then the compiler just include 'my-boring-polyfill-but-very-required.js' and keep it in the final script, without parsing/removing it.</div><div><br></div><div>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. 😀</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
For example:<br>
---snip---<br>
type<br>
  TDemo = class Name: string end;<br>
var<br>
  D: TDemo;<br>
{$parse-asm-pas}<br>
asm<br>
  window.Myfunction1 = Myfunction(pas(D.Name));<br>
end;<br>
---snap---<br></blockquote><div><br></div><div>It sounds good (by using directive). Any plans to support something like this (in future)?</div></div><div><br></div><div>best,</div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Silvio Clécio</div></div></div></div></div></div>