mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-29 19:30:36 +02:00
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 `@impl' shorthand with `call' + `@implv' for better control over resulting tree-il. * test-suite/tests/ecmascript.test (compiler): Add test for "new Object();" Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
d74e0fed0d
commit
9807d2dced
2 changed files with 11 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue