guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 67/99: Make child structs applicable.


From: Christopher Allan Webber
Subject: [Guile-commits] 67/99: Make child structs applicable.
Date: Sun, 10 Oct 2021 21:51:04 -0400 (EDT)

cwebber pushed a commit to branch compile-to-js-merge
in repository guile.

commit 70c25b1290cc1bf5f07fe432272e7b550f205201
Author: Ian Price <ianprice90@googlemail.com>
AuthorDate: Thu Aug 3 00:22:03 2017 +0100

    Make child structs applicable.
    
    * module/language/js-il/runtime.js (scheme.Struct): When certain flags
      are set, child structs should be marked as applicable.
---
 module/language/js-il/runtime.js | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/module/language/js-il/runtime.js b/module/language/js-il/runtime.js
index 72e0a0a..8e0480e 100644
--- a/module/language/js-il/runtime.js
+++ b/module/language/js-il/runtime.js
@@ -439,6 +439,22 @@ scheme.Struct = function (vtable, nfields) {
     this.vtable = vtable;
     this.fields = [];
 
+    if (this.vtable && 
this.vtable.hasOwnProperty('children_applicable_vtables')) {
+        this.is_vtable = true;
+        this.children_applicable = true;
+    }
+
+    if (this.vtable && this.vtable.hasOwnProperty('children_applicable')) {
+        this.is_applicable = true;
+        this.fun = function (self, cont) {
+            var scm_applicable_struct_index_procedure = 0;
+            var clos = self.fields[scm_applicable_struct_index_procedure];
+            return clos.fun(clos, cont);
+        };
+    } else {
+        this.fun = function () { throw "not applicable"; };
+    }
+
     // FIXME: worth doing?
     for(var i = 0; i < nfields; i++){
         this.fields[i]=scheme.UNDEFINED;



reply via email to

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