trying to teach the make system about javascript-implemented modules.

This commit is contained in:
Danny Yoo 2011-06-09 12:43:36 -04:00
parent 51490ec16b
commit f79886060c
5 changed files with 46 additions and 8 deletions

7
NOTES
View File

@ -738,4 +738,9 @@ I should add the functions:
get-viewport-width get-viewport-width
get-viewport-height get-viewport-height
Other notes from Shriram: too slow, inconsistent positioning from jsworld. Other notes from Shriram: too slow, inconsistent positioning from jsworld.
----------------------------------------------------------------------
Added base as the default planet language.

4
README
View File

@ -17,8 +17,6 @@ amount of time.
Example usage Example usage
[TODO: make this a reality... The lang line would preferably be
#lang planet dyoo/whalesong]
Create a simple, standalong executable of your program. At the Create a simple, standalong executable of your program. At the
@ -27,7 +25,7 @@ moment, the program must be written in the base language of whalesong.
from compiling, and we'll be working to remove this restriction.) from compiling, and we'll be working to remove this restriction.)
$ cat hello.rkt $ cat hello.rkt
#lang s-exp "lang/base.rkt" #lang planet dyoo/whalesong
(display "hello world") (display "hello world")
(newline) (newline)

View File

@ -5,6 +5,7 @@
"../make/make.rkt" "../make/make.rkt"
"../make/make-structs.rkt" "../make/make-structs.rkt"
"../parameters.rkt" "../parameters.rkt"
"../lang/js/query.rkt"
(planet dyoo/closure-compile:1:1) (planet dyoo/closure-compile:1:1)
(prefix-in runtime: "get-runtime.rkt") (prefix-in runtime: "get-runtime.rkt")
(prefix-in racket: racket/base)) (prefix-in racket: racket/base))
@ -38,6 +39,19 @@
;; source-is-javascript-module?: Source -> (or Source #f)
(define (source-is-javascript-module? src)
(cond
[(StatementsSource? src)
src]
[(MainModuleSource? src)
src]
[(ModuleSource? src)
src]
[(SexpSource? src)
src]
[(UninterpretedSource? src)
src]))
@ -59,15 +73,32 @@
;; wrap-source: source -> source ;; wrap-source: source -> source
(define (wrap-source src) (define (wrap-source src)
(printf "adding ~s\n" src) (printf "adding ~s\n" src)
src) (cond
[(source-is-javascript-module? src)
=>
(lambda (wrapped-src)
wrapped-src)]
[else
src]))
(define (on-visit-src src ast stmts) (define (on-visit-src src ast stmts)
(assemble/write-invoke stmts op) (cond
(fprintf op "(MACHINE, function() { ")) [(UninterpretedSource? src)
;; FIXME
(void)]
[else
(assemble/write-invoke stmts op)
(fprintf op "(MACHINE, function() { ")]))
(define (after-visit-src src ast stmts) (define (after-visit-src src ast stmts)
(fprintf op " }, FAIL, PARAMS);")) (cond
[(UninterpretedSource? src)
;; FIXME
(void)]
[else
(fprintf op " }, FAIL, PARAMS);")]))
(define (on-last-src) (define (on-last-src)

View File

@ -85,6 +85,7 @@
[program (second javascript-compiler+program)]) [program (second javascript-compiler+program)])
(with-handlers ([exn:fail? (lambda (exn) (with-handlers ([exn:fail? (lambda (exn)
(displayln exn)
(let ([sentinel (let ([sentinel
(format (format
#<<EOF #<<EOF

3
world.rkt Normal file
View File

@ -0,0 +1,3 @@
#lang s-exp "lang/base.rkt"
(require "world/main.rkt")
(provide (all-from-out "world/main.rkt"))