[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 30/99: Implement fluid primitives
From: |
Christopher Allan Webber |
Subject: |
[Guile-commits] 30/99: Implement fluid primitives |
Date: |
Sun, 10 Oct 2021 21:50:49 -0400 (EDT) |
cwebber pushed a commit to branch compile-to-js-merge
in repository guile.
commit 78cacbe450e2f46da62c5b95d725292acdbf71b3
Author: Ian Price <ianprice90@googlemail.com>
AuthorDate: Wed Jun 17 20:32:10 2015 +0100
Implement fluid primitives
---
module/language/js-il/runtime.js | 34 +++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/module/language/js-il/runtime.js b/module/language/js-il/runtime.js
index ad83fa1..4a4c542 100644
--- a/module/language/js-il/runtime.js
+++ b/module/language/js-il/runtime.js
@@ -370,9 +370,33 @@ scheme.primitives["eqv?"] = function(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;
+scheme.Fluid = function (x) {
+ this.value = x;
+ return this;
+};
+
+scheme.primitives["pop-fluid"] = function () {
+ var frame = scheme.dynstack.shift();
+ if (frame instanceof scheme.frame.Fluid) {
+ frame.fluid.value = frame.fluid.old_value;
+ return;
+ } else {
+ throw "not a frame";
+ };
+};
+
+scheme.primitives["push-fluid"] = function (fluid, new_value) {
+ var old_value = fluid.value;
+ fluid.value = new_value;
+ var frame = new scheme.frame.Fluid(fluid, old_value);
+ scheme.dynstack.unshift(frame);
+ return;
+};
+
+scheme.primitives["fluid-ref"] = function (fluid) {
+ // TODO: check fluid type
+ return fluid.value;
+};
// Variables
scheme.primitives["variable?"] = not_implemented_yet;
@@ -415,3 +439,7 @@ scheme.frame.Prompt = function(tag, escape_only, handler){
this.handler = handler;
};
+scheme.frame.Fluid = function(fluid, old_value) {
+ this.fluid = fluid;
+ this.old_value = old_value;
+};
- [Guile-commits] 13/99: Mangle js identifiers, (continued)
- [Guile-commits] 13/99: Mangle js identifiers, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 15/99: Handle case-lambda via a jump table, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 19/99: Simplify output Javascript, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 21/99: Primitives should return Scheme Booleans, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 23/99: Compile cps $prompt form to javascript, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 26/99: abort-to-prompt takes multiple arguments, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 34/99: Change function type representation, Christopher Allan Webber, 2021/10/10
- [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 <=
- [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, 2021/10/10
- [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