/* ATSextcode_beg() */
// COMMENT_line
// COMMENT_line
// COMMENT_line
var fs = require('fs');
eval(fs.readFileSync('./../prelude/CATS/integer_cats.js').toString());
/* ATSextcode_end() */
function
fact(arg0)
{
// __patsflab_fact
tmp1 = ats2jspre_gt_int0_int0(arg0, 0)
if (tmp1) {
tmp3 = ats2jspre_sub_int0_int0(arg0, 1)
tmp2 = fact(tmp3)
tmpret0 = ats2jspre_mul_int0_int0(arg0, tmp2)
} else {
tmpret0 = 1
} // endif
return tmpret0
}
/* ATSextcode_beg() */
console.log("fact(10) = ", fact(10))
/* ATSextcode_end() */
--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/b67fead7-b66a-40e0-82fe-2bf6a8279e1a%40googlegroups.com.
function
fact(arg0)
{
//
var tmpret0
var tmp1
var tmp2
var tmp3
//
// __patsflab_fact
tmp1 = ats2jspre_gt_int0_int0(arg0, 0)
if (tmp1) {
tmp3 = ats2jspre_sub_int0_int0(arg0, 1)
tmp2 = fact(tmp3)
tmpret0 = ats2jspre_mul_int0_int0(arg0, tmp2)
} else {
tmpret0 = 1
} // endif
return tmpret0
} // end-of-function
Okay, I have got the ball rolling:
https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript
I am currently targeting Node.js. This is the first running example I had: […]
Also, as the compilation from C source to the final binary target make uses of macro, why not do the same for C to JS and use the C preprocessor to generate JS files from the C files, as the C files seems to be made of a predefined set of macros?
Okay, I have got the ball rolling:
https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript
[…]
%{$
try {
js_main_dynload();
}
catch (e) {
alert(e);
}
%}
Okay, I have got the ball rolling:
https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript
#define ATS_MAINATSFLAG 1
#define ATS_DYNLOADNAME "js_main_dynload"
#include "share/atspre_define.hats"
#include "{$LIBATSCC2JS}/staloadall.hats"
sortdef reference = int
typedef reference = [r: reference] int(r)
typedef reference(r: reference) = int(r)
abstype element
stacst not_null(r: reference): bool
extern fun {r: reference} not_null(r: reference r): bool(not_null(r))
extern fun element{r: reference | not_null(r)}(r: reference r): element
extern fun reference(k: string): reference
val r: reference = reference("foo")
val b: bool = not_null(r)
val () =
if b then
let val e: element = element(r)
in () end
%{$
js_main_dynload();
%}Hello from atscc2js!
ParsingErrors:
:236:35:
error(parsing): the keyword [)] is needed.
:236:1:
error(parsing): the keyword [}] is needed.ATSINSmove(statmp1, PMVtmpltcstmat[0](not_null<S2Evar(r$1076(4441))>)(statmp0)) ;--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/e62a5141-4ab0-406f-a193-99d529d22419%40googlegroups.com.
not_null is a template, and it is never implemented.
extern fun not_null{r: reference}(r: reference r): bool(not_null(r))Okay, I have got the ball rolling:
https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript
I am currently targeting Node.js. This is the first running example I had:
[…]
--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/74394103-20ec-443e-b424-18767c75bb62%40googlegroups.com.
Okay, I added a quick fix.I am in the process of restructuring atscc2js. I will have something more modular soon.
Okay, I have got the ball rolling:
https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript
[…]
#define ATS_MAINATSFLAG 1
#define ATS_DYNLOADNAME "js_main_dynload"
#include "share/atspre_define.hats"
#include "{$LIBATSCC2JS}/staloadall.hats"
staload NS = "test-2.dats"
dynload "test-2.dats"
val y = $NS.x + "b"
(*JS*)
%{$
js_main_dynload();
%}
#define ATS_MAINATSFLAG 1
#include "share/atspre_define.hats"
#include "{$LIBATSCC2JS}/staloadall.hats"
extern val x: string
implement x = "a"
./test-2.js:10: WARNING - Redeclared variable: […]_dats__dynloadflag
var […]_dats__dynloadflag = 0;
^
./test-2.js:10: ERROR - Variable […]_dats__dynloadflag first declared in ./test-1.js
var […]_dats__dynloadflag = 0;
^
1 error(s), 1 warning(s)Will do it later. It probably just needs some compilation flags.
For now, I'd like to experiment co-programming with ATS and Node.js.
On Friday, August 22, 2014 3:18:21 PM UTC-4, Martin DeMello wrote:Why not target asm.js rather than javascript proper?martin
On Fri, Aug 22, 2014 at 11:58 AM, gmhwxi <gmh...@gmail.com> wrote:
Okay, I have got the ball rolling:
https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/JavaScript
I am currently targeting Node.js. This is the first running example I had:
--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/b67fead7-b66a-40e0-82fe-2bf6a8279e1a%40googlegroups.com.
This is the first I've heard of WebAssembly; http://www.osnews.com/story/28637/The_web_is_getting_its_bytecode_WebAssembly
Looks like it is quite a ways from even a draft spec for now.