#lang scheme/base
(require scheme/contract
"../compiler/compile.ss"
"../syntax/parse.ss"
"../syntax/sexp.ss")
(provide/contract [eval-compiled-javascript (syntax? namespace? . -> . any)]
[eval-javascript-string (input-source? namespace? . -> . any)]
[eval-function-string (input-source? namespace? . -> . any)]
[eval-javascript (sexp? namespace? . -> . any)])
(define (eval-compiled-javascript stx ns)
(parameterize ([current-namespace ns])
(eval stx)))
(define (eval-javascript-string src ns)
(eval-compiled-javascript (compile-script (parse-script src)) ns))
(define (eval-function-string src ns)
(eval-compiled-javascript (compile-function-expression (parse-function-expression src)) ns))
(define (eval-javascript src ns)
(eval-compiled-javascript (compile-script (list (sexp->SourceElement src))) ns))