got the namespacing stuff to work. can redefine in the repl things that have been defined in the namespace.
This commit is contained in:
parent
e302015fc3
commit
aea7c8dbd0
|
@ -295,7 +295,7 @@
|
|||
(make-PopControlFrame)
|
||||
|
||||
;; We sequester the prefix of the module with the record.
|
||||
(make-Perform (make-FinalizeModuleInvokation! path))
|
||||
(make-Perform (make-FinalizeModuleInvokation! path provides))
|
||||
(make-Goto (make-Reg 'proc))
|
||||
|
||||
after-module-body)))]))
|
||||
|
|
|
@ -516,7 +516,8 @@
|
|||
|
||||
;; Given the module locator, do any finalizing operations, like
|
||||
;; setting up the module namespace.
|
||||
(define-struct: FinalizeModuleInvokation! ([path : ModuleLocator])
|
||||
(define-struct: FinalizeModuleInvokation! ([path : ModuleLocator]
|
||||
[provides : (Listof ModuleProvide)])
|
||||
#:transparent)
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,12 @@
|
|||
(or (and (eq? (ModuleLocator-name locator) '#%kernel)
|
||||
(eq? (ModuleLocator-real-path locator) '#%kernel))
|
||||
(eq? (ModuleLocator-name locator)
|
||||
'whalesong/lang/kernel.rkt)))
|
||||
'whalesong/lang/kernel.rkt)
|
||||
|
||||
;; HACK HACK HACK
|
||||
;; This is for srcloc:
|
||||
(eq? (ModuleLocator-name locator)
|
||||
'collects/racket/private/kernstruct.rkt)))
|
||||
|
||||
|
||||
(: paramz-locator? (ModuleLocator -> Boolean))
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
(format "M.primitives[~s]" (symbol->string (PrimitivesReference-name op)))]
|
||||
|
||||
[(GlobalsReference? op)
|
||||
(format "(M.globals[~s]!==undefined?M.globals[~s]:M.params.currentNamespace.get(~s))"
|
||||
(format "(M.globals[~s]!==void(0)?M.globals[~s]:M.params.currentNamespace.get(~s))"
|
||||
(symbol->string (GlobalsReference-name op))
|
||||
(symbol->string (GlobalsReference-name op))
|
||||
(symbol->string (GlobalsReference-name op)))]))
|
|
@ -1,6 +1,7 @@
|
|||
#lang typed/racket/base
|
||||
(require "assemble-helpers.rkt"
|
||||
"../compiler/il-structs.rkt"
|
||||
"../compiler/expression-structs.rkt"
|
||||
"../compiler/lexical-structs.rkt"
|
||||
"../compiler/kernel-primitives.rkt"
|
||||
"../parameters.rkt"
|
||||
|
@ -22,7 +23,8 @@
|
|||
(add1 (CheckToplevelBound!-depth op))
|
||||
(CheckToplevelBound!-pos op))]
|
||||
[(CheckGlobalBound!? op)
|
||||
(format "if (M.globals[~s]===void(0)){ RT.raiseUnboundToplevelError(M,~s); }"
|
||||
(format "if (M.globals[~s]===void(0)&&M.params.currentNamespace.get(~s)===void(0)){ RT.raiseUnboundToplevelError(M,~s); }"
|
||||
(symbol->string (CheckGlobalBound!-name op))
|
||||
(symbol->string (CheckGlobalBound!-name op))
|
||||
(symbol->string (CheckGlobalBound!-name op)))]
|
||||
|
||||
|
@ -45,7 +47,10 @@
|
|||
[(eq? n #f)
|
||||
"false"]
|
||||
[(GlobalBucket? n)
|
||||
(format "M.globals[~s]" (symbol->string (GlobalBucket-name n)))]
|
||||
(format "M.globals[~s]!==void(0)?M.globals[~s]:M.params.currentNamespace.get(~s)"
|
||||
(symbol->string (GlobalBucket-name n))
|
||||
(symbol->string (GlobalBucket-name n))
|
||||
(symbol->string (GlobalBucket-name n)))]
|
||||
;; FIXME: this should be looking at the module path and getting
|
||||
;; the value here! It shouldn't be looking into Primitives...
|
||||
[(ModuleVariable? n)
|
||||
|
@ -185,6 +190,21 @@
|
|||
(symbol->string (ModuleLocator-name (AliasModuleAsMain!-from op))))]
|
||||
|
||||
[(FinalizeModuleInvokation!? op)
|
||||
(format "M.modules[~s].finalizeModuleInvokation();"
|
||||
(symbol->string
|
||||
(ModuleLocator-name (FinalizeModuleInvokation!-path op))))]))
|
||||
(define modname (symbol->string (ModuleLocator-name (FinalizeModuleInvokation!-path op))))
|
||||
(string-append
|
||||
(format "M.modules[~s].finalizeModuleInvokation();"
|
||||
modname)
|
||||
|
||||
"(function (ns) {"
|
||||
(string-join (for/list: : (Listof String) ([a-provide : ModuleProvide (FinalizeModuleInvokation!-provides op)])
|
||||
(cond [(kernel-module-name? (ModuleProvide-source a-provide))
|
||||
(format "ns.set(~s, M.primitives[~s]);"
|
||||
(symbol->string (ModuleProvide-external-name a-provide))
|
||||
(symbol->string (ModuleProvide-internal-name a-provide)))]
|
||||
[else
|
||||
(format "ns.set(~s, M.modules[~s].getNamespace().get(~s));"
|
||||
(symbol->string (ModuleProvide-external-name a-provide))
|
||||
(symbol->string (ModuleLocator-name (ModuleProvide-source a-provide)))
|
||||
(symbol->string (ModuleProvide-internal-name a-provide)))]))
|
||||
"")
|
||||
(format "}(M.modules[~s].getNamespace()));" modname))]))
|
||||
|
|
|
@ -28,8 +28,11 @@ $(document).ready(function() {
|
|||
console.log("Environment initialized.");
|
||||
afterLanguageInitialization();
|
||||
},
|
||||
function() {
|
||||
function(M, err) {
|
||||
// Nothing should work if we can't get this to work.
|
||||
console.log(M);
|
||||
console.log(err);
|
||||
console.log(err.stack);
|
||||
alert("uh oh!");
|
||||
});
|
||||
};
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
(define ns (make-fresh-namespace))
|
||||
(parameterize ([current-namespace ns])
|
||||
(namespace-attach-module this-namespace language-module-path)
|
||||
(namespace-require language-module-path))
|
||||
(namespace-require/copy language-module-path))
|
||||
ns)
|
||||
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
|
||||
|
||||
|
||||
;(write-repl-runtime-files)
|
||||
(write-repl-runtime-files)
|
||||
(serve/servlet start
|
||||
#:servlet-path "/compile"
|
||||
#:extra-files-paths (list htdocs)
|
||||
|
|
Loading…
Reference in New Issue
Block a user