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

Method parse

src/jvm/clojure/lang/Compiler.java:962–1019  ·  view source on GitHub ↗
(C context, Object frm)

Source from the content-addressed store, hash-verified

960
961 static class Parser implements IParser{
962 public Expr parse(C context, Object frm) {
963 ISeq form = (ISeq) frm;
964 //(. x fieldname-sym) or
965 //(. x 0-ary-method)
966 // (. x methodname-sym args+)
967 // (. x (methodname-sym args?))
968 if(RT.length(form) < 3)
969 throw new IllegalArgumentException("Malformed member expression, expecting (. target member ...)");
970 //determine static or instance
971 //static target must be symbol, either fully.qualified.Classname or Classname that has been imported
972 int line = lineDeref();
973 int column = columnDeref();
974 String source = (String) SOURCE.deref();
975 Class c = maybeClass(RT.second(form), false);
976 //at this point c will be non-null if static
977 Expr instance = null;
978 if(c == null)
979 instance = analyze(context == C.EVAL ? context : C.EXPRESSION, RT.second(form));
980
981 boolean maybeField = RT.length(form) == 3 && (RT.third(form) instanceof Symbol);
982
983 if(maybeField && !(((Symbol)RT.third(form)).name.charAt(0) == '-'))
984 {
985 Symbol sym = (Symbol) RT.third(form);
986 if(c != null)
987 maybeField = Reflector.getMethods(c, 0, munge(sym.name), true).size() == 0;
988 else if(instance != null && instance.hasJavaClass() && instance.getJavaClass() != null)
989 maybeField = Reflector.getMethods(instance.getJavaClass(), 0, munge(sym.name), false).size() == 0;
990 }
991
992 if(maybeField) //field
993 {
994 Symbol sym = (((Symbol)RT.third(form)).name.charAt(0) == '-') ?
995 Symbol.intern(((Symbol)RT.third(form)).name.substring(1))
996 :(Symbol) RT.third(form);
997 Symbol tag = tagOf(form);
998 if(c != null) {
999 return new StaticFieldExpr(line, column, c, munge(sym.name), tag);
1000 } else
1001 return new InstanceFieldExpr(line, column, instance, munge(sym.name), tag, (((Symbol)RT.third(form)).name.charAt(0) == '-'));
1002 }
1003 else
1004 {
1005 ISeq call = (ISeq) ((RT.third(form) instanceof ISeq) ? RT.third(form) : RT.next(RT.next(form)));
1006 if(!(RT.first(call) instanceof Symbol))
1007 throw new IllegalArgumentException("Malformed member expression");
1008 Symbol sym = (Symbol) RT.first(call);
1009 Symbol tag = tagOf(form);
1010 PersistentVector args = PersistentVector.EMPTY;
1011 boolean tailPosition = inTailCall(context);
1012 for(ISeq s = RT.next(call); s != null; s = s.next())
1013 args = args.cons(analyze(context == C.EVAL ? context : C.EXPRESSION, s.first()));
1014 if(c != null)
1015 return new StaticMethodExpr(source, line, column, tag, c, munge(sym.name), args, tailPosition);
1016 else
1017 return new InstanceMethodExpr(source, line, column, tag, instance, null, munge(sym.name), args, tailPosition);
1018 }
1019 }

Callers

nothing calls this directly

Calls 15

lengthMethod · 0.95
secondMethod · 0.95
thirdMethod · 0.95
getMethodsMethod · 0.95
hasJavaClassMethod · 0.95
getJavaClassMethod · 0.95
internMethod · 0.95
nextMethod · 0.95
firstMethod · 0.95
nextMethod · 0.95
consMethod · 0.95
firstMethod · 0.95

Tested by

no test coverage detected