Commit e9ab4bb6 authored by Vladimir Sedach's avatar Vladimir Sedach

Fixed bug with quoted symbol arguments to CREATE (thanks to Russell Sim for...

Fixed bug with quoted symbol arguments to CREATE (thanks to Russell Sim for the bug report and patch)
parent c5c78a53
......@@ -19,3 +19,4 @@ William Halliburton
Scott Bell
Bart Botta
Boris Smilga
Russell Sim
......@@ -51,13 +51,20 @@
(define-expression-operator create (&rest arrows)
`(ps-js:object
,@(loop for (key val-expr) on arrows by #'cddr collecting
(progn
(assert (or (stringp key) (numberp key) (symbolp key))
()
"Slot key ~s is not one of symbol, string or number."
key)
(cons (aif (and (symbolp key) (reserved-symbol? key)) it key)
(compile-expression val-expr))))))
(cons (acond ((and (symbolp key) (reserved-symbol? key))
it)
((or (stringp key) (numberp key) (symbolp key))
key)
((and (consp key)
(eq 'quote (first key))
(symbolp (second key))
(null (third key)))
(symbol-to-js-string (second key)))
(t
(error
"Slot key ~s is not one of symbol, string or number."
key)))
(compile-expression val-expr)))))
(define-expression-operator %js-getprop (obj slot)
(let ((expanded-slot (ps-macroexpand slot))
......
......@@ -119,6 +119,10 @@
(+ a b c))
"this.a + this.b + this.c;")
(test-ps-js object-literal-quoted-symbols
(create 'test "bang" 'symbol-saved-my-life "parenscript")
"({ 'test' : 'bang', 'symbolSavedMyLife' : 'parenscript' });")
(test-ps-js regular-expression-literals-1
(regex "foobar")
"/foobar/;")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment