public void new_instance_this() { new_instance(ce.getClassType()); }
public void throw_exception(Type type, String msg) { new_instance(type); dup(); push(msg); invoke_constructor(type, CSTRUCT_STRING); athrow(); }
public static void push_object(CodeEmitter e, Object obj) { if (obj == null) { e.aconst_null(); } else { Class type = obj.getClass(); if (type.isArray()) { push_array(e, (Object[])obj); } else if (obj instanceof String) { e.push((String)obj); } else if (obj instanceof Type) { load_class(e, (Type)obj); } else if (obj instanceof Class) { load_class(e, Type.getType((Class)obj)); } else if (obj instanceof BigInteger) { e.new_instance(Constants.TYPE_BIG_INTEGER); e.dup(); e.push(obj.toString()); e.invoke_constructor(Constants.TYPE_BIG_INTEGER); } else if (obj instanceof BigDecimal) { e.new_instance(Constants.TYPE_BIG_DECIMAL); e.dup(); e.push(obj.toString()); e.invoke_constructor(Constants.TYPE_BIG_DECIMAL); } else { throw new IllegalArgumentException("unknown type: " + obj.getClass()); } } }
se.new_instance(THREAD_LOCAL); se.dup(); se.invoke_constructor(THREAD_LOCAL, CSTRUCT_NULL);
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(); }
ReflectUtils.getSignature(newInstance), ReflectUtils.getExceptionTypes(newInstance)); e.new_instance(declaring); e.dup(); e.load_args();
private void generateKeySet(String[] allNames) { // static initializer declare_field(Constants.ACC_STATIC | Constants.ACC_PRIVATE, "keys", FIXED_KEY_SET, null); CodeEmitter e = begin_static(); e.new_instance(FIXED_KEY_SET); e.dup(); EmitUtils.push_array(e, allNames); e.invoke_constructor(FIXED_KEY_SET, CSTRUCT_STRING_ARRAY); e.putfield("keys"); e.return_value(); e.end_method(); // keySet e = begin_method(Constants.ACC_PUBLIC, KEY_SET, null); e.load_this(); e.getfield("keys"); e.return_value(); e.end_method(); }
/** * 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(base); e.dup(); e.load_arg(0);
e.new_instance(Constants.TYPE_STRING_BUFFER); e.dup(); e.invoke_constructor(Constants.TYPE_STRING_BUFFER);
e.return_value(); e.catch_exception(handler, Constants.TYPE_THROWABLE); e.new_instance(BULK_BEAN_EXCEPTION); e.dup_x1(); e.swap();
public void new_instance_this() { new_instance(ce.getClassType()); }
public void throw_exception(Type type, String msg) { new_instance(type); dup(); push(msg); invoke_constructor(type, CSTRUCT_STRING); athrow(); }
public static void push_object(CodeEmitter e, Object obj) { if (obj == null) { e.aconst_null(); } else { Class type = obj.getClass(); if (type.isArray()) { push_array(e, (Object[])obj); } else if (obj instanceof String) { e.push((String)obj); } else if (obj instanceof Type) { load_class(e, (Type)obj); } else if (obj instanceof Class) { load_class(e, Type.getType((Class)obj)); } else if (obj instanceof BigInteger) { e.new_instance(Constants.TYPE_BIG_INTEGER); e.dup(); e.push(obj.toString()); e.invoke_constructor(Constants.TYPE_BIG_INTEGER); } else if (obj instanceof BigDecimal) { e.new_instance(Constants.TYPE_BIG_DECIMAL); e.dup(); e.push(obj.toString()); e.invoke_constructor(Constants.TYPE_BIG_DECIMAL); } else { throw new IllegalArgumentException("unknown type: " + obj.getClass()); } } }
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(); }
ReflectUtils.getSignature(newInstance), ReflectUtils.getExceptionTypes(newInstance)); e.new_instance(declaring); e.dup(); e.load_args();
private void generateKeySet(String[] allNames) { // static initializer declare_field(Constants.ACC_STATIC | Constants.ACC_PRIVATE, "keys", FIXED_KEY_SET, null); CodeEmitter e = begin_static(); e.new_instance(FIXED_KEY_SET); e.dup(); EmitUtils.push_array(e, allNames); e.invoke_constructor(FIXED_KEY_SET, CSTRUCT_STRING_ARRAY); e.putfield("keys"); e.return_value(); e.end_method(); // keySet e = begin_method(Constants.ACC_PUBLIC, KEY_SET, null); e.load_this(); e.getfield("keys"); e.return_value(); e.end_method(); }
/** * 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 })); } } }