<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body smarttemplateinserted="true" text="#000000" bgcolor="#FFFFFF">
<div id="smartTemplate4-template">Hi,<br>
<br>
<p> </p>
<blockquote type="cite"><br>
Naturally, any memory pointer operation is not possible in
Javascript. Code that relies on this will not work. <br>
</blockquote>
<p><br>
</p>
<p>it would be great, if pointers were added.</p>
<p><br>
</p>
<p>One trick would be to wrap every variable that is accessed by a
pointer in an array (or object). The array can then be used as
reference.</p>
<p>For example:</p>
<p>var a: integer;<br>
b: pinteger;</p>
<p>begin</p>
<p> a := 10;<br>
b := @a;<br>
b^ := 11;<br>
writeln(a);<br>
writeln(b^);</p>
end;<br>
<p>becomes</p>
<p> var a,b<br>
a = [10]<br>
b = a<br>
b[0] = 11;<br>
alert(a[0])<br>
alert(b[0]) <br>
</p>
<p><br>
</p>
<p>For pointer arithmetic or pointers inside array elements, it
would need an additional index:<br>
</p>
<p>For example:<br>
<br>
var a: integer = 10;<br>
ar: array[0..1] of integer = (1,2);<br>
b: pinteger;<br>
<br>
begin<br>
b := @a;<br>
b^ := 11;<br>
b := @ar[1]<br>
b^ := 12;<br>
dec(b);<br>
b^ := 13;<br>
end;<br>
<br>
becomes<br>
<br>
var a,b,bi,ar <br>
a = [10]<br>
ar = [1,2] <br>
b = a; bi = 0<br>
b[bi] = 11;<br>
b = ar; bi = 1<br>
b[bi] = 12;<br>
bi--;<br>
b[bi] = 13;<br>
<br>
</p>
It does not cover pointers of mixed sizes (e.g. getting a pbyte of
an integer, or converting double to int64), but the most common
things should work. pchars should probably get special treatment,
too. When it is not modified, there is no need to wrap a string in
an array, but just keep a string reference plus index. Perhaps
there need to be two type of pchars, readonly and writeable. Only
writeable need wrapping.<br>
<br>
And then there needs to be some kind of static analysis that only
wraps those variables/fields in arrays whose address is actually
taken anywhere.<br>
<br>
<br>
Best,<br>
Benito </div>
<br>
<br>
<br>
<div class="moz-cite-prefix">Am 16.12.2017 um 17:36 schrieb Michael
Van Canneyt:<br>
</div>
<blockquote type="cite"
cite="mid:alpine.DEB.2.20.1712161655180.32745@home.telenet.be"> <br>
Hello fellow Pascal enthousiasts, <br>
<br>
It is with great pleasure that I can finally announce the first
publicly <br>
available version of pas2js. A "beta" version, version 0.8.39. <br>
The endpoint (for the time being) of nearly 10 years of (slow)
development. <br>
<br>
pas2js is a Object Pascal to Javascript transpiler. It compiles
Object <br>
pascal, and emits Javascript. The javascript is usable in the
browser, and <br>
in Node.js. <br>
<br>
It is open source, and part of FPC/Lazarus. This makes Free Pascal
a full-stack development environment for Web Development: <br>
You can use it to program the server and the browser alike, all
from within <br>
the environment you love so much :) <br>
<br>
What does pas2js include ? <br>
-------------------------- <br>
<br>
* On the language level: <br>
<br>
It supports basically Delphi 7 syntax, interfaces excepted. <br>
Naturally, any memory pointer operation is not possible in
Javascript. Code that relies on this will not work. <br>
<br>
This is just the first version, we of course want to add the same
language features that exist in Delphi and FPC today. <br>
<br>
* On the runtime level: <br>
<br>
Beside the compiler itself, there is a basic Object Pascal RTL,
and several units from the FPC Packages are also available: <br>
<br>
system <br>
sysutils <br>
Math <br>
strutils <br>
rtlconst <br>
classes <br>
contnrs <br>
DB (yes, TDataset) <br>
fpcunit testsuite <br>
custapp <br>
restconnection <br>
js (javascript system objects) <br>
web (browser provided objects) <br>
libjquery (jquery is available too) <br>
nodejs (basic node runtime environment) <br>
typeinfo <br>
objpas <br>
browserconsole (support for writeln) <br>
dateutils <br>
browserapp <br>
nodejsapp <br>
<br>
* Debugging: <br>
<br>
Obviously, the browser debugger can be used to debug the
Javascript. <br>
But there is more: the compiler can emit a source map, and this
means that <br>
if the browser finds the source file, it will display the original
source <br>
file instead of the javascript. You can debug Object pascal in the
browser. <br>
<br>
* Demoes ? <br>
<br>
The package has several demoes, including FPReport, TDataset,
JQuery and <br>
Bootstrap. <br>
<br>
* Documentation ? <br>
<br>
As befits an open source project, docs are lagging behind :/ <br>
<br>
But a WIKI page has been started, it will be expanded as time
permits: <br>
<br>
<a class="moz-txt-link-freetext"
href="http://wiki.freepascal.org/pas2js">http://wiki.freepascal.org/pas2js</a>
<br>
<br>
* Sources ? <br>
<br>
The pas2js compiler sources and RTL sources have been checked in
in FPC's subversion repository. The page describes where to find
it in SVN. <br>
<br>
* Binaries ? <br>
<br>
A snapshot is available: <br>
<a class="moz-txt-link-freetext"
href="http://www.freepascal.org/%7Emichael/pas2js/pas2js-demo-0.8.39.zip">http://www.freepascal.org/~michael/pas2js/pas2js-demo-0.8.39.zip</a>
<br>
<br>
* Reporting bugs ? <br>
<br>
The FPC bugtracker has now a 'pas2js' project, it can be used to
report <br>
bugs. <br>
<br>
* Can you help ? <br>
<br>
Yes, of course. There is still a lot of work to be done. Feel free
to contact me or Mattias Gaertner with questions. <br>
<br>
What about Lazarus ? <br>
-------------------- <br>
<br>
Lazarus "understands" the extensions to object pascal (for
importing Javascript <br>
classes) that were borrowed from the JVM version of the compiler,
so the <br>
code completion will continue to work. <br>
<br>
Using the pre-compiler command, CTRL-F9 just works. On error, you
will be <br>
shown the error location etc. <br>
<br>
Further and deeped integration of pas2js into lazarus is expected.
In the first place, IDE integration. Later on, a real widget set
for the browser can (and hopefully will) be created. <br>
<br>
But that is not all ! <br>
--------------------- <br>
<br>
In the very near future, a major Delphi component vendor will
announce a <br>
complete package for RAD web development in the Delphi IDE. The
expectation is that later on, the exact same components will be
usable in Lazarus. In essence, the component developer has created
a complete browser <br>
widgetset. More than 100 controls are available. <br>
<br>
Using this, you can design a web application as you design a
desktop app; <br>
Fully RAD, as you are used to. But even more, you can bind
controls on a form to existing tags in a web page, thus preserving
the style in the web page. <br>
<br>
The first demoes for a selected audience have evoked very positive
feedback <br>
indeed. <br>
<br>
All this is based on pas2js. <br>
<br>
As soon as I receive permission, I will announce here where it
becomes <br>
available. <br>
<br>
Lastly! <br>
------- <br>
<br>
On a more personal note, I wish to explicitly thank Mattias
Gaertner for finally <br>
finishing what has been started a long time ago. <br>
<br>
Without him, none of this would have been possible. <br>
<br>
The same is true for Detlef Overbeek, editor of Blaise Pascal
magazine, <br>
without his moral and financial help, it would have taken many
more years to <br>
finish this. <br>
<br>
It is - for me - a long standing dream finally come true. <br>
<br>
Enjoy ! <br>
<br>
Michael. <br>
_______________________________________________ <br>
fpc-devel maillist - <a class="moz-txt-link-abbreviated"
href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<br>
<a class="moz-txt-link-freetext"
href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>
<br>
</blockquote>
<br>
</body>
</html>