[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 18/99: Add more types of constants
From: |
Christopher Allan Webber |
Subject: |
[Guile-commits] 18/99: Add more types of constants |
Date: |
Sun, 10 Oct 2021 21:50:45 -0400 (EDT) |
cwebber pushed a commit to branch compile-to-js-merge
in repository guile.
commit e9d0f97410d3549caab95acea1b706e544e44f8b
Author: Ian Price <ianprice90@googlemail.com>
AuthorDate: Fri Jun 12 18:30:39 2015 +0100
Add more types of constants
---
module/language/js-il/compile-javascript.scm | 23 +++++++++++++++++++++++
module/language/js-il/runtime.js | 26 ++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/module/language/js-il/compile-javascript.scm
b/module/language/js-il/compile-javascript.scm
index 7f814ff..3b13e08 100644
--- a/module/language/js-il/compile-javascript.scm
+++ b/module/language/js-il/compile-javascript.scm
@@ -235,5 +235,28 @@
(make-call
(make-refine *scheme* (make-const "String"))
(list (make-const c)))))
+ ((pair? c)
+ (make-new
+ (make-call
+ (make-refine *scheme* (make-const "Pair"))
+ (list (compile-const (car c))
+ (compile-const (cdr c))))))
+ ((vector? c)
+ (make-new
+ (make-call
+ (make-refine *scheme* (make-const "Vector"))
+ (map compile-const (vector->list c)))))
+ ((char? c)
+ (make-new
+ (make-call
+ (make-refine *scheme* (make-const "Char"))
+ (list (make-const (string c))))))
+ ((keyword? c)
+ (make-new
+ (make-call
+ (make-refine *scheme* (make-const "Keyword"))
+ (list (make-const (symbol->string (keyword->symbol c)))))))
+ ((undefined? c)
+ (make-refine *scheme* (make-const "UNDEFINED")))
(else
(throw 'uncompilable-const c))))
diff --git a/module/language/js-il/runtime.js b/module/language/js-il/runtime.js
index 1e51c6b..6569cbe 100644
--- a/module/language/js-il/runtime.js
+++ b/module/language/js-il/runtime.js
@@ -111,13 +111,39 @@ scheme.Symbol = function(s) {
};
};
+// Keywords
+scheme.Keyword = function(s) {
+ this.name = s;
+ return this;
+};
+
// Vectors
+scheme.Vector = function () {
+ this.array = Array.prototype.slice.call(arguments);
+ return this;
+};
+
+scheme.primitives["vector-ref"] = function (vec, idx) {
+ return vec.array[idx];
+};
+
+scheme.primitives["vector-set!"] = function (vec, idx, obj) {
+ return vec.array[idx] = obj;
+};
+
+scheme.primitives["vector-length"] = function (vec) {
+ return vec.array.length;
+};
// Bytevectors
// Booleans
// Chars
+scheme.Char = function(c) {
+ this.c = c;
+ return this;
+};
// Strings
scheme.String = function(s) {
- [Guile-commits] 60/99: Implement struct built-ins., (continued)
- [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
- [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 <=
- [Guile-commits] 17/99: Implement Optional arguments, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 27/99: values takes multiple arguments, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 28/99: Implement apply correctly, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 38/99: Explicitly test for undefined arguments to handle false values like 0, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 44/99: Update primitives in no-values-primitives, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 35/99: Change local type representation and remove var type, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 42/99: compile-js uses the new cps representation, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 43/99: Handle multiple conts in a function body, Christopher Allan Webber, 2021/10/10
- [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