[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 01/01: Fix tree-il code generation for ECMAscript `new'
From: |
Ludovic Courtès |
Subject: |
[Guile-commits] 01/01: Fix tree-il code generation for ECMAscript `new' expression. |
Date: |
Tue, 25 Oct 2016 21:40:22 +0000 (UTC) |
civodul pushed a commit to branch master
in repository guile.
commit 9807d2dced107aecfb85502e9264e63f74214499
Author: Julian Graham <address@hidden>
Date: Tue Sep 13 08:39:43 2016 -0400
Fix tree-il code generation for ECMAscript `new' expression.
The compiler was producing `((toplevel foo))' instead of `(toplevel foo)'.
Changed to use `call' form with target type and spliced constructor
arguments.
* module/language/ecmascript/compile-tree-il.scm (comp): Replace
address@hidden'
shorthand with `call' + address@hidden' for better control over resulting
tree-il.
* test-suite/tests/ecmascript.test (compiler): Add test for "new Object();"
Signed-off-by: Ludovic Courtès <address@hidden>
---
module/language/ecmascript/compile-tree-il.scm | 8 ++++----
test-suite/tests/ecmascript.test | 8 +++++++-
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/module/language/ecmascript/compile-tree-il.scm
b/module/language/ecmascript/compile-tree-il.scm
index a9ac3e0..d61f712 100644
--- a/module/language/ecmascript/compile-tree-il.scm
+++ b/module/language/ecmascript/compile-tree-il.scm
@@ -1,6 +1,6 @@
;;; ECMAScript for Guile
-;; Copyright (C) 2009, 2011 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2011, 2016 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@@ -437,9 +437,9 @@
((^= ,what ,val)
(comp `(= ,what (^ ,what ,val)) e))
((new ,what ,args)
- (@impl new
- (map (lambda (x) (comp x e))
- (cons what args))))
+ `(call ,(@implv new)
+ ,(comp what e)
+ ,@(map (lambda (x) (comp x e)) args)))
((delete (pref ,obj ,prop))
(@impl pdel
(comp obj e)
diff --git a/test-suite/tests/ecmascript.test b/test-suite/tests/ecmascript.test
index 96b1d66..9f2731e 100644
--- a/test-suite/tests/ecmascript.test
+++ b/test-suite/tests/ecmascript.test
@@ -1,6 +1,6 @@
;;;; ecmascript.test --- ECMAScript. -*- mode: scheme; coding: utf-8; -*-
;;;;
-;;;; Copyright (C) 2010, 2011, 2013 Free Software Foundation, Inc.
+;;;; Copyright (C) 2010, 2011, 2013, 2016 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@@ -83,6 +83,12 @@
(ecompile "\"hello\";" "hello")
(ecompile "var test = { bar: 1 };")
+ (pass-if "new Object;"
+ (not (not
+ (compile (call-with-input-string "new Object;" read-ecmascript)
+ #:from 'ecmascript
+ #:to 'tree-il)))) ; Can't reference `Object' as value here
+
;; FIXME: Broken!
;; (ecompile "[1,2,3,4].map(function(x) { return x * x; });"
;; '(1 4 9 16))