[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 66/99: Implement misc built-ins
From: |
Christopher Allan Webber |
Subject: |
[Guile-commits] 66/99: Implement misc built-ins |
Date: |
Sun, 10 Oct 2021 21:51:04 -0400 (EDT) |
cwebber pushed a commit to branch compile-to-js-merge
in repository guile.
commit 46fa3b2fb8cbce9b55870a3f472d8a9b3f6f50c6
Author: Ian Price <ianprice90@googlemail.com>
AuthorDate: Thu Aug 3 00:16:02 2017 +0100
Implement misc built-ins
* module/language/js-il/runtime.js
(scm->u64): New primitive
(integer?, char=?, make-fluid, read-hash-extend, make-hook,
simple-format, scm-error): Implement built-ins.
(syntax-session-id, macroexpand, %exception-handler,
print-exception, *features*, %load-hook, current-reader): Stubbed
variables.
---
module/language/js-il/runtime.js | 53 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/module/language/js-il/runtime.js b/module/language/js-il/runtime.js
index 1ff5ae1..72e0a0a 100644
--- a/module/language/js-il/runtime.js
+++ b/module/language/js-il/runtime.js
@@ -108,6 +108,10 @@ scheme.primitives["u64->=-scm"] = function(x, y) {
return coerce_bool(x >= y);
};
+scheme.primitives["scm->u64"] = function(x) {
+ return x;
+};
+
// Boxes
scheme.Box = function (x) {
this.x = x;
@@ -636,6 +640,7 @@ function scm_list (self, cont) {
};
def_guile0("list", scm_list);
+// Numbers
function scm_add(self, cont) {
var total = 0;
@@ -658,6 +663,11 @@ function scm_mul(self, cont) {
};
def_guile0("*", scm_mul);
+def_guile0("integer?", function(self, cont, obj) {
+ // return coerce_bool(Number.isInteger(obj)); // ES6
+ return cont(coerce_bool(typeof(obj) === 'number'));
+});
+
// Lists
def_guile0("make-list", function (self, cont, n, obj) {
var list = scheme.EMPTY;
@@ -797,6 +807,10 @@ function scm_gensym (self, cont, prefix) {
};
def_guile0("gensym", scm_gensym);
+// Chars
+def_guile0("char=?", function (self, cont, char1, char2) {
+ return cont(char1.c === char2.c);
+});
// Strings
def_guile0("string=?", function (self, cont, s1, s2) {
@@ -830,6 +844,11 @@ def_guile0("string-join", function (self, cont, strings) {
return cont(new scheme.String(s));
});
+// Fluids
+def_guile0("make-fluid", function (self, cont, val) {
+ return cont(new scheme.Fluid(val));
+});
+
// Structs
var vtable_base_layout = new scheme.String("pruhsruhpwphuhuh");
def_guile_val("standard-vtable-fields", vtable_base_layout);
@@ -1097,3 +1116,37 @@ def_guile0("set-current-module", function (self, cont,
module) {
return cont(scheme.FALSE);
});
+// Stubs
+function stub(name) {
+ function scm_fn (self, cont) {
+ console.log(name, arguments);
+ not_implemented_yet();
+ };
+ def_guile0(name, scm_fn);
+};
+
+stub("syntax-session-id");
+stub("macroexpand");
+stub("%exception-handler");
+stub("print-exception");
+stub("*features*");
+stub("%load-hook");
+stub("current-reader");
+
+def_guile0("read-hash-extend", function (self, cont, char, fun) {
+ return cont(scheme.FALSE);
+});
+
+def_guile0("make-hook", function (self, cont, nargs) {
+ return cont(scheme.FALSE);
+});
+
+function scm_simple_format (self, cont) {
+ not_implemented_yet();
+};
+def_guile0("simple-format", scm_simple_format);
+
+def_guile0("scm-error", function (self, cont, key, subr, message, args, data) {
+ not_implemented_yet();
+});
+
- [Guile-commits] 83/99: Implement variable-bound? builtin, (continued)
- [Guile-commits] 83/99: Implement variable-bound? builtin, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 88/99: read argument to --depends switch, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 89/99: extra-dependencies go before boot-dependencies, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 90/99: Mention all arguments to guild jslink in --help, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 92/99: Merge branch 'compile-to-js-2017' into compile-to-js-rebase, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 99/99: Compile cps to bytecode by default, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 24/99: Primitives create multiple argument continuations., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 14/99: Add binop type, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 53/99: Implement Winding & Unwinding, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 63/99: Implement hashtable built-ins, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 66/99: Implement misc built-ins,
Christopher Allan Webber <=
- [Guile-commits] 61/99: define! primitive only takes one argument., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 69/99: Unwind prompt frames, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 67/99: Make child structs applicable., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 74/99: Reimplement JS module system primitives., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 95/99: Fix import of lower-cps in compile-js.scm, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 73/99: Implement unboxed integer primitives., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 76/99: Separate public / private module lookups, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 77/99: Search for variables in imports., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 93/99: Fix module/Makefile.am after compile-to-js merge, Christopher Allan Webber, 2021/10/10