public GetMapping ( |
||
name | The symbol to look up. | |
리턴 | object |
// core.clj compatibility public static object maybeResolveIn(Namespace n, Symbol symbol) { // note: ns-qualified vars must already exist if (symbol.Namespace != null) { Namespace ns = NamespaceFor(n, symbol); if (ns == null) return null; Var v = ns.FindInternedVar(Symbol.create(symbol.Name)); if (v == null) return null; return v; } else if (symbol.Name.IndexOf('.') > 0 || symbol.Name[0] == '[') return RT.classForName(symbol.Name); else if (symbol.Equals(NS)) return RT.NS_VAR; else if (symbol.Equals(IN_NS)) return RT.IN_NS_VAR; else { object o = n.GetMapping(symbol); return o; } }
public static object maybeResolveIn(Namespace n, Symbol symbol) { // note: ns-qualified vars must already exist if (symbol.Namespace != null) { Namespace ns = namespaceFor(n, symbol); if (ns == null) return null; Var v = ns.FindInternedVar(Symbol.intern(symbol.Name)); if (v == null) return null; return v; } else if (symbol.Name.IndexOf('.') > 0 && !symbol.Name.EndsWith(".") || symbol.Name[symbol.Name.Length - 1] == ']') /// JAVA: symbol.Name[0] == '[') return RT.classForNameE(symbol.Name); else if (symbol.Equals(NsSym)) return RT.NSVar; else if (symbol.Equals(InNsSym)) return RT.InNSVar; else { object o = n.GetMapping(symbol); return o; } }
private static object ResolveIn(Namespace n, Symbol symbol, bool allowPrivate) { // note: ns-qualified vars must already exist if (symbol.Namespace != null) { Namespace ns = NamespaceFor(n, symbol); if (ns == null) throw new Exception("No such namespace: " + symbol.Namespace); Var v = ns.FindInternedVar(Symbol.create(symbol.Name)); if (v == null) throw new Exception("No such var: " + symbol); else if (v.Namespace != CurrentNamespace && !v.IsPublic && !allowPrivate) throw new InvalidOperationException(string.Format("var: {0} is not public", symbol)); return v; } else if (symbol.Name.IndexOf('.') > 0 || symbol.Name[0] == '[') return RT.classForName(symbol.Name); else if (symbol.Equals(NS)) return RT.NS_VAR; else if (symbol.Equals(IN_NS)) return RT.IN_NS_VAR; else { object o = n.GetMapping(symbol); if (o == null) { if (RT.booleanCast(RT.ALLOW_UNRESOLVED_VARS.deref())) return symbol; else throw new Exception(string.Format("Unable to resolve symbol: {0} in this context", symbol)); } return o; } }
private static object ResolveIn(Namespace n, Symbol symbol, bool allowPrivate) { // note: ns-qualified vars must already exist if (symbol.Namespace != null) { Namespace ns = namespaceFor(n, symbol); if (ns == null) throw new InvalidOperationException("No such namespace: " + symbol.Namespace); Var v = ns.FindInternedVar(Symbol.intern(symbol.Name)); if (v == null) throw new InvalidOperationException("No such var: " + symbol); else if (v.Namespace != CurrentNamespace && !v.isPublic && !allowPrivate) throw new InvalidOperationException(string.Format("var: {0} is not public", symbol)); return v; } else if (symbol.Name.IndexOf('.') > 0 || symbol.Name[symbol.Name.Length - 1] == ']') return RT.classForNameE(symbol.Name); else if (symbol.Equals(NsSym)) return RT.NSVar; else if (symbol.Equals(InNsSym)) return RT.InNSVar; else { if (Util.equals(symbol, CompileStubSymVar.get())) return CompileStubClassVar.get(); object o = n.GetMapping(symbol); if (o == null) { if (RT.booleanCast(RT.AllowUnresolvedVarsVar.deref())) return symbol; else throw new InvalidOperationException(string.Format("Unable to resolve symbol: {0} in this context", symbol)); } return o; } }