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

Method addConstant

src/jvm/clojure/asm/SymbolTable.java:470–517  ·  view source on GitHub ↗

Adds a number or string constant to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item. @param value the value of the constant to be added to the constant pool. This parameter must be an Integer, Byte, Character, {@l

(final Object value)

Source from the content-addressed store, hash-verified

468 * @return a new or already existing Symbol with the given value.
469 */
470 Symbol addConstant(final Object value) {
471 if (value instanceof Integer) {
472 return addConstantInteger(((Integer) value).intValue());
473 } else if (value instanceof Byte) {
474 return addConstantInteger(((Byte) value).intValue());
475 } else if (value instanceof Character) {
476 return addConstantInteger(((Character) value).charValue());
477 } else if (value instanceof Short) {
478 return addConstantInteger(((Short) value).intValue());
479 } else if (value instanceof Boolean) {
480 return addConstantInteger(((Boolean) value).booleanValue() ? 1 : 0);
481 } else if (value instanceof Float) {
482 return addConstantFloat(((Float) value).floatValue());
483 } else if (value instanceof Long) {
484 return addConstantLong(((Long) value).longValue());
485 } else if (value instanceof Double) {
486 return addConstantDouble(((Double) value).doubleValue());
487 } else if (value instanceof String) {
488 return addConstantString((String) value);
489 } else if (value instanceof Type) {
490 Type type = (Type) value;
491 int typeSort = type.getSort();
492 if (typeSort == Type.OBJECT) {
493 return addConstantClass(type.getInternalName());
494 } else if (typeSort == Type.METHOD) {
495 return addConstantMethodType(type.getDescriptor());
496 } else { // type is a primitive or array type.
497 return addConstantClass(type.getDescriptor());
498 }
499 } else if (value instanceof Handle) {
500 Handle handle = (Handle) value;
501 return addConstantMethodHandle(
502 handle.getTag(),
503 handle.getOwner(),
504 handle.getName(),
505 handle.getDesc(),
506 handle.isInterface());
507 } else if (value instanceof ConstantDynamic) {
508 ConstantDynamic constantDynamic = (ConstantDynamic) value;
509 return addConstantDynamic(
510 constantDynamic.getName(),
511 constantDynamic.getDescriptor(),
512 constantDynamic.getBootstrapMethod(),
513 constantDynamic.getBootstrapMethodArguments());
514 } else {
515 throw new IllegalArgumentException("value " + value);
516 }
517 }
518
519 /**
520 * Adds a CONSTANT_Class_info to the constant pool of this symbol table. Does nothing if the

Callers 5

addBootstrapMethodMethod · 0.95
FieldWriterMethod · 0.80
visitLdcInsnMethod · 0.80
newConstMethod · 0.80
visitMethod · 0.80

Calls 15

addConstantIntegerMethod · 0.95
addConstantFloatMethod · 0.95
addConstantLongMethod · 0.95
addConstantDoubleMethod · 0.95
addConstantStringMethod · 0.95
getSortMethod · 0.95
addConstantClassMethod · 0.95
getInternalNameMethod · 0.95
addConstantMethodTypeMethod · 0.95
getDescriptorMethod · 0.95
getTagMethod · 0.95

Tested by

no test coverage detected