Created
May 4, 2010 10:57
-
-
Save exterm/389263 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| public static Object eval(Object form) throws Exception{ | |
| boolean createdLoader = false; | |
| if(true)//!LOADER.isBound()) | |
| { | |
| Var.pushThreadBindings(RT.map(LOADER, RT.makeClassLoader())); | |
| createdLoader = true; | |
| } | |
| try | |
| { | |
| if(form instanceof IPersistentCollection | |
| && !(RT.first(form) instanceof Symbol | |
| && ((Symbol) RT.first(form)).name.startsWith("def"))) | |
| { | |
| FnExpr fexpr = (FnExpr) analyze(C.EXPRESSION, RT.list(FN, PersistentVector.EMPTY, form), "eval"); | |
| IFn fn = (IFn) fexpr.eval(); | |
| return fn.invoke(); | |
| } | |
| else | |
| { | |
| Expr expr = analyze(C.EVAL, form); | |
| return expr.eval(); | |
| } | |
| } | |
| catch(Throwable e) | |
| { | |
| if(!(e instanceof CompilerException)) | |
| throw new CompilerException((String) SOURCE.deref(), (Integer) LINE.deref(), e); | |
| else | |
| throw (CompilerException) e; | |
| } | |
| finally | |
| { | |
| if(createdLoader) | |
| Var.popThreadBindings(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment