static Object resolve(Symbol sym, boolean allowPrivate) { return resolveIn(currentNS(), sym, allowPrivate); }
static Namespace namespaceFor(Symbol sym){ return namespaceFor(currentNS(), sym); }
static Object resolve(Symbol sym) { return resolveIn(currentNS(), sym, false); }
else Object o = currentNS().getMapping(sym); if(o instanceof Class) c = (Class) o;
kns = Compiler.namespaceFor(ks); else kns = Compiler.currentNS();
static public class CompilerException extends RuntimeException{ final public String source; final public int line; public CompilerException(String source, int line, int column, Throwable cause){ super(errorMsg(source, line, column, cause.toString()), cause); this.source = source; this.line = line; } public String toString(){ return getMessage(); } }
public static boolean isQualifiedSpecials(){ Namespace n = currentNS(); IPersistentMap mm = n.meta(); return RT.booleanCast(RT.get(mm,qualifiedSpecialsKey)); }
static Symbol resolveSymbol(Symbol sym){ //already qualified or classname? if(sym.name.indexOf('.') > 0) return sym; if(sym.ns != null) { Namespace ns = namespaceFor(sym); if(ns == null || (ns.name.name == null ? sym.ns == null : ns.name.name.equals(sym.ns))) return sym; return Symbol.intern(ns.name.name, sym.name); } Object o = currentNS().getMapping(sym); if(o == null) return Symbol.intern(currentNS().name.name, sym.name); else if(o instanceof Class) return Symbol.intern(null, ((Class) o).getName()); else if(o instanceof Var) { Var v = (Var) o; return Symbol.intern(v.ns.name.name, v.sym.name); } return null; }
static public Var isMacro(Object op) { //no local macros for now if(op instanceof Symbol && referenceLocal((Symbol) op) != null) return null; if(op instanceof Symbol || op instanceof Var) { Var v = (op instanceof Var) ? (Var) op : lookupVar((Symbol) op, false, false); if(v != null && v.isMacro()) { if(v.ns != currentNS() && !v.isPublic()) throw new IllegalStateException("var: " + v + " is not public"); return v; } } return null; }
return Reflector.invokeStaticMethod(fs.ns, fs.name, args); Object v = Compiler.maybeResolveIn(Compiler.currentNS(), fs); if(v instanceof Var)
else Object o = currentNS().getMapping(sym); if(o instanceof Class) c = (Class) o;
static public IFn isInline(Object op, int arity) { //no local inlines for now if(op instanceof Symbol && referenceLocal((Symbol) op) != null) return null; if(op instanceof Symbol || op instanceof Var) { Var v = (op instanceof Var) ? (Var) op : lookupVar((Symbol) op, false); if(v != null) { if(v.ns != currentNS() && !v.isPublic()) throw new IllegalStateException("var: " + v + " is not public"); IFn ret = (IFn) RT.get(v.meta(), inlineKey); if(ret != null) { IFn arityPred = (IFn) RT.get(v.meta(), inlineAritiesKey); if(arityPred == null || RT.booleanCast(arityPred.invoke(arity))) return ret; } } } return null; }
public Expr parse(C context, Object frm) { //(reify this-name? [interfaces] (method-name [args] body)*) ISeq form = (ISeq) frm; ObjMethod enclosingMethod = (ObjMethod) METHOD.deref(); String basename = enclosingMethod != null ? (trimGenID(enclosingMethod.objx.name) + "$") : (munge(currentNS().name.name) + "$"); String simpleName = "reify__" + RT.nextID(); String classname = basename + simpleName; ISeq rform = RT.next(form); IPersistentVector interfaces = ((IPersistentVector) RT.first(rform)).cons(Symbol.intern("clojure.lang.IObj")); rform = RT.next(rform); ObjExpr ret = build(interfaces, null, null, classname, Symbol.intern(classname), null, rform, frm); if(frm instanceof IObj && ((IObj) frm).meta() != null) return new MetaExpr(ret, MapExpr .parse(context == C.EVAL ? context : C.EXPRESSION, ((IObj) frm).meta())); else return ret; } }
return Reflector.invokeStaticMethod(fs.ns, fs.name, args); Object v = Compiler.maybeResolveIn(Compiler.currentNS(), fs); if(v instanceof Var)
if(v == null) throw Util.runtimeException("No such var: " + sym); else if(v.ns != currentNS() && !v.isPublic() && !allowPrivate) throw new IllegalStateException("var: " + sym + " is not public"); return v;
(enclosingMethod.objx.name + "$") (munge(currentNS().name.name) + "$"); if(RT.second(form) instanceof Symbol) name = ((Symbol) RT.second(form)).name;
static Object syntaxQuote(Object form) { Object ret; if(form instanceof Symbol) { if(Compiler.isQualifiedSpecial(form) || ((Compiler.currentNS().getMapping((Symbol)form) == null) && (Compiler.isSpecial(form)))) ret = RT.list(Compiler.QUOTE, form); else { maybeClass = Compiler.currentNS().getMapping( Symbol.intern(null, sym.ns)); if(maybeClass instanceof Class)
public Expr parse(C context, Object frm) { //(reify this-name? [interfaces] (method-name [args] body)*) ISeq form = (ISeq) frm; ObjMethod enclosingMethod = (ObjMethod) METHOD.deref(); String basename = enclosingMethod != null ? (trimGenID(enclosingMethod.objx.name) + "$") : (munge(currentNS().name.name) + "$"); String simpleName = "reify__" + RT.nextID(); String classname = basename + simpleName; ISeq rform = RT.next(form); IPersistentVector interfaces = ((IPersistentVector) RT.first(rform)).cons(Symbol.intern("clojure.lang.IObj")); rform = RT.next(rform); ObjExpr ret = build(interfaces, null, null, classname, Symbol.intern(classname), null, rform, frm); if(frm instanceof IObj && ((IObj) frm).meta() != null) return new MetaExpr(ret, MapExpr .parse(context == C.EVAL ? context : C.EXPRESSION, ((IObj) frm).meta())); else return ret; } }