[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 47/99: Add some primitives to runtime.js
From: |
Christopher Allan Webber |
Subject: |
[Guile-commits] 47/99: Add some primitives to runtime.js |
Date: |
Sun, 10 Oct 2021 21:50:56 -0400 (EDT) |
cwebber pushed a commit to branch compile-to-js-merge
in repository guile.
commit 936050c657729b21b8d42045a8e5287d2194e25d
Author: Ian Price <ianprice90@googlemail.com>
AuthorDate: Fri Jun 16 18:11:02 2017 +0100
Add some primitives to runtime.js
* module/language/js-il/runtime.js(add/immediate, sub/immediate,
load-u64, u64-=-scm, handle-interrupts): Add primitives.
---
module/language/js-il/runtime.js | 44 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/module/language/js-il/runtime.js b/module/language/js-il/runtime.js
index 4a4c542..6ef6ff1 100644
--- a/module/language/js-il/runtime.js
+++ b/module/language/js-il/runtime.js
@@ -33,6 +33,10 @@ scheme.primitives.add1 = function (x) {
return x + 1;
};
+scheme.primitives["add/immediate"] = function (x, y) {
+ return x + y;
+};
+
scheme.primitives.sub = function (x, y) {
return x - y;
};
@@ -41,6 +45,10 @@ scheme.primitives.sub1 = function (x) {
return x - 1;
};
+scheme.primitives["sub/immediate"] = function (x, y) {
+ return x - y;
+};
+
scheme.primitives.mul = function (x, y) {
return x * y;
};
@@ -73,6 +81,32 @@ scheme.primitives.quo = not_implemented_yet;
scheme.primitives.rem = not_implemented_yet;
scheme.primitives.mod = not_implemented_yet;
+// Unboxed Numbers
+scheme.primitives["load-u64"] = function(x) {
+ return x;
+};
+
+scheme.primitives["u64-=-scm"] = function(x, y) {
+ // i.e. br-if-u64-=-scm
+ return coerce_bool(x === y);
+};
+
+scheme.primitives["u64-<=-scm"] = function(x, y) {
+ return coerce_bool(x <= y);
+};
+
+scheme.primitives["u64-<-scm"] = function(x, y) {
+ return coerce_bool(x < y);
+};
+
+scheme.primitives["u64->-scm"] = function(x, y) {
+ return coerce_bool(x > y);
+};
+
+scheme.primitives["u64->=-scm"] = function(x, y) {
+ return coerce_bool(x >= y);
+};
+
// Boxes
scheme.Box = function (x) {
this.x = x;
@@ -259,7 +293,9 @@ scheme.primitives["builtin-ref"] = function (idx) {
// Modules
scheme.primitives["define!"] = function(sym, obj) {
- scheme.env[sym.name] = new scheme.Box(obj);
+ var b = new scheme.Box(obj);
+ scheme.env[sym.name] = b;
+ return b;
};
scheme.primitives["cache-current-module!"] = function (module, scope) {
@@ -430,6 +466,12 @@ var find_prompt = function(prompt) {
// FIXME: should error
return undefined;
};
+
+scheme.primitives["handle-interrupts"] = function () {
+ // TODO: implement
+ return;
+};
+
// Dynstack frames
scheme.frame = {};
- [Guile-commits] 19/99: Simplify output Javascript, (continued)
- [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, 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 <=
- [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
- [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