need to make quite a few changes to get repl to work.
This commit is contained in:
parent
a5fb4e26d0
commit
ce653948cc
|
@ -399,9 +399,10 @@ M.modules[~s] =
|
|||
window.console.log('loaded ' + ~s);
|
||||
}
|
||||
},
|
||||
function(err) {
|
||||
function(M, err) {
|
||||
if (window.console && window.console.log) {
|
||||
window.console.log('error: unable to load ' + ~s);
|
||||
if (err && err.stack) { console.log(err.stack); }
|
||||
}
|
||||
},
|
||||
{});"
|
||||
|
|
|
@ -1229,6 +1229,7 @@
|
|||
exports['raiseOperatorApplicationError'] = raiseOperatorApplicationError;
|
||||
exports['raiseOperatorIsNotPrimitiveProcedure'] = raiseOperatorIsNotPrimitiveProcedure;
|
||||
exports['raiseUnimplementedPrimitiveError'] = raiseUnimplementedPrimitiveError;
|
||||
exports['raiseModuleLoadingError'] = raiseModuleLoadingError;
|
||||
|
||||
|
||||
exports['finalizeClosureCall'] = finalizeClosureCall;
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
<body>
|
||||
<h1>Repl experiment</h1>
|
||||
|
||||
<div id="output"></div>
|
||||
<br/>
|
||||
<input id="repl" type="text" style="width:500px"></input>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
var COMPILED = [];
|
||||
|
||||
$(document).ready(function() {
|
||||
"use strict";
|
||||
|
||||
var repl = $("#repl");
|
||||
// Hook up a simple one-line REPL with enter triggering evaluation.
|
||||
$("#repl").keypress(function(e) {
|
||||
if (e.which == 13) {
|
||||
var repl = $(this);
|
||||
if (e.which == 13 && !repl.attr('disabled')) {
|
||||
var src = repl.val();
|
||||
$(this).val("");
|
||||
repl.attr('disabled', 'true');
|
||||
|
@ -19,9 +21,13 @@ $(document).ready(function() {
|
|||
console.log("about to eval", src);
|
||||
var onCompile = function(compiledResult) {
|
||||
console.log("compilation got", compiledResult);
|
||||
COMPILED.push(compiledResult);
|
||||
eval(compiledResult.compiled);
|
||||
// FIXME
|
||||
plt.runtime.currentMachine.modules['whalesong/repl-prototype/anonymous-module.rkt'].invoke();
|
||||
after();
|
||||
};
|
||||
var onError = function(x) {
|
||||
var onError = function(err) {
|
||||
console.log("error", err);
|
||||
after();
|
||||
};
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
file/gzip
|
||||
racket/runtime-path
|
||||
racket/port
|
||||
racket/match
|
||||
web-server/servlet-env
|
||||
web-server/servlet
|
||||
"../make/make-structs.rkt"
|
||||
"../js-assembler/package.rkt"
|
||||
"write-runtime.rkt"
|
||||
(for-syntax racket/base))
|
||||
|
||||
|
@ -40,13 +43,26 @@
|
|||
(define (start req)
|
||||
(define-values (response op)
|
||||
(make-port-response #:mime-type #"text/json"))
|
||||
(define source (extract-binding/single 'src (request-bindings req)))
|
||||
|
||||
(printf "program is: ~s\n" source)
|
||||
(define text-src (extract-binding/single 'src (request-bindings req)))
|
||||
(define as-mod? (match (extract-bindings 'm (request-bindings req))
|
||||
[(list (or "t" "true"))
|
||||
#t]
|
||||
[else #f]))
|
||||
;; Compile the program here...
|
||||
(define program-port (open-output-string))
|
||||
(cond #;[(not as-mod?)
|
||||
...]
|
||||
[else
|
||||
(package (SexpSource (parameterize ([read-accept-reader #t])
|
||||
(read (open-input-string (string-append "#lang whalesong\n" text-src)))))
|
||||
#:should-follow-children? (lambda (src) #f)
|
||||
#:output-port program-port)
|
||||
])
|
||||
;; Send it back as json text....
|
||||
(write-json '(1 2 3) op)
|
||||
(write-json (hash 'compiled (get-output-string program-port))
|
||||
op)
|
||||
(close-output-port op)
|
||||
(printf "done\n")
|
||||
response)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user