guile-commits
[Top][All Lists]
Advanced

[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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]