Merge loops/js into architecture: var hoisting + ASI + matchAll on top of regex engine / TDZ scaffolding
Combined arch's regex platform dispatch (runtime.sx) with loops/js's var-hoisting transpiler (transpile.sx) and matchAll string method. Plan checkboxes updated to reflect both done. Conflicts: lib/js/runtime.sx, lib/js/transpile.sx, lib/js/test.sh, plans/js-on-sx.md.
This commit is contained in:
251
lib/js/lexer.sx
251
lib/js/lexer.sx
@@ -29,6 +29,16 @@
|
||||
(and (>= c "a") (<= c "f"))
|
||||
(and (>= c "A") (<= c "F")))))
|
||||
|
||||
(define
|
||||
js-hex-value
|
||||
(fn
|
||||
(c)
|
||||
(cond
|
||||
((and (>= c "0") (<= c "9")) (- (char-code c) 48))
|
||||
((and (>= c "a") (<= c "f")) (- (char-code c) 87))
|
||||
((and (>= c "A") (<= c "F")) (- (char-code c) 55))
|
||||
(else 0))))
|
||||
|
||||
(define
|
||||
js-letter?
|
||||
(fn (c) (or (and (>= c "a") (<= c "z")) (and (>= c "A") (<= c "Z")))))
|
||||
@@ -37,9 +47,9 @@
|
||||
|
||||
(define js-ident-char? (fn (c) (or (js-ident-start? c) (js-digit? c))))
|
||||
|
||||
;; ── Reserved words ────────────────────────────────────────────────
|
||||
(define js-ws? (fn (c) (or (= c " ") (= c "\t") (= c "\n") (= c "\r"))))
|
||||
|
||||
;; ── Reserved words ────────────────────────────────────────────────
|
||||
(define
|
||||
js-keywords
|
||||
(list
|
||||
@@ -86,15 +96,18 @@
|
||||
"await"
|
||||
"of"))
|
||||
|
||||
;; ── Main tokenizer ────────────────────────────────────────────────
|
||||
(define js-keyword? (fn (word) (contains? js-keywords word)))
|
||||
|
||||
;; ── Main tokenizer ────────────────────────────────────────────────
|
||||
(define
|
||||
js-tokenize
|
||||
(fn
|
||||
(src)
|
||||
(let
|
||||
((tokens (list)) (pos 0) (src-len (len src)))
|
||||
((tokens (list))
|
||||
(pos 0)
|
||||
(src-len (len src))
|
||||
(nl-before false))
|
||||
(define
|
||||
js-peek
|
||||
(fn
|
||||
@@ -109,11 +122,7 @@
|
||||
(let
|
||||
((sl (len s)))
|
||||
(and (<= (+ pos sl) src-len) (= (slice src pos (+ pos sl)) s)))))
|
||||
(define
|
||||
js-emit!
|
||||
(fn
|
||||
(type value start)
|
||||
(append! tokens (js-make-token type value start))))
|
||||
(define js-emit! (fn (type value start) (append! tokens {:nl nl-before :type type :value value :pos start})))
|
||||
(define
|
||||
skip-line-comment!
|
||||
(fn
|
||||
@@ -136,7 +145,13 @@
|
||||
()
|
||||
(cond
|
||||
((>= pos src-len) nil)
|
||||
((js-ws? (cur)) (do (advance! 1) (skip-ws!)))
|
||||
((js-ws? (cur))
|
||||
(do
|
||||
(when
|
||||
(or (= (cur) "\n") (= (cur) "\r"))
|
||||
(set! nl-before true))
|
||||
(advance! 1)
|
||||
(skip-ws!)))
|
||||
((and (= (cur) "/") (< (+ pos 1) src-len) (= (js-peek 1) "/"))
|
||||
(do (advance! 2) (skip-line-comment!) (skip-ws!)))
|
||||
((and (= (cur) "/") (< (+ pos 1) src-len) (= (js-peek 1) "*"))
|
||||
@@ -254,11 +269,55 @@
|
||||
((= ch "b") (append! chars "\\b"))
|
||||
((= ch "f") (append! chars "\\f"))
|
||||
((= ch "v") (append! chars "\\v"))
|
||||
((= ch "u")
|
||||
(if
|
||||
(and
|
||||
(< (+ pos 4) src-len)
|
||||
(js-hex-digit? (js-peek 1))
|
||||
(js-hex-digit? (js-peek 2))
|
||||
(js-hex-digit? (js-peek 3))
|
||||
(js-hex-digit? (js-peek 4)))
|
||||
(do
|
||||
(append!
|
||||
chars
|
||||
(char-from-code
|
||||
(+
|
||||
(*
|
||||
4096
|
||||
(js-hex-value
|
||||
(js-peek 1)))
|
||||
(*
|
||||
256
|
||||
(js-hex-value
|
||||
(js-peek 2)))
|
||||
(*
|
||||
16
|
||||
(js-hex-value
|
||||
(js-peek 3)))
|
||||
(js-hex-value (js-peek 4)))))
|
||||
(advance! 4))
|
||||
(append! chars ch)))
|
||||
((= ch "x")
|
||||
(if
|
||||
(and
|
||||
(< (+ pos 2) src-len)
|
||||
(js-hex-digit? (js-peek 1))
|
||||
(js-hex-digit? (js-peek 2)))
|
||||
(do
|
||||
(append!
|
||||
chars
|
||||
(char-from-code
|
||||
(+
|
||||
(* 16 (js-hex-value (js-peek 1)))
|
||||
(js-hex-value (js-peek 2)))))
|
||||
(advance! 2))
|
||||
(append! chars ch)))
|
||||
(else (append! chars ch)))
|
||||
(advance! 1))))
|
||||
(loop)))
|
||||
((= (cur) quote-char) (advance! 1))
|
||||
(else (do (append! chars (cur)) (advance! 1) (loop))))))
|
||||
(else
|
||||
(do (append! chars (cur)) (advance! 1) (loop))))))
|
||||
(loop)
|
||||
(join "" chars))))
|
||||
(define
|
||||
@@ -289,7 +348,8 @@
|
||||
()
|
||||
(cond
|
||||
((>= pos src-len) nil)
|
||||
((and (= (cur) "}") (= depth 1)) (advance! 1))
|
||||
((and (= (cur) "}") (= depth 1))
|
||||
(advance! 1))
|
||||
((= (cur) "}")
|
||||
(do
|
||||
(append! buf (cur))
|
||||
@@ -325,7 +385,9 @@
|
||||
(advance! 1)))
|
||||
(sloop)))
|
||||
((= (cur) q)
|
||||
(do (append! buf (cur)) (advance! 1)))
|
||||
(do
|
||||
(append! buf (cur))
|
||||
(advance! 1)))
|
||||
(else
|
||||
(do
|
||||
(append! buf (cur))
|
||||
@@ -334,7 +396,10 @@
|
||||
(sloop)
|
||||
(expr-loop))))
|
||||
(else
|
||||
(do (append! buf (cur)) (advance! 1) (expr-loop))))))
|
||||
(do
|
||||
(append! buf (cur))
|
||||
(advance! 1)
|
||||
(expr-loop))))))
|
||||
(expr-loop)
|
||||
(join "" buf))))
|
||||
(define
|
||||
@@ -376,14 +441,17 @@
|
||||
(else (append! chars ch)))
|
||||
(advance! 1))))
|
||||
(loop)))
|
||||
(else (do (append! chars (cur)) (advance! 1) (loop))))))
|
||||
(else
|
||||
(do (append! chars (cur)) (advance! 1) (loop))))))
|
||||
(loop)
|
||||
(flush-chars!)
|
||||
(if
|
||||
(= (len parts) 0)
|
||||
""
|
||||
(if
|
||||
(and (= (len parts) 1) (= (nth (nth parts 0) 0) "str"))
|
||||
(and
|
||||
(= (len parts) 1)
|
||||
(= (nth (nth parts 0) 0) "str"))
|
||||
(nth (nth parts 0) 1)
|
||||
parts)))))
|
||||
(define
|
||||
@@ -399,7 +467,7 @@
|
||||
((ty (dict-get tk "type")) (vv (dict-get tk "value")))
|
||||
(cond
|
||||
((= ty "punct")
|
||||
(and (not (= vv ")")) (not (= vv "]"))))
|
||||
(and (not (= vv ")")) (not (= vv "]")) (not (= vv "}"))))
|
||||
((= ty "op") true)
|
||||
((= ty "keyword")
|
||||
(contains?
|
||||
@@ -453,9 +521,13 @@
|
||||
(append! buf (cur))
|
||||
(advance! 1)
|
||||
(body-loop)))
|
||||
((and (= (cur) "/") (not in-class)) (advance! 1))
|
||||
((and (= (cur) "/") (not in-class))
|
||||
(advance! 1))
|
||||
(else
|
||||
(begin (append! buf (cur)) (advance! 1) (body-loop))))))
|
||||
(begin
|
||||
(append! buf (cur))
|
||||
(advance! 1)
|
||||
(body-loop))))))
|
||||
(body-loop)
|
||||
(let
|
||||
((flags-buf (list)))
|
||||
@@ -470,7 +542,7 @@
|
||||
(advance! 1)
|
||||
(flags-loop)))))
|
||||
(flags-loop)
|
||||
{:pattern (join "" buf) :flags (join "" flags-buf)}))))
|
||||
{:flags (join "" flags-buf) :pattern (join "" buf)}))))
|
||||
(define
|
||||
try-op-4!
|
||||
(fn
|
||||
@@ -510,64 +582,113 @@
|
||||
(fn
|
||||
(start)
|
||||
(cond
|
||||
((at? "==") (do (js-emit! "op" "==" start) (advance! 2) true))
|
||||
((at? "!=") (do (js-emit! "op" "!=" start) (advance! 2) true))
|
||||
((at? "<=") (do (js-emit! "op" "<=" start) (advance! 2) true))
|
||||
((at? ">=") (do (js-emit! "op" ">=" start) (advance! 2) true))
|
||||
((at? "&&") (do (js-emit! "op" "&&" start) (advance! 2) true))
|
||||
((at? "||") (do (js-emit! "op" "||" start) (advance! 2) true))
|
||||
((at? "??") (do (js-emit! "op" "??" start) (advance! 2) true))
|
||||
((at? "=>") (do (js-emit! "op" "=>" start) (advance! 2) true))
|
||||
((at? "**") (do (js-emit! "op" "**" start) (advance! 2) true))
|
||||
((at? "<<") (do (js-emit! "op" "<<" start) (advance! 2) true))
|
||||
((at? ">>") (do (js-emit! "op" ">>" start) (advance! 2) true))
|
||||
((at? "++") (do (js-emit! "op" "++" start) (advance! 2) true))
|
||||
((at? "--") (do (js-emit! "op" "--" start) (advance! 2) true))
|
||||
((at? "+=") (do (js-emit! "op" "+=" start) (advance! 2) true))
|
||||
((at? "-=") (do (js-emit! "op" "-=" start) (advance! 2) true))
|
||||
((at? "*=") (do (js-emit! "op" "*=" start) (advance! 2) true))
|
||||
((at? "/=") (do (js-emit! "op" "/=" start) (advance! 2) true))
|
||||
((at? "%=") (do (js-emit! "op" "%=" start) (advance! 2) true))
|
||||
((at? "&=") (do (js-emit! "op" "&=" start) (advance! 2) true))
|
||||
((at? "|=") (do (js-emit! "op" "|=" start) (advance! 2) true))
|
||||
((at? "^=") (do (js-emit! "op" "^=" start) (advance! 2) true))
|
||||
((at? "?.") (do (js-emit! "op" "?." start) (advance! 2) true))
|
||||
((at? "==")
|
||||
(do (js-emit! "op" "==" start) (advance! 2) true))
|
||||
((at? "!=")
|
||||
(do (js-emit! "op" "!=" start) (advance! 2) true))
|
||||
((at? "<=")
|
||||
(do (js-emit! "op" "<=" start) (advance! 2) true))
|
||||
((at? ">=")
|
||||
(do (js-emit! "op" ">=" start) (advance! 2) true))
|
||||
((at? "&&")
|
||||
(do (js-emit! "op" "&&" start) (advance! 2) true))
|
||||
((at? "||")
|
||||
(do (js-emit! "op" "||" start) (advance! 2) true))
|
||||
((at? "??")
|
||||
(do (js-emit! "op" "??" start) (advance! 2) true))
|
||||
((at? "=>")
|
||||
(do (js-emit! "op" "=>" start) (advance! 2) true))
|
||||
((at? "**")
|
||||
(do (js-emit! "op" "**" start) (advance! 2) true))
|
||||
((at? "<<")
|
||||
(do (js-emit! "op" "<<" start) (advance! 2) true))
|
||||
((at? ">>")
|
||||
(do (js-emit! "op" ">>" start) (advance! 2) true))
|
||||
((at? "++")
|
||||
(do (js-emit! "op" "++" start) (advance! 2) true))
|
||||
((at? "--")
|
||||
(do (js-emit! "op" "--" start) (advance! 2) true))
|
||||
((at? "+=")
|
||||
(do (js-emit! "op" "+=" start) (advance! 2) true))
|
||||
((at? "-=")
|
||||
(do (js-emit! "op" "-=" start) (advance! 2) true))
|
||||
((at? "*=")
|
||||
(do (js-emit! "op" "*=" start) (advance! 2) true))
|
||||
((at? "/=")
|
||||
(do (js-emit! "op" "/=" start) (advance! 2) true))
|
||||
((at? "%=")
|
||||
(do (js-emit! "op" "%=" start) (advance! 2) true))
|
||||
((at? "&=")
|
||||
(do (js-emit! "op" "&=" start) (advance! 2) true))
|
||||
((at? "|=")
|
||||
(do (js-emit! "op" "|=" start) (advance! 2) true))
|
||||
((at? "^=")
|
||||
(do (js-emit! "op" "^=" start) (advance! 2) true))
|
||||
((at? "?.")
|
||||
(do (js-emit! "op" "?." start) (advance! 2) true))
|
||||
(else false))))
|
||||
(define
|
||||
emit-one-op!
|
||||
(fn
|
||||
(ch start)
|
||||
(cond
|
||||
((= ch "(") (do (js-emit! "punct" "(" start) (advance! 1)))
|
||||
((= ch ")") (do (js-emit! "punct" ")" start) (advance! 1)))
|
||||
((= ch "[") (do (js-emit! "punct" "[" start) (advance! 1)))
|
||||
((= ch "]") (do (js-emit! "punct" "]" start) (advance! 1)))
|
||||
((= ch "{") (do (js-emit! "punct" "{" start) (advance! 1)))
|
||||
((= ch "}") (do (js-emit! "punct" "}" start) (advance! 1)))
|
||||
((= ch ",") (do (js-emit! "punct" "," start) (advance! 1)))
|
||||
((= ch ";") (do (js-emit! "punct" ";" start) (advance! 1)))
|
||||
((= ch ":") (do (js-emit! "punct" ":" start) (advance! 1)))
|
||||
((= ch ".") (do (js-emit! "punct" "." start) (advance! 1)))
|
||||
((= ch "?") (do (js-emit! "op" "?" start) (advance! 1)))
|
||||
((= ch "+") (do (js-emit! "op" "+" start) (advance! 1)))
|
||||
((= ch "-") (do (js-emit! "op" "-" start) (advance! 1)))
|
||||
((= ch "*") (do (js-emit! "op" "*" start) (advance! 1)))
|
||||
((= ch "/") (do (js-emit! "op" "/" start) (advance! 1)))
|
||||
((= ch "%") (do (js-emit! "op" "%" start) (advance! 1)))
|
||||
((= ch "=") (do (js-emit! "op" "=" start) (advance! 1)))
|
||||
((= ch "<") (do (js-emit! "op" "<" start) (advance! 1)))
|
||||
((= ch ">") (do (js-emit! "op" ">" start) (advance! 1)))
|
||||
((= ch "!") (do (js-emit! "op" "!" start) (advance! 1)))
|
||||
((= ch "&") (do (js-emit! "op" "&" start) (advance! 1)))
|
||||
((= ch "|") (do (js-emit! "op" "|" start) (advance! 1)))
|
||||
((= ch "^") (do (js-emit! "op" "^" start) (advance! 1)))
|
||||
((= ch "~") (do (js-emit! "op" "~" start) (advance! 1)))
|
||||
((= ch "(")
|
||||
(do (js-emit! "punct" "(" start) (advance! 1)))
|
||||
((= ch ")")
|
||||
(do (js-emit! "punct" ")" start) (advance! 1)))
|
||||
((= ch "[")
|
||||
(do (js-emit! "punct" "[" start) (advance! 1)))
|
||||
((= ch "]")
|
||||
(do (js-emit! "punct" "]" start) (advance! 1)))
|
||||
((= ch "{")
|
||||
(do (js-emit! "punct" "{" start) (advance! 1)))
|
||||
((= ch "}")
|
||||
(do (js-emit! "punct" "}" start) (advance! 1)))
|
||||
((= ch ",")
|
||||
(do (js-emit! "punct" "," start) (advance! 1)))
|
||||
((= ch ";")
|
||||
(do (js-emit! "punct" ";" start) (advance! 1)))
|
||||
((= ch ":")
|
||||
(do (js-emit! "punct" ":" start) (advance! 1)))
|
||||
((= ch ".")
|
||||
(do (js-emit! "punct" "." start) (advance! 1)))
|
||||
((= ch "?")
|
||||
(do (js-emit! "op" "?" start) (advance! 1)))
|
||||
((= ch "+")
|
||||
(do (js-emit! "op" "+" start) (advance! 1)))
|
||||
((= ch "-")
|
||||
(do (js-emit! "op" "-" start) (advance! 1)))
|
||||
((= ch "*")
|
||||
(do (js-emit! "op" "*" start) (advance! 1)))
|
||||
((= ch "/")
|
||||
(do (js-emit! "op" "/" start) (advance! 1)))
|
||||
((= ch "%")
|
||||
(do (js-emit! "op" "%" start) (advance! 1)))
|
||||
((= ch "=")
|
||||
(do (js-emit! "op" "=" start) (advance! 1)))
|
||||
((= ch "<")
|
||||
(do (js-emit! "op" "<" start) (advance! 1)))
|
||||
((= ch ">")
|
||||
(do (js-emit! "op" ">" start) (advance! 1)))
|
||||
((= ch "!")
|
||||
(do (js-emit! "op" "!" start) (advance! 1)))
|
||||
((= ch "&")
|
||||
(do (js-emit! "op" "&" start) (advance! 1)))
|
||||
((= ch "|")
|
||||
(do (js-emit! "op" "|" start) (advance! 1)))
|
||||
((= ch "^")
|
||||
(do (js-emit! "op" "^" start) (advance! 1)))
|
||||
((= ch "~")
|
||||
(do (js-emit! "op" "~" start) (advance! 1)))
|
||||
((= ch "\\")
|
||||
(error "Unexpected char '\\' in source"))
|
||||
(else (advance! 1)))))
|
||||
(define
|
||||
scan!
|
||||
(fn
|
||||
()
|
||||
(do
|
||||
(set! nl-before false)
|
||||
(skip-ws!)
|
||||
(when
|
||||
(< pos src-len)
|
||||
|
||||
253
lib/js/parser.sx
253
lib/js/parser.sx
@@ -153,6 +153,32 @@
|
||||
(do (jp-advance! st) (list (quote js-ident) "this")))
|
||||
((and (= (get t :type) "keyword") (= (get t :value) "new"))
|
||||
(do (jp-advance! st) (jp-parse-new-expr st)))
|
||||
((and (= (get t :type) "keyword") (= (get t :value) "function"))
|
||||
(do
|
||||
(jp-advance! st)
|
||||
(let
|
||||
((nm
|
||||
(if
|
||||
(= (get (jp-peek st) :type) "ident")
|
||||
(let ((n (get (jp-peek st) :value))) (do (jp-advance! st) n))
|
||||
nil)))
|
||||
(let
|
||||
((params (jp-parse-param-list st)))
|
||||
(let
|
||||
((body (jp-parse-fn-body st)))
|
||||
(list (quote js-funcexpr) nm params body))))))
|
||||
((and (= (get t :type) "keyword") (= (get t :value) "true"))
|
||||
(do (jp-advance! st) (list (quote js-bool) true)))
|
||||
((and (= (get t :type) "keyword") (= (get t :value) "false"))
|
||||
(do (jp-advance! st) (list (quote js-bool) false)))
|
||||
((and (= (get t :type) "keyword") (= (get t :value) "null"))
|
||||
(do (jp-advance! st) (list (quote js-null))))
|
||||
((and (= (get t :type) "keyword") (= (get t :value) "undefined"))
|
||||
(do (jp-advance! st) (list (quote js-undef))))
|
||||
((= (get t :type) "number")
|
||||
(do (jp-advance! st) (list (quote js-num) (get t :value))))
|
||||
((= (get t :type) "string")
|
||||
(do (jp-advance! st) (list (quote js-str) (get t :value))))
|
||||
((and (= (get t :type) "punct") (= (get t :value) "("))
|
||||
(jp-parse-paren-or-arrow st))
|
||||
(else
|
||||
@@ -211,7 +237,7 @@
|
||||
(let
|
||||
((params (jp-parse-param-list st)))
|
||||
(let
|
||||
((body (jp-parse-block st)))
|
||||
((body (jp-parse-fn-body st)))
|
||||
(list (quote js-funcexpr-async) nm params body))))))
|
||||
((= (get t :type) "ident")
|
||||
(do
|
||||
@@ -363,7 +389,7 @@
|
||||
(let
|
||||
((params (jp-parse-param-list st)))
|
||||
(let
|
||||
((body (jp-parse-block st)))
|
||||
((body (jp-parse-fn-body st)))
|
||||
(list (quote js-funcexpr) nm params body))))))
|
||||
((= (get t :type) "ident")
|
||||
(do
|
||||
@@ -418,16 +444,51 @@
|
||||
(dict-set! st :idx saved)
|
||||
(jp-advance! st)
|
||||
(let
|
||||
((e (jp-parse-assignment st)))
|
||||
((e (jp-parse-comma-seq st)))
|
||||
(jp-expect! st "punct" ")")
|
||||
e)))
|
||||
(jp-paren-wrap e))))
|
||||
(do
|
||||
(dict-set! st :idx saved)
|
||||
(jp-advance! st)
|
||||
(let
|
||||
((e (jp-parse-assignment st)))
|
||||
((e (jp-parse-comma-seq st)))
|
||||
(jp-expect! st "punct" ")")
|
||||
e)))))))
|
||||
(jp-paren-wrap e))))))))
|
||||
|
||||
(define
|
||||
jp-paren-wrap
|
||||
(fn
|
||||
(e)
|
||||
(cond
|
||||
((and (list? e) (= (first e) (quote js-unop)))
|
||||
(list (quote js-paren) e))
|
||||
(else e))))
|
||||
|
||||
(define
|
||||
jp-parse-comma-seq
|
||||
(fn
|
||||
(st)
|
||||
(let
|
||||
((first-expr (jp-parse-assignment st)))
|
||||
(if
|
||||
(jp-at? st "punct" ",")
|
||||
(jp-parse-comma-seq-rest st (list first-expr))
|
||||
first-expr))))
|
||||
|
||||
(define
|
||||
jp-parse-comma-seq-rest
|
||||
(fn
|
||||
(st acc)
|
||||
(do
|
||||
(jp-advance! st)
|
||||
(let
|
||||
((next-expr (jp-parse-assignment st)))
|
||||
(let
|
||||
((acc2 (append acc (list next-expr))))
|
||||
(if
|
||||
(jp-at? st "punct" ",")
|
||||
(jp-parse-comma-seq-rest st acc2)
|
||||
(cons (quote js-comma) (list acc2))))))))
|
||||
|
||||
(define
|
||||
jp-collect-params
|
||||
@@ -485,6 +546,11 @@
|
||||
(st elems)
|
||||
(cond
|
||||
((jp-at? st "punct" "]") nil)
|
||||
((jp-at? st "punct" ",")
|
||||
(begin
|
||||
(append! elems (list (quote js-undef)))
|
||||
(jp-advance! st)
|
||||
(jp-array-loop st elems)))
|
||||
(else
|
||||
(begin
|
||||
(cond
|
||||
@@ -558,6 +624,20 @@
|
||||
(jp-advance! st)
|
||||
(jp-expect! st "punct" ":")
|
||||
(append! kvs {:value (jp-parse-assignment st) :key (get t :value)})))
|
||||
((and (= (get t :type) "punct") (= (get t :value) "["))
|
||||
(do
|
||||
(jp-advance! st)
|
||||
(let
|
||||
((key-expr (jp-parse-assignment st)))
|
||||
(jp-expect! st "punct" "]")
|
||||
(jp-expect! st "punct" ":")
|
||||
(append!
|
||||
kvs
|
||||
{:value (jp-parse-assignment st) :computed-key key-expr :key ""}))))
|
||||
((and (= (get t :type) "punct") (= (get t :value) "..."))
|
||||
(do
|
||||
(jp-advance! st)
|
||||
(append! kvs {:spread (jp-parse-assignment st)})))
|
||||
(else (error (str "Unexpected in object: " (get t :type))))))))
|
||||
|
||||
(define
|
||||
@@ -629,7 +709,7 @@
|
||||
st
|
||||
(list (quote js-optchain-member) left (get t :value))))
|
||||
(error "expected ident, [ or ( after ?.")))))))
|
||||
((or (jp-at? st "op" "++") (jp-at? st "op" "--"))
|
||||
((and (or (jp-at? st "op" "++") (jp-at? st "op" "--")) (not (jp-token-nl? st)))
|
||||
(let
|
||||
((op (get (jp-peek st) :value)))
|
||||
(jp-advance! st)
|
||||
@@ -682,6 +762,12 @@
|
||||
(cond
|
||||
((< prec 0) left)
|
||||
((< prec min-prec) left)
|
||||
((and (= op "**") (list? left) (= (first left) (quote js-unop)))
|
||||
(error
|
||||
(str
|
||||
"SyntaxError: Unary operator '"
|
||||
(nth left 1)
|
||||
"' used immediately before exponentiation expression")))
|
||||
(else
|
||||
(do
|
||||
(jp-advance! st)
|
||||
@@ -835,6 +921,12 @@
|
||||
jp-eat-semi
|
||||
(fn (st) (if (jp-at? st "punct" ";") (do (jp-advance! st) nil) nil)))
|
||||
|
||||
(define
|
||||
jp-token-nl?
|
||||
(fn
|
||||
(st)
|
||||
(let ((tok (jp-peek st))) (if tok (= (get tok :nl) true) false))))
|
||||
|
||||
(define
|
||||
jp-parse-vardecl
|
||||
(fn
|
||||
@@ -1052,15 +1144,63 @@
|
||||
((c (jp-parse-assignment st)))
|
||||
(do
|
||||
(jp-expect! st "punct" ")")
|
||||
(jp-disallow-decl-stmt! st "if")
|
||||
(let
|
||||
((t (jp-parse-stmt st)))
|
||||
(if
|
||||
(jp-at? st "keyword" "else")
|
||||
(do
|
||||
(jp-advance! st)
|
||||
(jp-disallow-decl-stmt! st "else")
|
||||
(list (quote js-if) c t (jp-parse-stmt st)))
|
||||
(list (quote js-if) c t nil))))))))
|
||||
|
||||
(define
|
||||
jp-disallow-decl-stmt!
|
||||
(fn
|
||||
(st context)
|
||||
(let
|
||||
((t (jp-peek st)))
|
||||
(cond
|
||||
((and (= (get t :type) "keyword")
|
||||
(or (= (get t :value) "let")
|
||||
(= (get t :value) "const")
|
||||
(= (get t :value) "function")
|
||||
(= (get t :value) "class")))
|
||||
(cond
|
||||
((and (= (get t :value) "let")
|
||||
(or (= (get (jp-peek-at st 1) :type) "ident")
|
||||
(and (= (get (jp-peek-at st 1) :type) "punct")
|
||||
(or (= (get (jp-peek-at st 1) :value) "[")
|
||||
(= (get (jp-peek-at st 1) :value) "{")))))
|
||||
(error
|
||||
(str
|
||||
"SyntaxError: Lexical declaration cannot appear in single-statement context: "
|
||||
context)))
|
||||
((or (= (get t :value) "const")
|
||||
(= (get t :value) "function")
|
||||
(= (get t :value) "class"))
|
||||
(error
|
||||
(str
|
||||
"SyntaxError: "
|
||||
(get t :value)
|
||||
" declaration cannot appear in single-statement context: "
|
||||
context)))
|
||||
(else nil)))
|
||||
(else nil)))))
|
||||
|
||||
(define
|
||||
jp-bump!
|
||||
(fn
|
||||
(st key)
|
||||
(dict-set! st key (+ (get st key) 1))))
|
||||
|
||||
(define
|
||||
jp-decr!
|
||||
(fn
|
||||
(st key)
|
||||
(dict-set! st key (- (get st key) 1))))
|
||||
|
||||
(define
|
||||
jp-parse-while-stmt
|
||||
(fn
|
||||
@@ -1072,7 +1212,11 @@
|
||||
((c (jp-parse-assignment st)))
|
||||
(do
|
||||
(jp-expect! st "punct" ")")
|
||||
(let ((body (jp-parse-stmt st))) (list (quote js-while) c body)))))))
|
||||
(jp-disallow-decl-stmt! st "while")
|
||||
(jp-bump! st :loop-depth)
|
||||
(let ((body (jp-parse-stmt st)))
|
||||
(jp-decr! st :loop-depth)
|
||||
(list (quote js-while) c body)))))))
|
||||
|
||||
(define
|
||||
jp-parse-do-while-stmt
|
||||
@@ -1080,8 +1224,11 @@
|
||||
(st)
|
||||
(do
|
||||
(jp-advance! st)
|
||||
(jp-disallow-decl-stmt! st "do")
|
||||
(jp-bump! st :loop-depth)
|
||||
(let
|
||||
((body (jp-parse-stmt st)))
|
||||
(jp-decr! st :loop-depth)
|
||||
(do
|
||||
(if
|
||||
(jp-at? st "keyword" "while")
|
||||
@@ -1126,8 +1273,11 @@
|
||||
(let
|
||||
((iter (jp-parse-assignment st)))
|
||||
(jp-expect! st "punct" ")")
|
||||
(jp-disallow-decl-stmt! st "for-of/in")
|
||||
(jp-bump! st :loop-depth)
|
||||
(let
|
||||
((body (jp-parse-stmt st)))
|
||||
(jp-decr! st :loop-depth)
|
||||
(list (quote js-for-of-in) iter-kind ident iter body)))))))
|
||||
(else
|
||||
(let
|
||||
@@ -1138,8 +1288,11 @@
|
||||
(let
|
||||
((step (if (jp-at? st "punct" ")") nil (jp-parse-assignment st))))
|
||||
(jp-expect! st "punct" ")")
|
||||
(jp-disallow-decl-stmt! st "for")
|
||||
(jp-bump! st :loop-depth)
|
||||
(let
|
||||
((body (jp-parse-stmt st)))
|
||||
(jp-decr! st :loop-depth)
|
||||
(list (quote js-for) init cond-ast step body)))))))))))
|
||||
|
||||
(define
|
||||
@@ -1162,10 +1315,14 @@
|
||||
(st)
|
||||
(do
|
||||
(jp-advance! st)
|
||||
(when
|
||||
(= (get st :fn-depth) 0)
|
||||
(error "SyntaxError: Illegal return statement"))
|
||||
(if
|
||||
(or
|
||||
(jp-at? st "punct" ";")
|
||||
(jp-at? st "punct" "}")
|
||||
(jp-token-nl? st)
|
||||
(jp-at? st "eof" nil))
|
||||
(do (jp-eat-semi st) (list (quote js-return) nil))
|
||||
(let
|
||||
@@ -1188,7 +1345,7 @@
|
||||
(let
|
||||
((params (jp-parse-param-list st)))
|
||||
(let
|
||||
((body (jp-parse-block st)))
|
||||
((body (jp-parse-fn-body st)))
|
||||
(list (quote js-funcdecl) nm params body))))))))
|
||||
|
||||
(define
|
||||
@@ -1207,7 +1364,7 @@
|
||||
(let
|
||||
((params (jp-parse-param-list st)))
|
||||
(let
|
||||
((body (jp-parse-block st)))
|
||||
((body (jp-parse-fn-body st)))
|
||||
(list (quote js-funcdecl-async) nm params body))))))))
|
||||
|
||||
(define
|
||||
@@ -1256,7 +1413,7 @@
|
||||
(let
|
||||
((params (jp-parse-param-list st)))
|
||||
(let
|
||||
((body (jp-parse-block st)))
|
||||
((body (jp-parse-fn-body st)))
|
||||
(list
|
||||
(quote js-method)
|
||||
(if static? "static" "instance")
|
||||
@@ -1284,9 +1441,11 @@
|
||||
((disc (jp-parse-assignment st)))
|
||||
(jp-expect! st "punct" ")")
|
||||
(jp-expect! st "punct" "{")
|
||||
(jp-bump! st :switch-depth)
|
||||
(let
|
||||
((cases (list)))
|
||||
(jp-parse-switch-cases st cases)
|
||||
(jp-decr! st :switch-depth)
|
||||
(jp-expect! st "punct" "}")
|
||||
(list (quote js-switch) disc cases)))))
|
||||
|
||||
@@ -1362,9 +1521,40 @@
|
||||
((jp-at? st "keyword" "for") (jp-parse-for-stmt st))
|
||||
((jp-at? st "keyword" "return") (jp-parse-return-stmt st))
|
||||
((jp-at? st "keyword" "break")
|
||||
(do (jp-advance! st) (jp-eat-semi st) (list (quote js-break))))
|
||||
(do
|
||||
(jp-advance! st)
|
||||
(cond
|
||||
((= (get (jp-peek st) :type) "ident")
|
||||
(do (jp-advance! st) (jp-eat-semi st) (list (quote js-break))))
|
||||
(else
|
||||
(do
|
||||
(when
|
||||
(and (= (get st :loop-depth) 0) (= (get st :switch-depth) 0))
|
||||
(error "SyntaxError: Illegal break statement"))
|
||||
(jp-eat-semi st)
|
||||
(list (quote js-break)))))))
|
||||
((jp-at? st "keyword" "continue")
|
||||
(do (jp-advance! st) (jp-eat-semi st) (list (quote js-continue))))
|
||||
(do
|
||||
(jp-advance! st)
|
||||
(cond
|
||||
((= (get (jp-peek st) :type) "ident")
|
||||
(do (jp-advance! st) (jp-eat-semi st) (list (quote js-continue))))
|
||||
(else
|
||||
(do
|
||||
(when
|
||||
(= (get st :loop-depth) 0)
|
||||
(error "SyntaxError: Illegal continue statement"))
|
||||
(jp-eat-semi st)
|
||||
(list (quote js-continue)))))))
|
||||
((and
|
||||
(= (get (jp-peek st) :type) "ident")
|
||||
(= (get (jp-peek-at st 1) :type) "punct")
|
||||
(= (get (jp-peek-at st 1) :value) ":"))
|
||||
(do
|
||||
(jp-advance! st)
|
||||
(jp-advance! st)
|
||||
(jp-disallow-decl-stmt! st "label")
|
||||
(jp-parse-stmt st)))
|
||||
((jp-at? st "keyword" "class") (jp-parse-class-decl st))
|
||||
((jp-at? st "keyword" "throw") (jp-parse-throw-stmt st))
|
||||
((jp-at? st "keyword" "try") (jp-parse-try-stmt st))
|
||||
@@ -1374,7 +1564,7 @@
|
||||
((jp-at? st "keyword" "switch") (jp-parse-switch-stmt st))
|
||||
(else
|
||||
(let
|
||||
((e (jp-parse-assignment st)))
|
||||
((e (jp-parse-comma-seq st)))
|
||||
(do (jp-eat-semi st) (list (quote js-exprstmt) e)))))))
|
||||
|
||||
(define
|
||||
@@ -1400,10 +1590,33 @@
|
||||
jp-parse-arrow-body
|
||||
(fn
|
||||
(st)
|
||||
(if
|
||||
(jp-at? st "punct" "{")
|
||||
(jp-parse-block st)
|
||||
(jp-parse-assignment st))))
|
||||
(jp-bump! st :fn-depth)
|
||||
(let
|
||||
((saved-loop (get st :loop-depth)) (saved-switch (get st :switch-depth)))
|
||||
(dict-set! st :loop-depth 0)
|
||||
(dict-set! st :switch-depth 0)
|
||||
(let
|
||||
((body (if (jp-at? st "punct" "{") (jp-parse-block st) (jp-parse-assignment st))))
|
||||
(jp-decr! st :fn-depth)
|
||||
(dict-set! st :loop-depth saved-loop)
|
||||
(dict-set! st :switch-depth saved-switch)
|
||||
body))))
|
||||
|
||||
(define
|
||||
jp-parse-fn-body
|
||||
(fn
|
||||
(st)
|
||||
(jp-bump! st :fn-depth)
|
||||
(let
|
||||
((saved-loop (get st :loop-depth)) (saved-switch (get st :switch-depth)))
|
||||
(dict-set! st :loop-depth 0)
|
||||
(dict-set! st :switch-depth 0)
|
||||
(let
|
||||
((body (jp-parse-block st)))
|
||||
(jp-decr! st :fn-depth)
|
||||
(dict-set! st :loop-depth saved-loop)
|
||||
(dict-set! st :switch-depth saved-switch)
|
||||
body))))
|
||||
|
||||
(define
|
||||
js-parse
|
||||
@@ -1414,7 +1627,7 @@
|
||||
(= (len tokens) 0)
|
||||
(and (= (len tokens) 1) (= (get (nth tokens 0) :type) "eof")))
|
||||
(list (quote js-program) (list))
|
||||
(let ((st {:idx 0 :tokens tokens :arrow-candidate true})) (jp-parse-program st)))))
|
||||
(let ((st {:idx 0 :tokens tokens :arrow-candidate true :loop-depth 0 :switch-depth 0 :fn-depth 0})) (jp-parse-program st)))))
|
||||
|
||||
(define
|
||||
js-parse-expr
|
||||
@@ -1427,4 +1640,4 @@
|
||||
(= (len tokens) 0)
|
||||
(and (= (len tokens) 1) (= (get (nth tokens 0) :type) "eof")))
|
||||
(list)
|
||||
(let ((st {:idx 0 :tokens tokens :arrow-candidate true})) (jp-parse-assignment st))))))
|
||||
(let ((st {:idx 0 :tokens tokens :arrow-candidate true :loop-depth 0 :switch-depth 0 :fn-depth 0})) (jp-parse-assignment st))))))
|
||||
|
||||
4066
lib/js/runtime.sx
4066
lib/js/runtime.sx
File diff suppressed because it is too large
Load Diff
@@ -1486,6 +1486,24 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(eval "(get (RegExp \"hello\" \"gi\") \"global\")")
|
||||
(epoch 6032)
|
||||
(eval "(get (RegExp \"foo\" \"i\") \"ignoreCase\")")
|
||||
;; ── Phase 1.ASI: automatic semicolon insertion ─────────────────
|
||||
(epoch 4200)
|
||||
(eval "(js-eval \"function f() { return\n42\n} f()\")")
|
||||
(epoch 4201)
|
||||
(eval "(js-eval \"function g() { return 42 } g()\")")
|
||||
(epoch 4202)
|
||||
(eval "(let ((toks (js-tokenize \"a\nb\"))) (get (nth toks 1) :nl))")
|
||||
(epoch 4203)
|
||||
(eval "(let ((toks (js-tokenize \"a b\"))) (get (nth toks 1) :nl))")
|
||||
|
||||
(epoch 4300)
|
||||
(eval "(js-eval \"var x = 5; x\")")
|
||||
(epoch 4301)
|
||||
(eval "(js-eval \"function f() { return x; var x = 42; } f()\")")
|
||||
(epoch 4302)
|
||||
(eval "(js-eval \"function f() { var y = 7; return y; } f()\")")
|
||||
(epoch 4303)
|
||||
(eval "(js-eval \"function f() { var z; z = 3; return z; } f()\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
@@ -2280,6 +2298,16 @@ check 6025 "set delete→size 0" '0'
|
||||
check 6030 "RegExp? result" 'true'
|
||||
check 6031 "RegExp global flag" 'true'
|
||||
check 6032 "RegExp ignoreCase" 'true'
|
||||
# ── Phase 1.ASI: automatic semicolon insertion ────────────────────
|
||||
check 4200 "return+newline → undefined" '"js-undefined"'
|
||||
check 4201 "return+space+val → val" '42'
|
||||
check 4202 "nl-before flag set after newline" 'true'
|
||||
check 4203 "nl-before flag false on same line" 'false'
|
||||
|
||||
check 4300 "var decl program-level" '5'
|
||||
check 4301 "var hoisted before use → undef" '"js-undefined"'
|
||||
check 4302 "var in function body" '7'
|
||||
check 4303 "var then set in function" '3'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
|
||||
@@ -52,7 +52,7 @@ UPSTREAM = REPO / "lib" / "js" / "test262-upstream"
|
||||
TEST_ROOT = UPSTREAM / "test"
|
||||
HARNESS_DIR = UPSTREAM / "harness"
|
||||
|
||||
DEFAULT_PER_TEST_TIMEOUT_S = 5.0
|
||||
DEFAULT_PER_TEST_TIMEOUT_S = 15.0
|
||||
DEFAULT_BATCH_TIMEOUT_S = 120
|
||||
|
||||
# Cache dir for precomputed SX source of harness JS (one file per Python run).
|
||||
@@ -134,6 +134,9 @@ var verifyProperty = function (obj, name, desc, opts) {
|
||||
}
|
||||
};
|
||||
var verifyPrimordialProperty = verifyProperty;
|
||||
var verifyEqualTo = function (obj, name, value) {
|
||||
assert.sameValue(obj[name], value, name + " equals");
|
||||
};
|
||||
var verifyNotEnumerable = function (o, n, v, w, x) { };
|
||||
var verifyNotWritable = function (o, n, v, w, x) { };
|
||||
var verifyNotConfigurable = function (o, n, v, w, x) { };
|
||||
@@ -146,6 +149,50 @@ var isConstructor = function (f) {
|
||||
// Best-effort: built-in functions and arrows aren't; declared `function` decls are.
|
||||
return false;
|
||||
};
|
||||
// $DONE / asyncTest — async-flag tests call $DONE(err) to signal completion.
|
||||
// Since we drain microtasks synchronously, $DONE is just a final-assertion sink.
|
||||
var $DONE = function (err) {
|
||||
if (err) { throw new Test262Error((err && err.message) || err); }
|
||||
};
|
||||
var asyncTest = function (testFunc) {
|
||||
Promise.resolve(testFunc()).then(function () { $DONE(); }, function (e) { $DONE(e); });
|
||||
};
|
||||
// promiseHelper.js include — used by Promise.all/race tests for ordering checks.
|
||||
var checkSequence = function (arr, message) {
|
||||
for (var i = 0; i < arr.length; i = i + 1) {
|
||||
if (arr[i] !== (i + 1)) {
|
||||
throw new Test262Error((message || "Sequence") + " expected " + (i+1) + " at index " + i + " but got " + arr[i]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
var checkSettledPromises = function (settleds, expected, message) {
|
||||
var msg = message ? message + " " : "";
|
||||
if (settleds.length !== expected.length) {
|
||||
throw new Test262Error(msg + "lengths differ: " + settleds.length + " vs " + expected.length);
|
||||
}
|
||||
for (var i = 0; i < settleds.length; i = i + 1) {
|
||||
if (settleds[i].status !== expected[i].status) {
|
||||
throw new Test262Error(msg + "status[" + i + "]: " + settleds[i].status + " vs " + expected[i].status);
|
||||
}
|
||||
if (expected[i].status === "fulfilled" && settleds[i].value !== expected[i].value) {
|
||||
throw new Test262Error(msg + "value[" + i + "]: " + settleds[i].value + " vs " + expected[i].value);
|
||||
}
|
||||
if (expected[i].status === "rejected" && settleds[i].reason !== expected[i].reason) {
|
||||
throw new Test262Error(msg + "reason[" + i + "]: " + settleds[i].reason + " vs " + expected[i].reason);
|
||||
}
|
||||
}
|
||||
};
|
||||
// decimalToHexString.js include — used by URI/escape tests.
|
||||
var decimalToHexString = function (n) {
|
||||
var hex = "0123456789ABCDEF";
|
||||
if (n < 0) { n = n + 65536; }
|
||||
return hex[(n >> 12) & 15] + hex[(n >> 8) & 15] + hex[(n >> 4) & 15] + hex[n & 15];
|
||||
};
|
||||
var decimalToPercentHexString = function (n) {
|
||||
var hex = "0123456789ABCDEF";
|
||||
return "%" + hex[(n >> 4) & 15] + hex[n & 15];
|
||||
};
|
||||
// Trivial helper for tests that use Array.isArray-like functionality
|
||||
// (many tests reach for it via compareArray)
|
||||
"""
|
||||
@@ -358,6 +405,8 @@ def classify_negative_result(fm: Frontmatter, kind: str, payload: str):
|
||||
or ("expected" in low and "got" in low)
|
||||
or "js-transpile-unop" in low
|
||||
or "js-transpile-binop" in low
|
||||
or "js-transpile-assign" in low
|
||||
or "js-transpile" in low
|
||||
or "js-compound-update" in low
|
||||
or "parse" in low
|
||||
):
|
||||
@@ -1012,11 +1061,45 @@ def _worker_run(args):
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
_HARNESS_INCLUDE_CACHE: dict = {}
|
||||
|
||||
# Only inline these small harness files per-test. Large ones like propertyHelper.js
|
||||
# multiply js-eval/JIT cost by ~5-10x and push tests over the per-test timeout.
|
||||
_INLINE_INCLUDES = {"nans.js", "sta.js", "byteConversionValues.js", "compareArray.js"}
|
||||
|
||||
|
||||
def _load_harness_include(name: str) -> str:
|
||||
"""Read an upstream harness include file (e.g. nans.js).
|
||||
Returns empty string if the file isn't present.
|
||||
"""
|
||||
if name in _HARNESS_INCLUDE_CACHE:
|
||||
return _HARNESS_INCLUDE_CACHE[name]
|
||||
path = HARNESS_DIR / name
|
||||
try:
|
||||
src = path.read_text()
|
||||
except OSError:
|
||||
src = ""
|
||||
_HARNESS_INCLUDE_CACHE[name] = src
|
||||
return src
|
||||
|
||||
|
||||
def assemble_source(t):
|
||||
"""Return JS source to feed to js-eval. Harness is preloaded, so we only
|
||||
append the test source (plus negative-test prep if needed).
|
||||
append the test source (plus a small allowlist of per-test includes).
|
||||
"""
|
||||
return t.src
|
||||
if not getattr(t.fm, "includes", None):
|
||||
return t.src
|
||||
parts = []
|
||||
for inc in t.fm.includes:
|
||||
if inc not in _INLINE_INCLUDES:
|
||||
continue
|
||||
chunk = _load_harness_include(inc)
|
||||
if chunk:
|
||||
parts.append(chunk)
|
||||
if not parts:
|
||||
return t.src
|
||||
parts.append(t.src)
|
||||
return "\n".join(parts)
|
||||
|
||||
|
||||
def aggregate(results):
|
||||
@@ -1194,7 +1277,7 @@ def main(argv):
|
||||
shards = [[] for _ in range(n_workers)]
|
||||
for i, t in enumerate(tests):
|
||||
shards[i % n_workers].append(
|
||||
(t.rel, t.category, t.src, t.fm.negative_phase, t.fm.negative_type)
|
||||
(t.rel, t.category, assemble_source(t), t.fm.negative_phase, t.fm.negative_type)
|
||||
)
|
||||
|
||||
t_run_start = time.monotonic()
|
||||
|
||||
@@ -1,137 +1,53 @@
|
||||
{
|
||||
"totals": {
|
||||
"pass": 162,
|
||||
"fail": 128,
|
||||
"skip": 1597,
|
||||
"timeout": 10,
|
||||
"total": 1897,
|
||||
"runnable": 300,
|
||||
"pass_rate": 54.0
|
||||
"pass": 4,
|
||||
"fail": 10,
|
||||
"skip": 16,
|
||||
"timeout": 0,
|
||||
"total": 30,
|
||||
"runnable": 14,
|
||||
"pass_rate": 28.6
|
||||
},
|
||||
"categories": [
|
||||
{
|
||||
"category": "built-ins/Math",
|
||||
"total": 327,
|
||||
"pass": 43,
|
||||
"fail": 56,
|
||||
"skip": 227,
|
||||
"timeout": 1,
|
||||
"pass_rate": 43.0,
|
||||
"category": "built-ins/Function",
|
||||
"total": 30,
|
||||
"pass": 4,
|
||||
"fail": 10,
|
||||
"skip": 16,
|
||||
"timeout": 0,
|
||||
"pass_rate": 28.6,
|
||||
"top_failures": [
|
||||
[
|
||||
"TypeError: not a function",
|
||||
36
|
||||
],
|
||||
[
|
||||
"Test262Error (assertion failed)",
|
||||
20
|
||||
],
|
||||
[
|
||||
"Timeout",
|
||||
1
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"category": "built-ins/Number",
|
||||
"total": 340,
|
||||
"pass": 77,
|
||||
"fail": 19,
|
||||
"skip": 240,
|
||||
"timeout": 4,
|
||||
"pass_rate": 77.0,
|
||||
"top_failures": [
|
||||
[
|
||||
"Test262Error (assertion failed)",
|
||||
19
|
||||
],
|
||||
[
|
||||
"Timeout",
|
||||
"SyntaxError (parse/unsupported syntax)",
|
||||
4
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"category": "built-ins/String",
|
||||
"total": 1223,
|
||||
"pass": 42,
|
||||
"fail": 53,
|
||||
"skip": 1123,
|
||||
"timeout": 5,
|
||||
"pass_rate": 42.0,
|
||||
"top_failures": [
|
||||
[
|
||||
"Test262Error (assertion failed)",
|
||||
44
|
||||
],
|
||||
[
|
||||
"Timeout",
|
||||
5
|
||||
],
|
||||
[
|
||||
"ReferenceError (undefined symbol)",
|
||||
2
|
||||
3
|
||||
],
|
||||
[
|
||||
"Unhandled: Not callable: {:__proto__ {:toLowerCase <lambda(&rest, args)",
|
||||
2
|
||||
],
|
||||
[
|
||||
"Unhandled: Not callable: \\\\\\",
|
||||
2
|
||||
"TypeError (other)",
|
||||
3
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"category": "built-ins/StringIteratorPrototype",
|
||||
"total": 7,
|
||||
"pass": 0,
|
||||
"fail": 0,
|
||||
"skip": 7,
|
||||
"timeout": 0,
|
||||
"pass_rate": 0.0,
|
||||
"top_failures": []
|
||||
}
|
||||
],
|
||||
"top_failure_modes": [
|
||||
[
|
||||
"Test262Error (assertion failed)",
|
||||
83
|
||||
],
|
||||
[
|
||||
"TypeError: not a function",
|
||||
36
|
||||
],
|
||||
[
|
||||
"Timeout",
|
||||
10
|
||||
"SyntaxError (parse/unsupported syntax)",
|
||||
4
|
||||
],
|
||||
[
|
||||
"ReferenceError (undefined symbol)",
|
||||
2
|
||||
3
|
||||
],
|
||||
[
|
||||
"Unhandled: Not callable: {:__proto__ {:toLowerCase <lambda(&rest, args)",
|
||||
2
|
||||
],
|
||||
[
|
||||
"Unhandled: Not callable: \\\\\\",
|
||||
2
|
||||
],
|
||||
[
|
||||
"SyntaxError (parse/unsupported syntax)",
|
||||
1
|
||||
],
|
||||
[
|
||||
"Unhandled: Not callable: {:__proto__ {:valueOf <lambda()> :propertyIsEn",
|
||||
1
|
||||
],
|
||||
[
|
||||
"Unhandled: js-transpile-binop: unsupported op: >>>\\",
|
||||
1
|
||||
"TypeError (other)",
|
||||
3
|
||||
]
|
||||
],
|
||||
"pinned_commit": "d5e73fc8d2c663554fb72e2380a8c2bc1a318a33",
|
||||
"elapsed_seconds": 274.5,
|
||||
"elapsed_seconds": 11.2,
|
||||
"workers": 1
|
||||
}
|
||||
@@ -1,47 +1,26 @@
|
||||
# test262 scoreboard
|
||||
|
||||
Pinned commit: `d5e73fc8d2c663554fb72e2380a8c2bc1a318a33`
|
||||
Wall time: 274.5s
|
||||
Wall time: 11.2s
|
||||
|
||||
**Total:** 162/300 runnable passed (54.0%). Raw: pass=162 fail=128 skip=1597 timeout=10 total=1897.
|
||||
**Total:** 4/14 runnable passed (28.6%). Raw: pass=4 fail=10 skip=16 timeout=0 total=30.
|
||||
|
||||
## Top failure modes
|
||||
|
||||
- **83x** Test262Error (assertion failed)
|
||||
- **36x** TypeError: not a function
|
||||
- **10x** Timeout
|
||||
- **2x** ReferenceError (undefined symbol)
|
||||
- **2x** Unhandled: Not callable: {:__proto__ {:toLowerCase <lambda(&rest, args)
|
||||
- **2x** Unhandled: Not callable: \\\
|
||||
- **1x** SyntaxError (parse/unsupported syntax)
|
||||
- **1x** Unhandled: Not callable: {:__proto__ {:valueOf <lambda()> :propertyIsEn
|
||||
- **1x** Unhandled: js-transpile-binop: unsupported op: >>>\
|
||||
- **4x** SyntaxError (parse/unsupported syntax)
|
||||
- **3x** ReferenceError (undefined symbol)
|
||||
- **3x** TypeError (other)
|
||||
|
||||
## Categories (worst pass-rate first, min 10 runnable)
|
||||
|
||||
| Category | Pass | Fail | Skip | Timeout | Total | Pass % |
|
||||
|---|---:|---:|---:|---:|---:|---:|
|
||||
| built-ins/String | 42 | 53 | 1123 | 5 | 1223 | 42.0% |
|
||||
| built-ins/Math | 43 | 56 | 227 | 1 | 327 | 43.0% |
|
||||
| built-ins/Number | 77 | 19 | 240 | 4 | 340 | 77.0% |
|
||||
| built-ins/Function | 4 | 10 | 16 | 0 | 30 | 28.6% |
|
||||
|
||||
## Per-category top failures (min 10 runnable, worst first)
|
||||
|
||||
### built-ins/String (42/100 — 42.0%)
|
||||
### built-ins/Function (4/14 — 28.6%)
|
||||
|
||||
- **44x** Test262Error (assertion failed)
|
||||
- **5x** Timeout
|
||||
- **2x** ReferenceError (undefined symbol)
|
||||
- **2x** Unhandled: Not callable: {:__proto__ {:toLowerCase <lambda(&rest, args)
|
||||
- **2x** Unhandled: Not callable: \\\
|
||||
|
||||
### built-ins/Math (43/100 — 43.0%)
|
||||
|
||||
- **36x** TypeError: not a function
|
||||
- **20x** Test262Error (assertion failed)
|
||||
- **1x** Timeout
|
||||
|
||||
### built-ins/Number (77/100 — 77.0%)
|
||||
|
||||
- **19x** Test262Error (assertion failed)
|
||||
- **4x** Timeout
|
||||
- **4x** SyntaxError (parse/unsupported syntax)
|
||||
- **3x** ReferenceError (undefined symbol)
|
||||
- **3x** TypeError (other)
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
(list (js-sym "js-regex-new") (nth ast 1) (nth ast 2)))
|
||||
((js-tag? ast "js-null") nil)
|
||||
((js-tag? ast "js-undef") (list (js-sym "quote") :js-undefined))
|
||||
((js-tag? ast "js-paren") (js-transpile (nth ast 1)))
|
||||
((js-tag? ast "js-ident") (js-transpile-ident (nth ast 1)))
|
||||
((js-tag? ast "js-unop")
|
||||
(js-transpile-unop (nth ast 1) (nth ast 2)))
|
||||
@@ -116,7 +117,8 @@
|
||||
((js-tag? ast "js-arrow")
|
||||
(js-transpile-arrow (nth ast 1) (nth ast 2)))
|
||||
((js-tag? ast "js-program") (js-transpile-stmts (nth ast 1)))
|
||||
((js-tag? ast "js-block") (js-transpile-stmts (nth ast 1)))
|
||||
((js-tag? ast "js-block")
|
||||
(cons (js-sym "begin") (js-transpile-stmt-list (nth ast 1))))
|
||||
((js-tag? ast "js-exprstmt") (js-transpile (nth ast 1)))
|
||||
((js-tag? ast "js-empty") nil)
|
||||
((js-tag? ast "js-var")
|
||||
@@ -164,6 +166,8 @@
|
||||
(js-transpile-new (nth ast 1) (nth ast 2)))
|
||||
((js-tag? ast "js-class")
|
||||
(js-transpile-class (nth ast 1) (nth ast 2) (nth ast 3)))
|
||||
((js-tag? ast "js-comma")
|
||||
(cons (js-sym "begin") (map js-transpile (nth ast 1))))
|
||||
((js-tag? ast "js-throw") (js-transpile-throw (nth ast 1)))
|
||||
((js-tag? ast "js-try")
|
||||
(js-transpile-try (nth ast 1) (nth ast 2) (nth ast 3)))
|
||||
@@ -221,7 +225,23 @@
|
||||
(js-sym "js-delete-prop")
|
||||
(js-transpile (nth arg 1))
|
||||
(js-transpile (nth arg 2))))
|
||||
((js-tag? arg "js-ident") false)
|
||||
((js-tag? arg "js-paren") (js-transpile-unop op (nth arg 1)))
|
||||
(else true)))
|
||||
((and (= op "typeof") (js-tag? arg "js-ident"))
|
||||
(let
|
||||
((name (nth arg 1)))
|
||||
(list
|
||||
(js-sym "if")
|
||||
(list
|
||||
(js-sym "or")
|
||||
(list
|
||||
(js-sym "env-has?")
|
||||
(list (js-sym "current-env"))
|
||||
name)
|
||||
(list (js-sym "dict-has?") (js-sym "js-global") name))
|
||||
(list (js-sym "js-typeof") (js-transpile arg))
|
||||
"undefined")))
|
||||
(else
|
||||
(let
|
||||
((a (js-transpile arg)))
|
||||
@@ -231,7 +251,8 @@
|
||||
((= op "!") (list (js-sym "js-not") a))
|
||||
((= op "~") (list (js-sym "js-bitnot") a))
|
||||
((= op "typeof") (list (js-sym "js-typeof") a))
|
||||
((= op "void") (list (js-sym "quote") :js-undefined))
|
||||
((= op "void")
|
||||
(list (js-sym "begin") a (list (js-sym "quote") :js-undefined)))
|
||||
(else (error (str "js-transpile-unop: unsupported op: " op)))))))))
|
||||
|
||||
;; ── Array literal ─────────────────────────────────────────────────
|
||||
@@ -295,6 +316,21 @@
|
||||
(list (js-sym "js-undefined?") (js-sym "_a")))
|
||||
(js-transpile r)
|
||||
(js-sym "_a"))))
|
||||
((= op ">>>")
|
||||
(list
|
||||
(js-sym "js-unsigned-rshift")
|
||||
(js-transpile l)
|
||||
(js-transpile r)))
|
||||
((= op "<<")
|
||||
(list (js-sym "js-shl") (js-transpile l) (js-transpile r)))
|
||||
((= op ">>")
|
||||
(list (js-sym "js-shr") (js-transpile l) (js-transpile r)))
|
||||
((= op "&")
|
||||
(list (js-sym "js-bitand") (js-transpile l) (js-transpile r)))
|
||||
((= op "|")
|
||||
(list (js-sym "js-bitor") (js-transpile l) (js-transpile r)))
|
||||
((= op "^")
|
||||
(list (js-sym "js-bitxor") (js-transpile l) (js-transpile r)))
|
||||
(else (error (str "js-transpile-binop: unsupported op: " op))))))
|
||||
|
||||
;; ── Object literal ────────────────────────────────────────────────
|
||||
@@ -373,7 +409,19 @@
|
||||
(list
|
||||
(js-sym "js-new-call")
|
||||
(js-transpile callee)
|
||||
(cons (js-sym "list") (map js-transpile args)))))
|
||||
(cond
|
||||
((js-has-spread? args)
|
||||
(cons
|
||||
(js-sym "js-array-spread-build")
|
||||
(map
|
||||
(fn
|
||||
(e)
|
||||
(if
|
||||
(js-tag? e "js-spread")
|
||||
(list (js-sym "list") "js-spread" (js-transpile (nth e 1)))
|
||||
(list (js-sym "list") "js-value" (js-transpile e))))
|
||||
args)))
|
||||
(else (cons (js-sym "js-args") (map js-transpile args)))))))
|
||||
|
||||
(define
|
||||
js-transpile-array
|
||||
@@ -391,7 +439,7 @@
|
||||
(list (js-sym "list") "js-spread" (js-transpile (nth e 1)))
|
||||
(list (js-sym "list") "js-value" (js-transpile e))))
|
||||
elts))
|
||||
(cons (js-sym "list") (map js-transpile elts)))))
|
||||
(cons (js-sym "js-make-list") (map js-transpile elts)))))
|
||||
|
||||
(define
|
||||
js-has-spread?
|
||||
@@ -421,7 +469,7 @@
|
||||
(list (js-sym "list") "js-spread" (js-transpile (nth e 1)))
|
||||
(list (js-sym "list") "js-value" (js-transpile e))))
|
||||
args))
|
||||
(cons (js-sym "list") (map js-transpile args)))))
|
||||
(cons (js-sym "js-args") (map js-transpile args)))))
|
||||
|
||||
;; Transpile a JS expression string to SX source text (for inspection
|
||||
;; in tests). Useful for asserting the exact emitted tree.
|
||||
@@ -431,18 +479,28 @@
|
||||
(entries)
|
||||
(list
|
||||
(js-sym "let")
|
||||
(list (list (js-sym "_obj") (list (js-sym "dict"))))
|
||||
(list (list (js-sym "_obj") (list (js-sym "js-make-obj"))))
|
||||
(cons
|
||||
(js-sym "begin")
|
||||
(append
|
||||
(map
|
||||
(fn
|
||||
(entry)
|
||||
(list
|
||||
(js-sym "dict-set!")
|
||||
(js-sym "_obj")
|
||||
(get entry :key)
|
||||
(js-transpile (get entry :value))))
|
||||
(cond
|
||||
((contains? (keys entry) :spread)
|
||||
(list
|
||||
(js-sym "js-obj-spread!")
|
||||
(js-sym "_obj")
|
||||
(js-transpile (get entry :spread))))
|
||||
(else
|
||||
(list
|
||||
(js-sym "js-obj-set!")
|
||||
(js-sym "_obj")
|
||||
(if
|
||||
(contains? (keys entry) :computed-key)
|
||||
(list (js-sym "js-to-string") (js-transpile (get entry :computed-key)))
|
||||
(get entry :key))
|
||||
(js-transpile (get entry :value))))))
|
||||
entries)
|
||||
(list (js-sym "_obj")))))))
|
||||
|
||||
@@ -486,6 +544,95 @@
|
||||
(append inits (list (js-transpile body))))))))
|
||||
(list (js-sym "fn") param-syms body-tr))))
|
||||
|
||||
(define
|
||||
js-collect-var-decl-names
|
||||
(fn
|
||||
(decls)
|
||||
(cond
|
||||
((empty? decls) (list))
|
||||
((js-tag? (first decls) "js-vardecl")
|
||||
(cons
|
||||
(nth (first decls) 1)
|
||||
(js-collect-var-decl-names (rest decls))))
|
||||
(else (js-collect-var-decl-names (rest decls))))))
|
||||
|
||||
(define
|
||||
js-collect-var-names
|
||||
(fn
|
||||
(stmts)
|
||||
(cond
|
||||
((empty? stmts) (list))
|
||||
(else
|
||||
(append
|
||||
(js-collect-var-names-stmt (first stmts))
|
||||
(js-collect-var-names (rest stmts)))))))
|
||||
|
||||
(define
|
||||
js-collect-var-names-stmt
|
||||
(fn
|
||||
(stmt)
|
||||
(cond
|
||||
((not (list? stmt)) (list))
|
||||
((and (js-tag? stmt "js-var") (= (nth stmt 1) "var"))
|
||||
(js-collect-var-decl-names (nth stmt 2)))
|
||||
((js-tag? stmt "js-block") (js-collect-var-names (nth stmt 1)))
|
||||
((js-tag? stmt "js-for")
|
||||
(append
|
||||
(js-collect-var-names-stmt (nth stmt 1))
|
||||
(js-collect-var-names-stmt (nth stmt 4))))
|
||||
((js-tag? stmt "js-for-of-in")
|
||||
(js-collect-var-names-stmt (nth stmt 4)))
|
||||
((js-tag? stmt "js-while")
|
||||
(js-collect-var-names-stmt (nth stmt 2)))
|
||||
((js-tag? stmt "js-do-while")
|
||||
(js-collect-var-names-stmt (nth stmt 1)))
|
||||
((js-tag? stmt "js-if")
|
||||
(append
|
||||
(js-collect-var-names-stmt (nth stmt 2))
|
||||
(if (>= (len stmt) 4) (js-collect-var-names-stmt (nth stmt 3)) (list))))
|
||||
((js-tag? stmt "js-try")
|
||||
(append
|
||||
(js-collect-var-names-stmt (nth stmt 1))
|
||||
(if (and (>= (len stmt) 3) (list? (nth stmt 2)))
|
||||
(js-collect-var-names-stmt (nth (nth stmt 2) 2))
|
||||
(list))
|
||||
(if (>= (len stmt) 4) (js-collect-var-names-stmt (nth stmt 3)) (list))))
|
||||
((js-tag? stmt "js-switch")
|
||||
(js-collect-var-names-cases (nth stmt 2)))
|
||||
(else (list)))))
|
||||
|
||||
(define
|
||||
js-collect-var-names-cases
|
||||
(fn
|
||||
(cases)
|
||||
(cond
|
||||
((empty? cases) (list))
|
||||
(else
|
||||
(append
|
||||
(js-collect-var-names (nth (first cases) 2))
|
||||
(js-collect-var-names-cases (rest cases)))))))
|
||||
|
||||
(define
|
||||
js-dedup-names
|
||||
(fn
|
||||
(names seen)
|
||||
(cond
|
||||
((empty? names) (list))
|
||||
((some (fn (s) (= s (first names))) seen)
|
||||
(js-dedup-names (rest names) seen))
|
||||
(else
|
||||
(cons
|
||||
(first names)
|
||||
(js-dedup-names (rest names) (cons (first names) seen)))))))
|
||||
|
||||
(define
|
||||
js-var-hoist-forms
|
||||
(fn
|
||||
(names)
|
||||
(map
|
||||
(fn (name) (list (js-sym "define") (js-sym name) :js-undefined))
|
||||
names)))
|
||||
|
||||
(define
|
||||
js-transpile-tpl
|
||||
(fn
|
||||
@@ -577,6 +724,12 @@
|
||||
(list (js-sym "js-undefined?") lhs-expr))
|
||||
rhs-expr
|
||||
lhs-expr))
|
||||
((= op "<<=") (list (js-sym "js-shl") lhs-expr rhs-expr))
|
||||
((= op ">>=") (list (js-sym "js-shr") lhs-expr rhs-expr))
|
||||
((= op ">>>=") (list (js-sym "js-unsigned-rshift") lhs-expr rhs-expr))
|
||||
((= op "&=") (list (js-sym "js-bitand") lhs-expr rhs-expr))
|
||||
((= op "|=") (list (js-sym "js-bitor") lhs-expr rhs-expr))
|
||||
((= op "^=") (list (js-sym "js-bitxor") lhs-expr rhs-expr))
|
||||
(else (error (str "js-compound-update: unsupported op: " op))))))
|
||||
|
||||
(define
|
||||
@@ -806,7 +959,7 @@
|
||||
(if
|
||||
(= iter-kind "of")
|
||||
(list (js-sym "js-iterable-to-list") iter-sx)
|
||||
(list (js-sym "js-object-keys") iter-sx))))
|
||||
(list (js-sym "js-for-in-keys") iter-sx))))
|
||||
(list
|
||||
(js-sym "for-each")
|
||||
(list
|
||||
@@ -835,7 +988,7 @@
|
||||
(fn
|
||||
(params)
|
||||
(cond
|
||||
((empty? params) (list))
|
||||
((empty? params) (list (js-sym "&rest") (js-sym "__extra_args__")))
|
||||
((and (list? (first params)) (js-tag? (first params) "js-rest"))
|
||||
(list (js-sym "&rest") (js-sym (nth (first params) 1))))
|
||||
(else
|
||||
@@ -843,6 +996,27 @@
|
||||
(js-param-sym (first params))
|
||||
(js-build-param-list (rest params)))))))
|
||||
|
||||
(define
|
||||
js-arguments-build-form
|
||||
(fn
|
||||
(params)
|
||||
(list (js-sym "js-list-copy") (js-arguments-build-form-raw params))))
|
||||
|
||||
(define
|
||||
js-arguments-build-form-raw
|
||||
(fn
|
||||
(params)
|
||||
(cond
|
||||
((empty? params)
|
||||
(js-sym "__extra_args__"))
|
||||
((and (list? (first params)) (js-tag? (first params) "js-rest"))
|
||||
(js-sym (nth (first params) 1)))
|
||||
(else
|
||||
(list
|
||||
(js-sym "cons")
|
||||
(js-param-sym (first params))
|
||||
(js-arguments-build-form-raw (rest params)))))))
|
||||
|
||||
(define
|
||||
js-param-init-forms
|
||||
(fn
|
||||
@@ -876,7 +1050,7 @@
|
||||
(fn
|
||||
(stmts)
|
||||
(let
|
||||
((hoisted (js-collect-funcdecls stmts)))
|
||||
((hoisted (append (js-var-hoist-forms (js-dedup-names (js-collect-var-names stmts) (list))) (js-collect-funcdecls stmts))))
|
||||
(let
|
||||
((rest-stmts (js-transpile-stmt-list stmts)))
|
||||
(cons (js-sym "begin") (append hoisted rest-stmts))))))
|
||||
@@ -935,12 +1109,12 @@
|
||||
|
||||
(define
|
||||
js-transpile-var
|
||||
(fn (kind decls) (cons (js-sym "begin") (js-vardecl-forms kind decls))))
|
||||
(fn (kind decls) (cons (js-sym "begin") (js-vardecl-forms decls (= kind "var")))))
|
||||
|
||||
(define
|
||||
js-vardecl-forms
|
||||
(fn
|
||||
(kind decls)
|
||||
(decls is-var)
|
||||
(cond
|
||||
((empty? decls) (list))
|
||||
(else
|
||||
@@ -950,10 +1124,10 @@
|
||||
((js-tag? d "js-vardecl")
|
||||
(cons
|
||||
(list
|
||||
(js-sym "define")
|
||||
(js-sym (if is-var "set!" "define"))
|
||||
(js-sym (nth d 1))
|
||||
(js-transpile (nth d 2)))
|
||||
(js-vardecl-forms kind (rest decls))))
|
||||
(js-vardecl-forms (rest decls) is-var)))
|
||||
((js-tag? d "js-vardecl-obj")
|
||||
(let
|
||||
((names (nth d 1))
|
||||
@@ -964,7 +1138,7 @@
|
||||
(js-vardecl-obj-forms
|
||||
names
|
||||
tmp-sym
|
||||
(js-vardecl-forms kind (rest decls))))))
|
||||
(js-vardecl-forms (rest decls) is-var)))))
|
||||
((js-tag? d "js-vardecl-arr")
|
||||
(let
|
||||
((names (nth d 1))
|
||||
@@ -976,7 +1150,7 @@
|
||||
names
|
||||
tmp-sym
|
||||
0
|
||||
(js-vardecl-forms kind (rest decls))))))
|
||||
(js-vardecl-forms (rest decls) is-var)))))
|
||||
(else (error "js-vardecl-forms: unexpected decl"))))))))
|
||||
|
||||
(define
|
||||
@@ -1276,7 +1450,28 @@
|
||||
(let
|
||||
((body-tr (js-transpile body)))
|
||||
(let
|
||||
((with-catch (cond ((= catch-part nil) body-tr) (else (let ((pname (nth catch-part 0)) (cbody (nth catch-part 1))) (list (js-sym "guard") (list (if (= pname nil) (js-sym "__exc__") (js-sym pname)) (list (js-sym "else") (js-transpile cbody))) body-tr))))))
|
||||
((with-catch
|
||||
(cond
|
||||
((= catch-part nil) body-tr)
|
||||
(else
|
||||
(let
|
||||
((pname (nth catch-part 0))
|
||||
(cbody (nth catch-part 1))
|
||||
(raw-sym (js-sym "__raw_exc__")))
|
||||
(list
|
||||
(js-sym "guard")
|
||||
(list
|
||||
raw-sym
|
||||
(list
|
||||
(js-sym "else")
|
||||
(cond
|
||||
((= pname nil) (js-transpile cbody))
|
||||
(else
|
||||
(list
|
||||
(js-sym "let")
|
||||
(list (list (js-sym pname) (list (js-sym "js-wrap-exn") raw-sym)))
|
||||
(js-transpile cbody))))))
|
||||
body-tr))))))
|
||||
(cond
|
||||
((= finally-part nil) with-catch)
|
||||
(else
|
||||
@@ -1297,7 +1492,7 @@
|
||||
(if
|
||||
(and (list? body) (js-tag? body "js-block"))
|
||||
(let
|
||||
((hoisted (js-collect-funcdecls (nth body 1))))
|
||||
((hoisted (append (js-var-hoist-forms (js-dedup-names (js-collect-var-names (nth body 1)) (list))) (js-collect-funcdecls (nth body 1)))))
|
||||
(append hoisted (js-transpile-stmt-list (nth body 1))))
|
||||
(list (js-transpile body)))))
|
||||
(list
|
||||
@@ -1305,7 +1500,9 @@
|
||||
param-syms
|
||||
(list
|
||||
(js-sym "let")
|
||||
(list (list (js-sym "this") (list (js-sym "js-this"))))
|
||||
(list
|
||||
(list (js-sym "this") (list (js-sym "js-this")))
|
||||
(list (js-sym "arguments") (js-arguments-build-form params)))
|
||||
(list
|
||||
(js-sym "let")
|
||||
(list
|
||||
@@ -1316,7 +1513,7 @@
|
||||
(list
|
||||
(js-sym "fn")
|
||||
(list (js-sym "__return__"))
|
||||
(cons (js-sym "begin") (append inits body-forms))))))
|
||||
(cons (js-sym "begin") (append (append inits body-forms) (list nil)))))))
|
||||
(list
|
||||
(js-sym "if")
|
||||
(list (js-sym "=") (js-sym "__r__") nil)
|
||||
@@ -1333,7 +1530,7 @@
|
||||
(if
|
||||
(and (list? body) (js-tag? body "js-block"))
|
||||
(let
|
||||
((hoisted (js-collect-funcdecls (nth body 1))))
|
||||
((hoisted (append (js-var-hoist-forms (js-dedup-names (js-collect-var-names (nth body 1)) (list))) (js-collect-funcdecls (nth body 1)))))
|
||||
(append hoisted (js-transpile-stmt-list (nth body 1))))
|
||||
(list (js-transpile body)))))
|
||||
(list
|
||||
@@ -1401,7 +1598,7 @@
|
||||
(fn
|
||||
(src)
|
||||
(let
|
||||
((result (eval-expr (js-transpile (js-parse (js-tokenize src))))))
|
||||
((result (eval-expr (list (quote let) (list (list (js-sym "this") (list (js-sym "js-this")))) (js-transpile (js-parse (js-tokenize src)))))))
|
||||
(js-drain-microtasks!)
|
||||
result)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user