still working at it.
This commit is contained in:
parent
e4509b0886
commit
4a4f1948b5
|
@ -14,8 +14,27 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var initializeLanguage = function(afterLanguageInitialization) {
|
||||||
|
// Load up the language.
|
||||||
|
plt.runtime.currentMachine.modules['whalesong/lang/whalesong.rkt'].invoke(
|
||||||
|
plt.runtime.currentMachine,
|
||||||
|
function() {
|
||||||
|
console.log("Environment initialized.");
|
||||||
|
afterLanguageInitialization();
|
||||||
|
},
|
||||||
|
function() {
|
||||||
|
// Nothing should work if we can't get this to work.
|
||||||
|
alert("uh oh!");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
repl.attr('disabled', 'true');
|
||||||
|
initializeLanguage(
|
||||||
|
function() {
|
||||||
|
repl.removeAttr('disabled');
|
||||||
// Hook up a simple one-line REPL with enter triggering evaluation.
|
// Hook up a simple one-line REPL with enter triggering evaluation.
|
||||||
$("#repl").keypress(function(e) {
|
repl.keypress(function(e) {
|
||||||
if (e.which == 13 && !repl.attr('disabled')) {
|
if (e.which == 13 && !repl.attr('disabled')) {
|
||||||
var src = repl.val();
|
var src = repl.val();
|
||||||
$(this).val("");
|
$(this).val("");
|
||||||
|
@ -26,6 +45,8 @@ $(document).ready(function() {
|
||||||
repl.val("");});
|
repl.val("");});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
var evaluate = function(src, after) {
|
var evaluate = function(src, after) {
|
||||||
console.log("about to eval", src);
|
console.log("about to eval", src);
|
||||||
|
|
|
@ -11,6 +11,11 @@
|
||||||
web-server/servlet
|
web-server/servlet
|
||||||
"../make/make-structs.rkt"
|
"../make/make-structs.rkt"
|
||||||
"../js-assembler/package.rkt"
|
"../js-assembler/package.rkt"
|
||||||
|
"../repl-compile.rkt"
|
||||||
|
"../parser/parse-bytecode.rkt"
|
||||||
|
"../compiler/compiler.rkt"
|
||||||
|
"../compiler/compiler-structs.rkt"
|
||||||
|
"../js-assembler/assemble.rkt"
|
||||||
"write-runtime.rkt"
|
"write-runtime.rkt"
|
||||||
(for-syntax racket/base))
|
(for-syntax racket/base))
|
||||||
|
|
||||||
|
@ -50,8 +55,25 @@
|
||||||
[else #f]))
|
[else #f]))
|
||||||
;; Compile the program here...
|
;; Compile the program here...
|
||||||
(define program-port (open-output-string))
|
(define program-port (open-output-string))
|
||||||
(cond #;[(not as-mod?)
|
(cond [(not as-mod?)
|
||||||
...]
|
(define ip (open-input-string text-src))
|
||||||
|
(port-count-lines! ip)
|
||||||
|
(define assembled-codes
|
||||||
|
(let loop ()
|
||||||
|
(define sexp (read-syntax #f ip))
|
||||||
|
(cond [(eof-object? sexp)
|
||||||
|
'()]
|
||||||
|
[else
|
||||||
|
(define raw-bytecode (repl-compile sexp #:lang 'whalesong/lang/whalesong))
|
||||||
|
(define op (open-output-bytes))
|
||||||
|
(write raw-bytecode op)
|
||||||
|
(define whalesong-bytecode (parse-bytecode (open-input-bytes (get-output-bytes op))))
|
||||||
|
(define compiled-bytecode (compile whalesong-bytecode 'val next-linkage/drop-multiple))
|
||||||
|
(define assembled-op (open-output-bytes))
|
||||||
|
(define assembled (assemble/write-invoke compiled-bytecode #f assembled-op))
|
||||||
|
(cons (get-output-bytes assembled-op) (loop))])))
|
||||||
|
(printf "assembled codes ~s\n" assembled-codes)
|
||||||
|
(void)]
|
||||||
[else
|
[else
|
||||||
(package (SexpSource (parameterize ([read-accept-reader #t])
|
(package (SexpSource (parameterize ([read-accept-reader #t])
|
||||||
(read (open-input-string (string-append "#lang whalesong\n" text-src)))))
|
(read (open-input-string (string-append "#lang whalesong\n" text-src)))))
|
||||||
|
@ -67,7 +89,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(write-repl-runtime-files)
|
;(write-repl-runtime-files)
|
||||||
(serve/servlet start
|
(serve/servlet start
|
||||||
#:servlet-path "/compile"
|
#:servlet-path "/compile"
|
||||||
#:extra-files-paths (list htdocs)
|
#:extra-files-paths (list htdocs)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user