-
Notifications
You must be signed in to change notification settings - Fork 791
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support code reflection in the cljs repl.
A few changes have been made to support runtime code reflection in a cljs repl. These include small changes to cljs.analyzer, a separation of the server element of cljs.repl.browser into cljs.repl.server, and the addition of two new namespaces: cljs.repl.reflect (in src/clj) and clojure.reflect (in src/cljs). cljs.analyzer: - Arbitrary metadata declared on symbols will now be added to the AST. This supports the addition of docstrings. - Fix a subtle bug in cljs.analyzer/analyze-file, where an uncommon code-path would lead to the failed coercion of an absolute-path into a URL. An absolute path, including a `file://` protocol, can now be passed into the function successfully. cljs.repl: - Add function to analyze source on repl-env -setup. This is used to support reflection on user-defined cljs source files, as well as to populate the cljs.analyzer/namespaces atom on repl startup. cljs.repl.browser: - The server element of this namespace has been factored out into cljs.repl.server to support other services that may require that functionality. cljs.repl.server: - Expose a simple HTTP method and predicate dispatch system to register handler functions for incoming requests. (Note: this system seems to be relatively brittle, and future change may be warranted.) cljs.repl.reflect: - Registers a server handler for incoming requests to "/reflect". - Queries cljs.analyzer/namespaces for meta information relevant to a symbol, responding to requests with compiled javascript. - Can use "fixed point" macroexpansion on cljs macro forms. clojure.reflect: - Expose a set of simple functions for querying meta information of a symbol, as well as macroexpanding a cljs form.
- Loading branch information
1 parent
0f73237
commit b5b20fd
Showing
9 changed files
with
377 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ closure | |
/coresimple.js | ||
/out | ||
.repl | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
|
||
if [ "$CLOJURESCRIPT_HOME" = "" ]; then | ||
CLOJURESCRIPT_HOME="`dirname $0`/.." | ||
fi | ||
|
||
CLJSC_CP='' | ||
for next in lib/*: src/clj: src/cljs: test/cljs; do | ||
CLJSC_CP=$CLJSC_CP$CLOJURESCRIPT_HOME'/'$next | ||
done | ||
|
||
java -server -cp $CLJSC_CP clojure.main -e " | ||
(require '[cljs.repl :as r]) | ||
(require '[cljs.repl.browser :as b]) | ||
(r/repl (b/repl-env)) | ||
" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.