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

Class ImportExpr

src/jvm/clojure/lang/Compiler.java:749–789  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

747}
748
749public static class ImportExpr implements Expr{
750 public final String c;
751 final static Method forNameMethod = Method.getMethod("Class classForNameNonLoading(String)");
752 final static Method importClassMethod = Method.getMethod("Class importClass(Class)");
753 final static Method derefMethod = Method.getMethod("Object deref()");
754
755 public ImportExpr(String c){
756 this.c = c;
757 }
758
759 public Object eval() {
760 Namespace ns = (Namespace) RT.CURRENT_NS.deref();
761 ns.importClass(RT.classForNameNonLoading(c));
762 return null;
763 }
764
765 public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
766 gen.getStatic(RT_TYPE,"CURRENT_NS",VAR_TYPE);
767 gen.invokeVirtual(VAR_TYPE, derefMethod);
768 gen.checkCast(NS_TYPE);
769 gen.push(c);
770 gen.invokeStatic(RT_TYPE, forNameMethod);
771 gen.invokeVirtual(NS_TYPE, importClassMethod);
772 if(context == C.STATEMENT)
773 gen.pop();
774 }
775
776 public boolean hasJavaClass(){
777 return false;
778 }
779
780 public Class getJavaClass() {
781 throw new IllegalArgumentException("ImportExpr has no Java class");
782 }
783
784 static class Parser implements IParser{
785 public Expr parse(C context, Object form) {
786 return new ImportExpr((String) RT.second(form));
787 }
788 }
789}
790
791public static abstract class LiteralExpr implements Expr{
792 abstract Object val();

Callers

nothing calls this directly

Calls 1

getMethodMethod · 0.95

Tested by

no test coverage detected