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

Method box

src/jvm/clojure/asm/commons/GeneratorAdapter.java:828–849  ·  view source on GitHub ↗

Generates the instructions to box the top stack value. This value is replaced by its boxed equivalent on top of the stack. @param type the type of the top stack value.

(final Type type)

Source from the content-addressed store, hash-verified

826 * @param type the type of the top stack value.
827 */
828 public void box(final Type type) {
829 if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
830 return;
831 }
832 if (type == Type.VOID_TYPE) {
833 push((String) null);
834 } else {
835 Type boxedType = getBoxedType(type);
836 newInstance(boxedType);
837 if (type.getSize() == 2) {
838 // Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o
839 dupX2();
840 dupX2();
841 pop();
842 } else {
843 // p -> po -> opo -> oop -> o
844 dupX1();
845 swap();
846 }
847 invokeConstructor(boxedType, new Method("<init>", Type.VOID_TYPE, new Type[] {type}));
848 }
849 }
850
851 /**
852 * Generates the instructions to box the top stack value using Java 5's valueOf() method. This

Callers 3

doEmitStaticMethod · 0.95
doEmitPrimMethod · 0.95
loadArgArrayMethod · 0.95

Calls 10

pushMethod · 0.95
getBoxedTypeMethod · 0.95
newInstanceMethod · 0.95
dupX2Method · 0.95
popMethod · 0.95
dupX1Method · 0.95
swapMethod · 0.95
invokeConstructorMethod · 0.95
getSizeMethod · 0.80
getSortMethod · 0.45

Tested by

no test coverage detected