[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 60/99: Implement struct built-ins.
From: |
Christopher Allan Webber |
Subject: |
[Guile-commits] 60/99: Implement struct built-ins. |
Date: |
Sun, 10 Oct 2021 21:51:01 -0400 (EDT) |
cwebber pushed a commit to branch compile-to-js-merge
in repository guile.
commit ebe9d00153e38f502c6484acc0c24444458b26a6
Author: Ian Price <ianprice90@googlemail.com>
AuthorDate: Wed Aug 2 22:44:27 2017 +0100
Implement struct built-ins.
* module/language/js-il/runtime.js
(struct?): New primitive.
(<applicable-struct-vtable>, record-type-vtable,
set-struct-vtable-name!, make-struct): Implement built-ins.
---
module/language/js-il/runtime.js | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/module/language/js-il/runtime.js b/module/language/js-il/runtime.js
index c6d70cb..51f1c6c 100644
--- a/module/language/js-il/runtime.js
+++ b/module/language/js-il/runtime.js
@@ -443,6 +443,10 @@ scheme.Struct = function (vtable, nfields) {
return this;
};
+scheme.primitives["struct?"] = function (obj) {
+ return coerce_bool(obj instanceof scheme.Struct);
+};
+
scheme.primitives["allocate-struct/immediate"] = function (vtable, nfields) {
return new scheme.Struct(vtable, nfields);
};
@@ -908,3 +912,27 @@ def_guile0("struct-vtable?", function (self, cont, obj) {
var bool = coerce_bool(obj instanceof scheme.Struct && obj.is_vtable);
return cont(bool);
});
+
+var applicable_vtable = scm_make_struct(scm_standard_vtable, [new
scheme.Symbol(vtable_base_layout.s)]);
+applicable_vtable.children_applicable_vtables = true;
+
+def_guile_val("<applicable-struct-vtable>", applicable_vtable);
+
+def_guile_val("record-type-vtable", scm_standard_vtable); // FIXME:
+
+def_guile0("set-struct-vtable-name!", function (self, cont, val, args) {
+ // FIXME:
+ return cont(scheme.FALSE);
+});
+
+def_guile0("make-struct", function (self, cont, vtable, tailsize) {
+ if (tailsize === 0) {
+ // make-struct/no-tail
+ var args = Array.prototype.slice.call(arguments, 4);
+ return cont(scm_make_struct(vtable, args));
+ } else {
+ console.log("make-struct with tail", arguments);
+ not_implemented_yet();
+ }
+});
+
- [Guile-commits] 33/99: Change program type representation, (continued)
- [Guile-commits] 33/99: Change program type representation, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 31/99: Different types for Continuation and Variable identifiers, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 29/99: Use scheme.frame.Prompt objects for prompts on dynstack, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 30/99: Implement fluid primitives, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 36/99: Handle more identifier characters, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 47/99: Add some primitives to runtime.js, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 50/99: Add more variables to no-values-primitives, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 55/99: Implement immediate version of vector primitives., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 62/99: scm_struct_init skips hidden fields., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 59/99: Implement built-in string procedures., Christopher Allan Webber, 2021/10/10
- [Guile-commits] 60/99: Implement struct built-ins.,
Christopher Allan Webber <=
- [Guile-commits] 70/99: Add `guild jslink' to bundle JS programs, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 75/99: scheme.HashTable uses ES6 Map objects, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 41/99: Fix build of (language cps compile-js), Christopher Allan Webber, 2021/10/10
- [Guile-commits] 45/99: Add #:js-inline? and #:js-flatten? debugging options, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 54/99: Implement structs in runtime.js, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 25/99: Implement call-with-values, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 52/99: Add macro type in runtime.js, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 51/99: Implement cached-module-box, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 48/99: Rebuild nested scopes for js continuations, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 18/99: Add more types of constants, Christopher Allan Webber, 2021/10/10