guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 49/99: Compile Syntax Objects to Javascript


From: Christopher Allan Webber
Subject: [Guile-commits] 49/99: Compile Syntax Objects to Javascript
Date: Sun, 10 Oct 2021 21:50:57 -0400 (EDT)

cwebber pushed a commit to branch compile-to-js-merge
in repository guile.

commit 536d94feb3288c22517e565f45059ec5ea824cc8
Author: Ian Price <ianprice90@googlemail.com>
AuthorDate: Tue Jun 20 22:50:06 2017 +0100

    Compile Syntax Objects to Javascript
    
    * module/language/js-il/compile-javascript.scm (compile-const):
      Handle the new syntax object struct.
    * module/language/js-il/runtime.js(scheme.Syntax): Add Syntax Object type
---
 module/language/js-il/compile-javascript.scm | 8 ++++++++
 module/language/js-il/runtime.js             | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/module/language/js-il/compile-javascript.scm 
b/module/language/js-il/compile-javascript.scm
index ed76441..4ac7820 100644
--- a/module/language/js-il/compile-javascript.scm
+++ b/module/language/js-il/compile-javascript.scm
@@ -6,6 +6,7 @@
   #:use-module (language javascript simplify)
   #:use-module (language js-il inlining)
   #:use-module (system foreign)
+  #:use-module (system syntax internal)
   #:export (compile-javascript))
 
 (define (undefined? obj)
@@ -355,5 +356,12 @@
            (list (make-const (symbol->string (keyword->symbol c)))))))
         ((undefined? c)
          (make-refine *scheme* (make-const "UNDEFINED")))
+        ((syntax? c)
+         (make-call
+          (make-refine *scheme* (make-const "Syntax"))
+          (map compile-const
+               (list (syntax-expression c)
+                     (syntax-wrap c)
+                     (syntax-module c)))))
         (else
          (throw 'uncompilable-const c))))
diff --git a/module/language/js-il/runtime.js b/module/language/js-il/runtime.js
index 6ef6ff1..85669da 100644
--- a/module/language/js-il/runtime.js
+++ b/module/language/js-il/runtime.js
@@ -291,6 +291,14 @@ scheme.primitives["builtin-ref"] = function (idx) {
     return scheme.builtins[idx];
 };
 
+// Syntax Objects
+scheme.Syntax = function (expr, wrap, module) {
+    this.expr = expr;
+    this.wrap = wrap;
+    this.module = module;
+    return this;
+};
+
 // Modules
 scheme.primitives["define!"] = function(sym, obj) {
     var b = new scheme.Box(obj);



reply via email to

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