public FnLoaderThunk(Var v, String fnClassName){ this.v = v; this.loader = (ClassLoader) RT.FN_LOADER_VAR.get(); this.fnClassName = fnClassName; fn = null; }
public FnLoaderThunk(Var v, String fnClassName){ this.v = v; this.loader = (ClassLoader) RT.FN_LOADER_VAR.get(); this.fnClassName = fnClassName; fn = null; }
static LocalBinding referenceLocal(Symbol sym) { if(!LOCAL_ENV.isBound()) return null; LocalBinding b = (LocalBinding) RT.get(LOCAL_ENV.deref(), sym); if(b != null) { ObjMethod method = (ObjMethod) METHOD.deref(); closeOver(b, method); } return b; }
static PathNode clearPathRoot(){ return (PathNode) CLEAR_ROOT.get(); }
.... public void fromJson(String json){ //(real-code)--start //Var var = Djson.parse(json); //(real-code)--end //--test-code--start Var var = null; try { var = Djson.parse(new File("d:\\j1.txt")); } catch (IOException e) { e.printStackTrace(); } //--test-code--end this.dealedNum = var.get("dealedNum").toInt(); this.nextRequestDelay = var.get("nextRequestDelay").toString(); this.percent = var.get("percent").toString(); this.filterNum = var.get("filterNum").toInt(); this.dealedBillNum = var.get("dealedBillNum").toInt(); for(int i=0; i<var.get("mails").size(); i++) { this.mails.add(var.get("mails").get(i).toObject()); // MAP type setting... } }
Var hotels = Djson.parse(new File("d:\\sample1.txt")).find("[0].hotels"); for(int i=0; i<hotels.size(); i++) { System.out.println(hotels.get(i).get("name").toString()); System.out.println(hotels.get(i).get("starRating").toInt()); System.out.println(hotels.get(i).find("geoPoint").get(0).toDouble()); // case1) basic System.out.println(hotels.get(i).find("geoPoint[1]").toDouble()); // case2) find() System.out.println(); }
mappings = mappings.assoc(RT.CURRENT_NS, RT.CURRENT_NS.get()); mappings = mappings.assoc(RT.OUT, newRtOut); mappings = mappings.assoc(RT.ERR, newRtOut);
mappings = mappings.assoc(RT.CURRENT_NS, RT.CURRENT_NS.get()); mappings = mappings.assoc(RT.OUT, newRtOut); mappings = mappings.assoc(RT.ERR, newRtOut);
HashMap<Integer,Expr> thens = new HashMap(); PathNode branch = new PathNode(PATHTYPE.BRANCH, (PathNode) CLEAR_PATH.get());
else if(form.count() < 3) throw Util.runtimeException("Too few arguments to if"); PathNode branch = new PathNode(PATHTYPE.BRANCH, (PathNode) CLEAR_PATH.get()); Expr testexpr = analyze(context == C.EVAL ? context : C.EXPRESSION, RT.second(form)); Expr thenexpr, elseexpr;
public Model read(final Reader input, final Map<String, ?> options) throws IOException { assert input != null; try { String location = PolyglotModelUtil.getLocation(options); final Var USE = Var.intern(RT.CLOJURE_NS, Symbol.create("use")); final Symbol READER = Symbol.create("org.sonatype.maven.polyglot.clojure.dsl.reader"); final Symbol LEININGEN = Symbol.create("org.sonatype.maven.polyglot.clojure.dsl.leiningen"); USE.invoke(READER); USE.invoke(LEININGEN); clojure.lang.Compiler.load(input, location, location); final Var MODEL = Var.intern(Namespace.findOrCreate(READER), Symbol.create("*MODEL*")); return (Model) ((Atom) MODEL.get()).deref(); } catch (Exception e) { // Don't use new IOException(e) because it doesn't exist in Java 5 throw (IOException) new IOException(e.toString()).initCause(e); } } }
HashMap<Integer,Expr> thens = new HashMap(); PathNode branch = new PathNode(PATHTYPE.BRANCH, (PathNode) CLEAR_PATH.get());
sym, SOURCE_PATH.get(), LINE.get()); v.setMeta(vm); Object source_path = SOURCE_PATH.get(); source_path = source_path == null ? "NO_SOURCE_FILE" : source_path; mm = (IPersistentMap) RT.assoc(mm, RT.LINE_KEY, LINE.get()).assoc(RT.COLUMN_KEY, COLUMN.get()).assoc(RT.FILE_KEY, source_path); if (docstring != null) mm = (IPersistentMap) RT.assoc(mm, RT.DOC_KEY, docstring);
else if(form.count() < 3) throw Util.runtimeException("Too few arguments to if"); PathNode branch = new PathNode(PATHTYPE.BRANCH, (PathNode) CLEAR_PATH.get()); Expr testexpr = analyze(context == C.EVAL ? context : C.EXPRESSION, RT.second(form)); Expr thenexpr, elseexpr;
throw Util.runtimeException("Can't take value of a macro: " + v); if(RT.booleanCast(RT.get(v.meta(),RT.CONST_KEY))) return analyze(C.EXPRESSION, RT.list(QUOTE, v.get())); registerVar(v); return new VarExpr(v, tag);