[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 12/99: Compile string constants
From: |
Christopher Allan Webber |
Subject: |
[Guile-commits] 12/99: Compile string constants |
Date: |
Sun, 10 Oct 2021 21:50:43 -0400 (EDT) |
cwebber pushed a commit to branch compile-to-js-merge
in repository guile.
commit a4003003e2766805b28c8187b6939d4206b2fe0b
Author: Ian Price <ianprice90@googlemail.com>
AuthorDate: Sun Jun 7 21:48:02 2015 +0100
Compile string constants
---
module/language/javascript.scm | 3 +++
module/language/js-il/compile-javascript.scm | 5 +++++
module/language/js-il/runtime.js | 4 ++++
3 files changed, 12 insertions(+)
diff --git a/module/language/javascript.scm b/module/language/javascript.scm
index 0a30db3..37b7b28 100644
--- a/module/language/javascript.scm
+++ b/module/language/javascript.scm
@@ -167,6 +167,9 @@
(define (print-const c port)
(cond ((string? c)
+ ;; FIXME:
+ ;; Scheme strings and JS Strings are different, and not just in
+ ;; terms of mutability
(write c port))
((number? c)
(write c port))
diff --git a/module/language/js-il/compile-javascript.scm
b/module/language/js-il/compile-javascript.scm
index 676d448..3d50bcc 100644
--- a/module/language/js-il/compile-javascript.scm
+++ b/module/language/js-il/compile-javascript.scm
@@ -112,5 +112,10 @@
(make-call
(make-refine *scheme* (make-const "list"))
(map compile-const c)))
+ ((string? c)
+ (make-new
+ (make-call
+ (make-refine *scheme* (make-const "String"))
+ (list (make-const c)))))
(else
(throw 'uncompilable-const c))))
diff --git a/module/language/js-il/runtime.js b/module/language/js-il/runtime.js
index 502c61b..ac2d4e3 100644
--- a/module/language/js-il/runtime.js
+++ b/module/language/js-il/runtime.js
@@ -118,6 +118,10 @@ scheme.Symbol = function(s) {
// Chars
// Strings
+scheme.String = function(s) {
+ this.s = s;
+ return this;
+};
// Closures
scheme.Closure = function(f, size) {
- [Guile-commits] 03/99: Remove jscall type, (continued)
- [Guile-commits] 03/99: Remove jscall type, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 04/99: fix makefile, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 05/99: separate js-il functions into actual functions and those for continuations, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 06/99: Get rid of comments and dead branches, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 07/99: Simple inlining of immediate calls, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 08/99: conditional->branch, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 10/99: fix makefile, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 11/99: Compile rest args, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 16/99: Remove superfluous space, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 20/99: Implement keyword argument parsing, Christopher Allan Webber, 2021/10/10
- [Guile-commits] 12/99: Compile string constants,
Christopher Allan Webber <=
- [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