public Expr parse(C context, Object frm) { ISeq form = (ISeq) frm; if(RT.length(form) != 3) throw new IllegalArgumentException("Malformed assignment, expecting (set! target val)"); Expr target = analyze(C.EXPRESSION, RT.second(form)); if(!(target instanceof AssignableExpr)) throw new IllegalArgumentException("Invalid assignment target"); return new AssignExpr((AssignableExpr) target, analyze(C.EXPRESSION, RT.third(form))); } }
public Expr parse(C context, Object form) { return new MonitorEnterExpr(analyze(C.EXPRESSION, RT.second(form))); } }
public Expr parse(C context, Object form) { return new MonitorEnterExpr(analyze(C.EXPRESSION, RT.second(form))); } }
public Expr parse(C context, Object form) { return new MonitorExitExpr(analyze(C.EXPRESSION, RT.second(form))); } }
public Expr parse(C context, Object form) { return new MonitorExitExpr(analyze(C.EXPRESSION, RT.second(form))); } }
public Expr parse(C context, Object frm) { int line = (Integer) LINE.deref(); int column = (Integer) COLUMN.deref(); ISeq form = (ISeq) frm; //(new Classname args...) if(form.count() < 2) throw Util.runtimeException("wrong number of arguments, expecting: (new Classname args...)"); Class c = HostExpr.maybeClass(RT.second(form), false); if(c == null) throw new IllegalArgumentException("Unable to resolve classname: " + RT.second(form)); PersistentVector args = PersistentVector.EMPTY; for(ISeq s = RT.next(RT.next(form)); s != null; s = s.next()) args = args.cons(analyze(context == C.EVAL ? context : C.EXPRESSION, s.first())); return new NewExpr(c, args, line, column); } }
static public Expr parse(C context, IPersistentVector form) { boolean constant = true; IPersistentVector args = PersistentVector.EMPTY; for(int i = 0; i < form.count(); i++) { Expr v = analyze(context == C.EVAL ? context : C.EXPRESSION, form.nth(i)); args = (IPersistentVector) args.cons(v); if(!(v instanceof LiteralExpr)) constant = false; } Expr ret = new VectorExpr(args); if(form instanceof IObj && ((IObj) form).meta() != null) return new MetaExpr(ret, MapExpr .parse(context == C.EVAL ? context : C.EXPRESSION, ((IObj) form).meta())); else if (constant) { PersistentVector rv = PersistentVector.EMPTY; for(int i =0;i<args.count();i++) { LiteralExpr ve = (LiteralExpr)args.nth(i); rv = rv.cons(ve.val()); } // System.err.println("Constant: " + rv); return new ConstantExpr(rv); } else return ret; }
public Expr parse(C context, Object frms) { ISeq forms = (ISeq) frms; if(Util.equals(RT.first(forms), DO) || Util.equals(RT.first(forms), QDO)) forms = RT.next(forms); PersistentVector exprs = PersistentVector.EMPTY; for(; forms != null; forms = forms.next()) { Expr e = (context != C.EVAL && (context == C.STATEMENT || forms.next() != null)) ? analyze(C.STATEMENT, forms.first()) : analyze(context, forms.first()); exprs = exprs.cons(e); } if(exprs.count() == 0) exprs = exprs.cons(NIL_EXPR); return new BodyExpr(exprs); } }
public Expr parse(C context, Object frm) { int line = lineDeref(); int column = columnDeref(); ISeq form = (ISeq) frm; //(new Classname args...) if(form.count() < 2) throw Util.runtimeException("wrong number of arguments, expecting: (new Classname args...)"); Class c = HostExpr.maybeClass(RT.second(form), false); if(c == null) throw new IllegalArgumentException("Unable to resolve classname: " + RT.second(form)); PersistentVector args = PersistentVector.EMPTY; for(ISeq s = RT.next(RT.next(form)); s != null; s = s.next()) args = args.cons(analyze(context == C.EVAL ? context : C.EXPRESSION, s.first())); return new NewExpr(c, args, line, column); } }
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; try { Var.pushThreadBindings( RT.map(CLEAR_PATH, new PathNode(PATHTYPE.PATH,branch))); thenexpr = analyze(context, RT.third(form)); Var.pushThreadBindings( RT.map(CLEAR_PATH, new PathNode(PATHTYPE.PATH,branch))); elseexpr = analyze(context, RT.fourth(form));
Expr expr = analyze(context == C.EVAL ? context : C.EXPRESSION, e); keys = (IPersistentVector) keys.cons(expr); if(!(expr instanceof LiteralExpr))
static public Expr parse(C context, IPersistentVector form) { boolean constant = true; IPersistentVector args = PersistentVector.EMPTY; for(int i = 0; i < form.count(); i++) { Expr v = analyze(context == C.EVAL ? context : C.EXPRESSION, form.nth(i)); args = (IPersistentVector) args.cons(v); if(!(v instanceof LiteralExpr)) constant = false; } Expr ret = new VectorExpr(args); if(form instanceof IObj && ((IObj) form).meta() != null) return new MetaExpr(ret, MapExpr .parse(context == C.EVAL ? context : C.EXPRESSION, ((IObj) form).meta())); else if (constant) { PersistentVector rv = PersistentVector.EMPTY; for(int i =0;i<args.count();i++) { LiteralExpr ve = (LiteralExpr)args.nth(i); rv = rv.cons(ve.val()); } // System.err.println("Constant: " + rv); return new ConstantExpr(rv); } else return ret; }
Expr expr = analyze(context == C.EVAL ? context : C.EXPRESSION, e); keys = (IPersistentVector) keys.cons(expr); if(!(expr instanceof LiteralExpr))
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);
Expr expr = analyze(C.EVAL, form); objx.keywords = (IPersistentMap) KEYWORDS.deref(); objx.vars = (IPersistentMap) VARS.deref();