public static void hash_code(CodeEmitter e, Type type, int multiplier, final CustomizerRegistry registry) { if (TypeUtils.isArray(type)) { hash_array(e, type, multiplier, registry); } else { e.swap(Type.INT_TYPE, type); e.push(multiplier); e.math(e.MUL, Type.INT_TYPE); e.swap(type, Type.INT_TYPE); if (TypeUtils.isPrimitive(type)) { hash_primitive(e, type); } else { hash_object(e, type, registry); } e.math(e.ADD, Type.INT_TYPE); } }
public static void wrap_undeclared_throwable(CodeEmitter e, Block handler, Type[] exceptions, Type wrapper) { Set set = (exceptions == null) ? Collections.EMPTY_SET : new HashSet(Arrays.asList(exceptions)); if (set.contains(Constants.TYPE_THROWABLE)) return; boolean needThrow = exceptions != null; if (!set.contains(Constants.TYPE_RUNTIME_EXCEPTION)) { e.catch_exception(handler, Constants.TYPE_RUNTIME_EXCEPTION); needThrow = true; } if (!set.contains(Constants.TYPE_ERROR)) { e.catch_exception(handler, Constants.TYPE_ERROR); needThrow = true; } if (exceptions != null) { for (int i = 0; i < exceptions.length; i++) { e.catch_exception(handler, exceptions[i]); } } if (needThrow) { e.athrow(); } // e -> eo -> oeo -> ooe -> o e.catch_exception(handler, Constants.TYPE_THROWABLE); e.new_instance(wrapper); e.dup_x1(); e.swap(); e.invoke_constructor(wrapper, CSTRUCT_THROWABLE); e.athrow(); }
public static void hash_code(CodeEmitter e, Type type, int multiplier, final CustomizerRegistry registry) { if (TypeUtils.isArray(type)) { hash_array(e, type, multiplier, registry); } else { e.swap(Type.INT_TYPE, type); e.push(multiplier); e.math(e.MUL, Type.INT_TYPE); e.swap(type, Type.INT_TYPE); if (TypeUtils.isPrimitive(type)) { hash_primitive(e, type); } else { hash_object(e, type, registry); } e.math(e.ADD, Type.INT_TYPE); } }
public static void wrap_undeclared_throwable(CodeEmitter e, Block handler, Type[] exceptions, Type wrapper) { Set set = (exceptions == null) ? Collections.EMPTY_SET : new HashSet(Arrays.asList(exceptions)); if (set.contains(Constants.TYPE_THROWABLE)) return; boolean needThrow = exceptions != null; if (!set.contains(Constants.TYPE_RUNTIME_EXCEPTION)) { e.catch_exception(handler, Constants.TYPE_RUNTIME_EXCEPTION); needThrow = true; } if (!set.contains(Constants.TYPE_ERROR)) { e.catch_exception(handler, Constants.TYPE_ERROR); needThrow = true; } if (exceptions != null) { for (int i = 0; i < exceptions.length; i++) { e.catch_exception(handler, exceptions[i]); } } if (needThrow) { e.athrow(); } // e -> eo -> oeo -> ooe -> o e.catch_exception(handler, Constants.TYPE_THROWABLE); e.new_instance(wrapper); e.dup_x1(); e.swap(); e.invoke_constructor(wrapper, CSTRUCT_THROWABLE); e.athrow(); }
public static void wrap_throwable(Block block, Type wrapper) { CodeEmitter e = block.getCodeEmitter(); e.catch_exception(block, Constants.TYPE_THROWABLE); e.new_instance(wrapper); e.dup_x1(); e.swap(); e.invoke_constructor(wrapper, CSTRUCT_THROWABLE); e.athrow(); }
public void processCase(Object key, Label end) { PropertyDescriptor pd = (PropertyDescriptor)setters.get(key); if (pd.getReadMethod() == null) { e.aconst_null(); } else { MethodInfo read = ReflectUtils.getMethodInfo(pd.getReadMethod()); e.dup(); e.invoke(read); e.box(read.getSignature().getReturnType()); } e.swap(); // move old value behind bean e.load_arg(2); // new value MethodInfo write = ReflectUtils.getMethodInfo(pd.getWriteMethod()); e.unbox(write.getSignature().getArgumentTypes()[0]); e.invoke(write); e.return_value(); } public void processDefault() {
public static void wrap_throwable(Block block, Type wrapper) { CodeEmitter e = block.getCodeEmitter(); e.catch_exception(block, Constants.TYPE_THROWABLE); e.new_instance(wrapper); e.dup_x1(); e.swap(); e.invoke_constructor(wrapper, CSTRUCT_THROWABLE); e.athrow(); }
final Label end = e.make_label(); if (useName) { e.swap(); final Map buckets = CollectionUtils.bucket(members, new Transformer() { public Object transform(Object value) {
public void processCase(Object key, Label end) { PropertyDescriptor pd = (PropertyDescriptor)setters.get(key); if (pd.getReadMethod() == null) { e.aconst_null(); } else { MethodInfo read = ReflectUtils.getMethodInfo(pd.getReadMethod()); e.dup(); e.invoke(read); e.box(read.getSignature().getReturnType()); } e.swap(); // move old value behind bean e.load_arg(2); // new value MethodInfo write = ReflectUtils.getMethodInfo(pd.getWriteMethod()); e.unbox(write.getSignature().getArgumentTypes()[0]); e.invoke(write); e.return_value(); } public void processDefault() {
public void swap(Type prev, Type type) { if (type.getSize() == 1) { if (prev.getSize() == 1) { swap(); // same as dup_x1(), pop(); } else { dup_x2(); pop(); } } else { if (prev.getSize() == 1) { dup2_x1(); pop2(); } else { dup2_x2(); pop2(); } } }
public void swap(Type prev, Type type) { if (type.getSize() == 1) { if (prev.getSize() == 1) { swap(); // same as dup_x1(), pop(); } else { dup_x2(); pop(); } } else { if (prev.getSize() == 1) { dup2_x1(); pop2(); } else { dup2_x2(); pop2(); } } }
/** * If the argument is a primitive class, replaces the primitive value * on the top of the stack with the wrapped (Object) equivalent. For * example, char -> Character. * If the class is Void, a null is pushed onto the stack instead. * @param type the class indicating the current type of the top stack value */ public void box(Type type) { if (TypeUtils.isPrimitive(type)) { if (type == Type.VOID_TYPE) { aconst_null(); } else { Type boxed = TypeUtils.getBoxedType(type); new_instance(boxed); if (type.getSize() == 2) { // Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o dup_x2(); dup_x2(); pop(); } else { // p -> po -> opo -> oop -> o dup_x1(); swap(); } invoke_constructor(boxed, new Signature(Constants.CONSTRUCTOR_NAME, Type.VOID_TYPE, new Type[]{ type })); } } }
/** * If the argument is a primitive class, replaces the primitive value * on the top of the stack with the wrapped (Object) equivalent. For * example, char -> Character. * If the class is Void, a null is pushed onto the stack instead. * @param type the class indicating the current type of the top stack value */ public void box(Type type) { if (TypeUtils.isPrimitive(type)) { if (type == Type.VOID_TYPE) { aconst_null(); } else { Type boxed = TypeUtils.getBoxedType(type); new_instance(boxed); if (type.getSize() == 2) { // Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o dup_x2(); dup_x2(); pop(); } else { // p -> po -> opo -> oop -> o dup_x1(); swap(); } invoke_constructor(boxed, new Signature(Constants.CONSTRUCTOR_NAME, Type.VOID_TYPE, new Type[]{ type })); } } }
e.new_instance(BULK_BEAN_EXCEPTION); e.dup_x1(); e.swap(); e.load_local(index); e.invoke_constructor(BULK_BEAN_EXCEPTION, CSTRUCT_EXCEPTION);
e.checkcast(CALLBACK_ARRAY); e.load_local(me); e.swap(); for (int i = callbackTypes.length - 1; i >= 0; i--) { if (i != 0) {
e.checkcast(CALLBACK_ARRAY); e.load_local(me); e.swap(); for (int i = callbackTypes.length - 1; i >= 0; i--) { if (i != 0) {