guile-commits
[Top][All Lists]
Advanced

[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) {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]