still working at it.

This commit is contained in:
Danny Yoo 2013-02-28 17:53:27 -07:00
parent e4509b0886
commit 4a4f1948b5
2 changed files with 59 additions and 16 deletions

View File

@ -14,18 +14,39 @@ $(document).ready(function() {
}
// Hook up a simple one-line REPL with enter triggering evaluation.
$("#repl").keypress(function(e) {
if (e.which == 13 && !repl.attr('disabled')) {
var src = repl.val();
$(this).val("");
repl.attr('disabled', 'true');
repl.val("... evaluating...");
evaluate(src,
function() { repl.removeAttr('disabled');
repl.val("");});
}
});
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.
repl.keypress(function(e) {
if (e.which == 13 && !repl.attr('disabled')) {
var src = repl.val();
$(this).val("");
repl.attr('disabled', 'true');
repl.val("... evaluating...");
evaluate(src,
function() { repl.removeAttr('disabled');
repl.val("");});
}
});
});
var evaluate = function(src, after) {
console.log("about to eval", src);

View File

@ -11,6 +11,11 @@
web-server/servlet
"../make/make-structs.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"
(for-syntax racket/base))
@ -50,8 +55,25 @@
[else #f]))
;; Compile the program here...
(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
(package (SexpSource (parameterize ([read-accept-reader #t])
(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
#:servlet-path "/compile"
#:extra-files-paths (list htdocs)