MCPcopy Index your code
hub / github.com/clojure/clojure / analyzeSymbol

Method analyzeSymbol

src/jvm/clojure/lang/Compiler.java:7865–7920  ·  view source on GitHub ↗
(Symbol sym)

Source from the content-addressed store, hash-verified

7863}
7864
7865private static Expr analyzeSymbol(Symbol sym) {
7866 Symbol tag = tagOf(sym);
7867 if(sym.ns == null) //ns-qualified syms are always Vars
7868 {
7869 LocalBinding b = referenceLocal(sym);
7870 if(b != null)
7871 {
7872 return new LocalBindingExpr(b, tag);
7873 }
7874 }
7875 else
7876 {
7877 if(namespaceFor(sym) == null && !Util.isPosDigit(sym.name))
7878 {
7879 Symbol nsSym = Symbol.intern(sym.ns);
7880 Class c = HostExpr.maybeClass(nsSym, false);
7881 if(c != null)
7882 {
7883 if(Reflector.getField(c, sym.name, true) != null)
7884 {
7885 List<Executable> maybeOverloads = QualifiedMethodExpr.methodOverloads(c, sym.name, QualifiedMethodExpr.MethodKind.STATIC);
7886
7887 if(maybeOverloads.isEmpty())
7888 return new StaticFieldExpr(lineDeref(), columnDeref(), c, sym.name, tag);
7889 else
7890 return new QualifiedMethodExpr(c, sym, new StaticFieldExpr(lineDeref(), columnDeref(), c, sym.name, tag));
7891 }
7892 else
7893 return new QualifiedMethodExpr(c, sym);
7894 }
7895
7896 }
7897 }
7898 //Var v = lookupVar(sym, false);
7899// Var v = lookupVar(sym, false);
7900// if(v != null)
7901// return new VarExpr(v, tag);
7902 Object o = resolve(sym);
7903 if(o instanceof Var)
7904 {
7905 Var v = (Var) o;
7906 if(isMacro(v) != null)
7907 throw Util.runtimeException("Can't take value of a macro: " + v);
7908 if(RT.booleanCast(RT.get(v.meta(),RT.CONST_KEY)))
7909 return analyze(C.EXPRESSION, RT.list(QUOTE, v.get()));
7910 registerVar(v);
7911 return new VarExpr(v, tag);
7912 }
7913 else if(o instanceof Class)
7914 return new ConstantExpr(o);
7915 else if(o instanceof Symbol)
7916 return new UnresolvedVarExpr((Symbol) o);
7917
7918 throw Util.runtimeException("Unable to resolve symbol: " + sym + " in this context");
7919
7920}
7921
7922static String destubClassName(String className){

Callers 1

analyzeMethod · 0.95

Calls 15

tagOfMethod · 0.95
referenceLocalMethod · 0.95
namespaceForMethod · 0.95
isPosDigitMethod · 0.95
internMethod · 0.95
maybeClassMethod · 0.95
getFieldMethod · 0.95
methodOverloadsMethod · 0.95
lineDerefMethod · 0.95
columnDerefMethod · 0.95
resolveMethod · 0.95
isMacroMethod · 0.95

Tested by

no test coverage detected