private void init() { loader = ClojureClassLoaderFactory.newInstance(classPath, outDir); String loadFunctionPrefix = "run_str"; try { String clojureInitScript = String.format(initScriptSource(), beaker_clojure_ns, shellId, loadFunctionPrefix, NSClientProxy.class.getName()); String ns = String.format("%1$s_%2$s", beaker_clojure_ns, shellId); clearClojureNamespace(ns); clojureLoadString = RT.var(ns, String.format("%1$s_%2$s", loadFunctionPrefix, shellId)); clojure.lang.Compiler.load(new StringReader(clojureInitScript)); } catch (Exception e) { logger.error(e.getMessage()); } clojureAutocomplete = new ClojureAutocomplete(clojureLoadString, shellId, autocompletePatterns); }
public static IFn loadClojureFn(String namespace, String name) { try { clojure.lang.Compiler.eval(RT.readString("(require '" + namespace + ")")); } catch (Exception ignored) { // if playing from the repl and defining functions, file won't exist } return (IFn) RT.var(namespace, name).deref(); }
public static IFn loadClojureFn(String namespace, String name) { try { clojure.lang.Compiler.eval(RT.readString("(require '" + namespace + ")")); } catch (Exception e) { // if playing from the repl and defining functions, file won't exist } return (IFn) RT.var(namespace, name).deref(); }
private static synchronized Var getCompiler() { if (compiler == null) { compiler = RT.var("clojure.core", "load-string"); } return compiler; }
/** * Looks up a var by name in the given namespace. * * The var can subsequently be invoked if it is a function. * @param nsName * @param varName * @return */ public static Var var(String nsName, String varName) { return RT.var(nsName,varName); }
public ClojureCompletionWrapper() { try { RT.load("complete"); } catch (IOException e) { throw new RuntimeException("Error: Unable to load complete.clj", e); } catch (ClassNotFoundException e) { throw new RuntimeException("Error: Unable to load complete.clj", e); } this.completions = RT.var("complete", "completions"); }
@Startup public static void launchClojure() { Var require = RT.var("clojure.core", "require"); } }
static public Object instantiate(String implementation) throws Exception { Var require = RT.var("clojure.core", "require"); Var symbol = RT.var("clojure.core", "symbol"); require.invoke(symbol.invoke("clojure.plexus.factory.component-factory")); Var instantiate = RT.var( "clojure.plexus.factory.component-factory", "instantiate"); return instantiate.invoke(implementation); } }
public static void main(String[] args) { Symbol CLOJURE_MAIN = Symbol.intern("clojure.main"); Var REQUIRE = RT.var("clojure.core", "require"); Var MAIN = RT.var("clojure.main", "main"); try { REQUIRE.invoke(CLOJURE_MAIN); MAIN.applyTo(RT.seq(new String[]{})); } catch(Exception e) { e.printStackTrace(); } } }
public VarTester(String ns,String name) { Clojure.require(ns); testVar=RT.var(ns, name); desc=Description.createSuiteDescription(ns + '.' + name); }
public static boolean isClojureVar(Symbol sym) { String ns=sym.getNamespace(); if (ns==null) return false; String name=sym.getName(); return (RT.var(ns, name)!=null); }
private void createNecessaryThreadBindings() { var("user", "input").bindRoot(ioCache.getInputLookupFn()); var("user", "output").bindRoot(ioCache.getOutputLookupFn()); Var.pushThreadBindings(map( var("clojure.core", "*out*"), writer, ns, ns.deref(), output1, null, output2, null, output3, null, lastError, null )); }
public IClojureRepl(final ConsoleReader reader) throws ClassNotFoundException, IOException { String clojureVersion = (String) var("clojure.core", "clojure-version").invoke(); this.clojure1_2 = clojureVersion.startsWith("1.2"); this.reader = reader; this.inputNumber = 0; this.writer = new ConsoleOutputStreamWriter(reader); this.describeHandler = new DescribeJavaObjectHandler(reader); createNecessaryThreadBindings(); createUserNamespace(); this.pst = var("clj-stacktrace.repl", "pst"); reader.addCompleter(new DelegatingCompleter(classFinder)); inputSoFar = new StringBuilder(); }
public static synchronized clojure.lang.IFn loadClojureFn(String namespace, String name) { try { clojure.lang.Compiler.eval(RT.readString("(require '" + namespace + ")")); } catch (Exception e) { //if playing from the repl and defining functions, file won't exist } return (clojure.lang.IFn) RT.var(namespace, name).deref(); }
public static IFn loadClojureFn(String namespace, String name) { try { clojure.lang.Compiler.eval(RT.readString("(require '" + namespace + ")")); } catch (Exception e) { //if playing from the repl and defining functions, file won't exist } return (IFn) RT.var(namespace, name).deref(); }
public static IFn loadClojureFn(String namespace, String name) { try { clojure.lang.Compiler.eval(RT.readString("(require '" + namespace + ")")); } catch (Exception ignored) { // if playing from the repl and defining functions, file won't exist } return (IFn) RT.var(namespace, name).deref(); }
@Override public boolean isMacro() { Var v=RT.var(sym.getNamespace(),sym.getName()); return KissUtils.isTruthy(v.meta().valAt(Keywords.MACRO)); }
@Override public EvalResult interpret(Environment e, IPersistentMap bindings) { try { Var v=RT.var(sym.getNamespace(),sym.getName()); if (v!=null) return e.withResult(v.deref()); } catch (Throwable t) { String err="Error trying to lookp var "+sym+" "; err+=" with Environment "+e.toString(); throw new KissException(err,t); } throw new KissException("Cannot find Clojure symbol "+sym+" in environment"); }