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

Class EmptyExpr

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

Source from the content-addressed store, hash-verified

3466}
3467
3468public static class EmptyExpr implements Expr{
3469 public final Object coll;
3470 final static Type HASHMAP_TYPE = Type.getType(PersistentArrayMap.class);
3471 final static Type HASHSET_TYPE = Type.getType(PersistentHashSet.class);
3472 final static Type VECTOR_TYPE = Type.getType(PersistentVector.class);
3473 final static Type IVECTOR_TYPE = Type.getType(IPersistentVector.class);
3474 final static Type TUPLE_TYPE = Type.getType(Tuple.class);
3475 final static Type LIST_TYPE = Type.getType(PersistentList.class);
3476 final static Type EMPTY_LIST_TYPE = Type.getType(PersistentList.EmptyList.class);
3477
3478
3479 public EmptyExpr(Object coll){
3480 this.coll = coll;
3481 }
3482
3483 public Object eval() {
3484 return coll;
3485 }
3486
3487 public void emit(C context, ObjExpr objx, GeneratorAdapter gen){
3488 if(coll instanceof IPersistentList)
3489 gen.getStatic(LIST_TYPE, "EMPTY", EMPTY_LIST_TYPE);
3490 else if(coll instanceof IPersistentVector)
3491 gen.getStatic(VECTOR_TYPE, "EMPTY", VECTOR_TYPE);
3492 else if(coll instanceof IPersistentMap)
3493 gen.getStatic(HASHMAP_TYPE, "EMPTY", HASHMAP_TYPE);
3494 else if(coll instanceof IPersistentSet)
3495 gen.getStatic(HASHSET_TYPE, "EMPTY", HASHSET_TYPE);
3496 else
3497 throw new UnsupportedOperationException("Unknown Collection type");
3498 if(context == C.STATEMENT)
3499 {
3500 gen.pop();
3501 }
3502 }
3503
3504 public boolean hasJavaClass() {
3505 return true;
3506 }
3507
3508 public Class getJavaClass() {
3509 if(coll instanceof IPersistentList)
3510 return IPersistentList.class;
3511 else if(coll instanceof IPersistentVector)
3512 return IPersistentVector.class;
3513 else if(coll instanceof IPersistentMap)
3514 return IPersistentMap.class;
3515 else if(coll instanceof IPersistentSet)
3516 return IPersistentSet.class;
3517 else
3518 throw new UnsupportedOperationException("Unknown Collection type");
3519 }
3520}
3521
3522public static class ListExpr implements Expr{
3523 public final IPersistentVector args;

Callers

nothing calls this directly

Calls 1

getTypeMethod · 0.95

Tested by

no test coverage detected