(Namespace n, Symbol sym, boolean allowPrivate)
| 7959 | } |
| 7960 | |
| 7961 | static public Object resolveIn(Namespace n, Symbol sym, boolean allowPrivate) { |
| 7962 | //note - ns-qualified vars must already exist |
| 7963 | if(sym.ns != null) |
| 7964 | { |
| 7965 | Namespace ns = namespaceFor(n, sym); |
| 7966 | if(ns == null) |
| 7967 | { |
| 7968 | Class ac = HostExpr.maybeArrayClass(sym); |
| 7969 | if(ac != null) |
| 7970 | return ac; |
| 7971 | throw Util.runtimeException("No such namespace: " + sym.ns); |
| 7972 | } |
| 7973 | |
| 7974 | Var v = ns.findInternedVar(Symbol.intern(sym.name)); |
| 7975 | if(v == null) |
| 7976 | throw Util.runtimeException("No such var: " + sym); |
| 7977 | else if(v.ns != currentNS() && !v.isPublic() && !allowPrivate) |
| 7978 | throw new IllegalStateException("var: " + sym + " is not public"); |
| 7979 | return v; |
| 7980 | } |
| 7981 | else if(sym.name.indexOf('.') > 0 || sym.name.charAt(0) == '[') |
| 7982 | { |
| 7983 | return RT.classForName(sym.name); |
| 7984 | } |
| 7985 | else if(sym.equals(NS)) |
| 7986 | return RT.NS_VAR; |
| 7987 | else if(sym.equals(IN_NS)) |
| 7988 | return RT.IN_NS_VAR; |
| 7989 | else |
| 7990 | { |
| 7991 | if(Util.equals(sym, COMPILE_STUB_SYM.get())) |
| 7992 | return COMPILE_STUB_CLASS.get(); |
| 7993 | Object o = n.getMapping(sym); |
| 7994 | if(o == null) |
| 7995 | { |
| 7996 | if(RT.booleanCast(RT.ALLOW_UNRESOLVED_VARS.deref())) |
| 7997 | { |
| 7998 | return sym; |
| 7999 | } |
| 8000 | else |
| 8001 | { |
| 8002 | throw Util.runtimeException("Unable to resolve symbol: " + sym + " in this context"); |
| 8003 | } |
| 8004 | } |
| 8005 | return o; |
| 8006 | } |
| 8007 | } |
| 8008 | |
| 8009 | |
| 8010 | static public Object maybeResolveIn(Namespace n, Symbol sym) { |
no test coverage detected