[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 72/99: Implement basic `equal?' implementation
From: |
Christopher Allan Webber |
Subject: |
[Guile-commits] 72/99: Implement basic `equal?' implementation |
Date: |
Sun, 10 Oct 2021 21:51:06 -0400 (EDT) |
cwebber pushed a commit to branch compile-to-js-merge
in repository guile.
commit 3f9bc2dbb00102b17488afaa353083e36c230940
Author: Ian Price <ianprice90@googlemail.com>
AuthorDate: Mon Aug 14 16:26:39 2017 +0100
Implement basic `equal?' implementation
* module/language/js-il/runtime.js (equal?): Remove primitive.
Implement as builtin procedure. This version Only handles pairs.
---
module/language/js-il/runtime.js | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/module/language/js-il/runtime.js b/module/language/js-il/runtime.js
index c9328a6..34dd3a6 100644
--- a/module/language/js-il/runtime.js
+++ b/module/language/js-il/runtime.js
@@ -496,8 +496,6 @@ scheme.primitives["eqv?"] = function(x, y) {
return coerce_bool(x === y);
};
-scheme.primitives["equal?"] = not_implemented_yet;
-
// Fluids
scheme.Fluid = function (x) {
this.value = x;
@@ -761,6 +759,24 @@ def_guile0("append", function (self, cont, l1, l2) {
return cont(l);
});
+function scm_equal(x,y) {
+ if (x instanceof scheme.Pair) {
+ if (y instanceof scheme.Pair) {
+ return (scm_equal(x.car,y.car) && scm_equal(x.cdr,y.cdr));
+ } else {
+ return false;
+ }
+ } else if (y instanceof scheme.Pair) {
+ return false;
+ } else {
+ return (x === y);
+ }
+}
+
+def_guile0("equal?", function (self, cont, x, y) {
+ return cont(coerce_bool(scm_equal(x,y)));
+});
+
def_guile0("memq", function (self, cont, val, args) {
return cont(scheme.FALSE);
});
- [Guile-commits] 46/99: JS-IL inliner has different count-calls for different clauses, (continued)
- [Guile-commits] 46/99: JS-IL inliner has different count-calls for different clauses, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 40/99: Merge branch 'stable-2.2' into compile-to-js-2017, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 49/99: Compile Syntax Objects to Javascript, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 39/99: Add missing simplify.scm to Makefile, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 37/99: Fixup binop unparsing, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 57/99: Implement built-in syntax procedures., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 56/99: Implement builtin list procedures., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 58/99: Implement built-in symbol procedures., Christopher Allan Webber, 2021/10/10
- [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 <=
- [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, 2021/10/10
- [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