[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 22/99: Add more Scheme Primitives to runtime.js
From: |
Christopher Allan Webber |
Subject: |
[Guile-commits] 22/99: Add more Scheme Primitives to runtime.js |
Date: |
Sun, 10 Oct 2021 21:50:47 -0400 (EDT) |
cwebber pushed a commit to branch compile-to-js-merge
in repository guile.
commit 48e84c5a2c170e8b1d868705400821cff486e079
Author: Ian Price <ianprice90@googlemail.com>
AuthorDate: Mon Jun 15 16:37:22 2015 +0100
Add more Scheme Primitives to runtime.js
---
module/language/js-il/runtime.js | 95 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 94 insertions(+), 1 deletion(-)
diff --git a/module/language/js-il/runtime.js b/module/language/js-il/runtime.js
index 271e508..d0aff57 100644
--- a/module/language/js-il/runtime.js
+++ b/module/language/js-il/runtime.js
@@ -55,6 +55,17 @@ scheme.primitives["="] = function (x, y) {
scheme.primitives["<"] = function (x, y) {
return coerce_bool(x < y);
};
+
+scheme.primitives["<="] = function (x, y) {
+ return coerce_bool(x <= y);
+};
+
+scheme.primitives[">"] = function (x, y) {
+ return coerce_bool(x > y);
+};
+
+scheme.primitives[">="] = function (x, y) {
+ return coerce_bool(x >= y);
};
scheme.primitives.quo = not_implemented_yet;
@@ -67,6 +78,10 @@ scheme.Box = function (x) {
return this;
};
+scheme.primitives["box"] = function(x) {
+ return new scheme.Box(x);
+};
+
scheme.primitives["box-ref"] = function (box) {
return box.x;
};
@@ -82,6 +97,10 @@ scheme.Pair = function (car, cdr) {
return this;
};
+scheme.primitives["pair?"] = function (obj) {
+ return coerce_bool(obj instanceof scheme.Pair);
+};
+
scheme.primitives.cons = function (car, cdr) {
return new scheme.Pair(car,cdr);
};
@@ -94,6 +113,14 @@ scheme.primitives.cdr = function (obj) {
return obj.cdr;
};
+scheme.primitives["set-car!"] = function (pair, obj) {
+ obj.car = obj;
+};
+
+scheme.primitives["set-cdr!"] = function (pair, obj) {
+ obj.cdr = obj;
+};
+
scheme.list = function () {
var l = scheme.EMPTY;
for (var i = arguments.length - 1; i >= 0; i--){
@@ -117,12 +144,20 @@ scheme.Symbol = function(s) {
};
};
+scheme.primitives["symbol?"] = function (obj) {
+ return coerce_bool(obj instanceof scheme.Symbol);
+};
+
// Keywords
scheme.Keyword = function(s) {
this.name = s;
return this;
};
+scheme.primitives["keyword?"] = function (obj) {
+ return coerce_bool(obj instanceof scheme.Keyword);
+};
+
scheme.utils.keyword_ref = function(kw, args, start, dflt) {
var l = args.length;
@@ -160,22 +195,48 @@ scheme.primitives["vector-length"] = function (vec) {
return vec.array.length;
};
+scheme.primitives["vector?"] = function (obj) {
+ return coerce_bool(obj instanceof scheme.Vector);
+};
+
+scheme.primitives["make-vector/immediate"] = not_implemented_yet;
+scheme.primitives["vector-set!/immediate"] = not_implemented_yet;
+scheme.primitives["vector-ref/immediate"] = not_implemented_yet;
+
// Bytevectors
// Booleans
+scheme.primitives["boolean?"] = not_implemented_yet;
+
// Chars
scheme.Char = function(c) {
this.c = c;
return this;
};
+scheme.primitives["char?"] = function (obj) {
+ return coerce_bool(obj instanceof scheme.Char);
+};
+
// Strings
scheme.String = function(s) {
this.s = s;
return this;
};
+scheme.primitives["string?"] = function (obj) {
+ return coerce_bool(obj instanceof scheme.String);
+};
+
+scheme.primitives["string-length"] = function (str) {
+ return str.s.length;
+};
+
+scheme.primitives["string-ref"] = function (str, idx) {
+ return new scheme.Char(str.s[idx]);
+};
+
// Closures
scheme.Closure = function(f, size) {
this.fun = f;
@@ -208,6 +269,8 @@ scheme.primitives["cached-toplevel-box"] = function (scope,
sym, is_bound) {
return scheme.cache[scope][sym.name];
};
+scheme.primitives["cached-module-box"] = not_implemented_yet;
+
scheme.primitives["current-module"] = function () {
return scheme.env;
};
@@ -237,4 +300,34 @@ scheme.builtins[4] = new scheme.Closure(callcc, 0);
// M(call_with_values, CALL_WITH_VALUES, 2, 0, 0) \
// M(call_with_current_continuation, CALL_WITH_CURRENT_CONTINUATION, 1, 0, 0)
-// ---
+// Structs
+scheme.primitives["struct?"] = not_implemented_yet;
+scheme.primitives["struct-set!/immediate"] = not_implemented_yet;
+scheme.primitives["struct-vtable"] = not_implemented_yet;
+scheme.primitives["struct-ref/immediate"] = not_implemented_yet;
+scheme.primitives["struct-ref"] = not_implemented_yet;
+scheme.primitives["struct-set!"] = not_implemented_yet;
+scheme.primitives["allocate-struct/immediate"] = not_implemented_yet;
+
+// Equality
+scheme.primitives["eq?"] = function(x, y) {
+ return coerce_bool(x === y);
+};
+
+scheme.primitives["eqv?"] = function(x, y) {
+ return coerce_bool(x === y);
+};
+
+scheme.primitives["equal?"] = not_implemented_yet;
+
+// Fluids
+scheme.primitives["pop-fluid"] = not_implemented_yet;
+scheme.primitives["push-fluid"] = not_implemented_yet;
+scheme.primitives["fluid-ref"] = not_implemented_yet;
+
+// Variables
+scheme.primitives["variable?"] = not_implemented_yet;
+
+// Dynamic Wind
+scheme.primitives["wind"] = not_implemented_yet;
+scheme.primitives["unwind"] = not_implemented_yet;
- [Guile-commits] 64/99: Implement procedure built-ins., (continued)
- [Guile-commits] 64/99: Implement procedure built-ins., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 65/99: Implement module built-ins., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 72/99: Implement basic `equal?' implementation, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 68/99: struct-set! primitive returns no values, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 71/99: modules should be passed current continuation, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 79/99: Implement list builtins, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 80/99: *features* is an empty list, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 84/99: Add assignment js-type to (language javascript), Christopher Allan Webber, 2021/10/10
- [Guile-commits] 87/99: Create stub module forms for dependecies, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 97/99: Switch use of $closure to $const-fun, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 22/99: Add more Scheme Primitives to runtime.js,
Christopher Allan Webber <=
- [Guile-commits] 32/99: Rewrite js-il inliner, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 82/99: pop-fluid uses field of frame not fluid, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 85/99: Handle more JavaScript binary operators, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 86/99: Keywords cannot be both keyword and optional, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 91/99: Update Copyright Headers, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 94/99: Add compiler-chooser for CPS spec, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 96/99: Fix cps's choose-compiler to be able to compile javascript, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 98/99: Merge branch 'main' into compile-to-js-merge, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 78/99: Implement Hook Builtins, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 81/99: Argument to make-fluid is optional, Christopher Allan Webber, 2021/10/10