public Block(CodeEmitter e) { this.e = e; start = e.mark(); }
public Block(CodeEmitter e) { this.e = e; start = e.mark(); }
public void end() { if (end != null) { throw new IllegalStateException("end of label already set"); } end = e.mark(); }
public void end() { if (end != null) { throw new IllegalStateException("end of label already set"); } end = e.mark(); }
public void catch_exception(Block block, Type exception) { if (block.getEnd() == null) { throw new IllegalStateException("end of block is unset"); } mv.visitTryCatchBlock(block.getStart(), block.getEnd(), mark(), exception.getInternalName()); }
public void catch_exception(Block block, Type exception) { if (block.getEnd() == null) { throw new IllegalStateException("end of block is unset"); } mv.visitTryCatchBlock(block.getStart(), block.getEnd(), mark(), exception.getInternalName()); }
private static void hash_array(final CodeEmitter e, Type type, final int multiplier, final CustomizerRegistry registry) { Label skip = e.make_label(); Label end = e.make_label(); e.dup(); e.ifnull(skip); EmitUtils.process_array(e, type, new ProcessArrayCallback() { public void processElement(Type type) { hash_code(e, type, multiplier, registry); } }); e.goTo(end); e.mark(skip); e.pop(); e.mark(end); }
public void processCase(int key, Label ignore_end) throws Exception { List bucket = (List)buckets.get(new Integer(key)); Label next = null; if (skipEquals && bucket.size() == 1) { if (skipEquals) e.pop(); callback.processCase((String)bucket.get(0), end); } else { for (Iterator it = bucket.iterator(); it.hasNext();) { String string = (String)it.next(); if (next != null) { e.mark(next); } if (it.hasNext()) { e.dup(); } e.push(string); e.invoke_virtual(Constants.TYPE_OBJECT, EQUALS); if (it.hasNext()) { e.if_jump(e.EQ, next = e.make_label()); e.pop(); } else { e.if_jump(e.EQ, def); } callback.processCase(string, end); } } } public void processDefault() {
private static void hash_array(final CodeEmitter e, Type type, final int multiplier, final CustomizerRegistry registry) { Label skip = e.make_label(); Label end = e.make_label(); e.dup(); e.ifnull(skip); EmitUtils.process_array(e, type, new ProcessArrayCallback() { public void processElement(Type type) { hash_code(e, type, multiplier, registry); } }); e.goTo(end); e.mark(skip); e.pop(); e.mark(end); }
private static void string_switch_trie(final CodeEmitter e, String[] strings, final ObjectSwitchCallback callback) throws Exception { final Label def = e.make_label(); final Label end = e.make_label(); final Map buckets = CollectionUtils.bucket(Arrays.asList(strings), new Transformer() { public Object transform(Object value) { return new Integer(((String)value).length()); } }); e.dup(); e.invoke_virtual(Constants.TYPE_STRING, STRING_LENGTH); e.process_switch(getSwitchKeys(buckets), new ProcessSwitchCallback() { public void processCase(int key, Label ignore_end) throws Exception { List bucket = (List)buckets.get(new Integer(key)); stringSwitchHelper(e, bucket, callback, def, end, 0); } public void processDefault() { e.goTo(def); } }); e.mark(def); e.pop(); callback.processDefault(); e.mark(end); }
/** * If both objects on the top of the stack are non-null, does nothing. * If one is null, or both are null, both are popped off and execution * branches to the respective label. * @param oneNull label to branch to if only one of the objects is null * @param bothNull label to branch to if both of the objects are null */ private static void nullcmp(CodeEmitter e, Label oneNull, Label bothNull) { e.dup2(); Label nonNull = e.make_label(); Label oneNullHelper = e.make_label(); Label end = e.make_label(); e.ifnonnull(nonNull); e.ifnonnull(oneNullHelper); e.pop2(); e.goTo(bothNull); e.mark(nonNull); e.ifnull(oneNullHelper); e.goTo(end); e.mark(oneNullHelper); e.pop2(); e.goTo(oneNull); e.mark(end); }
/** * Unboxes the object on the top of the stack. If the object is null, the * unboxed primitive value becomes zero. */ public void unbox_or_zero(Type type) { if (TypeUtils.isPrimitive(type)) { if (type != Type.VOID_TYPE) { Label nonNull = make_label(); Label end = make_label(); dup(); ifnonnull(nonNull); pop(); zero_or_null(type); goTo(end); mark(nonNull); unbox(type); mark(end); } } else { checkcast(type); } }
/** * Unboxes the object on the top of the stack. If the object is null, the * unboxed primitive value becomes zero. */ public void unbox_or_zero(Type type) { if (TypeUtils.isPrimitive(type)) { if (type != Type.VOID_TYPE) { Label nonNull = make_label(); Label end = make_label(); dup(); ifnonnull(nonNull); pop(); zero_or_null(type); goTo(end); mark(nonNull); unbox(type); mark(end); } } else { checkcast(type); } }
private static void hash_object(CodeEmitter e, Type type, CustomizerRegistry registry) { // (f == null) ? 0 : f.hashCode(); Label skip = e.make_label(); Label end = e.make_label(); e.dup(); e.ifnull(skip); boolean customHashCode = false; for (HashCodeCustomizer customizer : registry.get(HashCodeCustomizer.class)) { if (customizer.customize(e, type)) { customHashCode = true; break; } } if (!customHashCode) { for (Customizer customizer : registry.get(Customizer.class)) { customizer.customize(e, type); } e.invoke_virtual(Constants.TYPE_OBJECT, HASH_CODE); } e.goTo(end); e.mark(skip); e.pop(); e.push(0); e.mark(end); }
private void emitCurrentCallback(CodeEmitter e, int index) { e.load_this(); e.getfield(getCallbackField(index)); e.dup(); Label end = e.make_label(); e.ifnonnull(end); e.pop(); // stack height e.load_this(); e.invoke_static_this(BIND_CALLBACKS); e.load_this(); e.getfield(getCallbackField(index)); e.mark(end); }
public CodeEmitter beginMethod(ClassEmitter ce, MethodInfo method) { CodeEmitter e = EmitUtils.begin_method(ce, method); if (!interceptDuringConstruction && !TypeUtils.isAbstract(method.getModifiers())) { Label constructed = e.make_label(); e.load_this(); e.getfield(CONSTRUCTED_FIELD); e.if_jump(e.NE, constructed); e.load_this(); e.load_args(); e.super_invoke(); e.return_value(); e.mark(constructed); } return e; } };
private void emitCurrentCallback(CodeEmitter e, int index) { e.load_this(); e.getfield(getCallbackField(index)); e.dup(); Label end = e.make_label(); e.ifnonnull(end); e.pop(); // stack height e.load_this(); e.invoke_static_this(BIND_CALLBACKS); e.load_this(); e.getfield(getCallbackField(index)); e.mark(end); }
private void addWriteMethod(String name, Type type) { CodeEmitter e = super.begin_method(Constants.ACC_PUBLIC, writeMethodSig(name, type.getDescriptor()), null); e.load_this(); e.dup(); e.invoke_interface(ENABLED,ENABLED_GET); Label skip = e.make_label(); e.ifnull(skip); e.load_this(); e.invoke_interface(ENABLED,ENABLED_GET); e.load_this(); e.push(name); e.load_this(); e.getfield(name); e.load_arg(0); e.invoke_interface(CALLBACK, writeCallbackSig(type)); if (!TypeUtils.isPrimitive(type)) { e.checkcast(type); } Label go = e.make_label(); e.goTo(go); e.mark(skip); e.load_arg(0); e.mark(go); e.putfield(name); e.return_value(); e.end_method(); }
public CodeEmitter beginMethod(ClassEmitter ce, MethodInfo method) { CodeEmitter e = EmitUtils.begin_method(ce, method); if (!interceptDuringConstruction && !TypeUtils.isAbstract(method.getModifiers())) { Label constructed = e.make_label(); e.load_this(); e.getfield(CONSTRUCTED_FIELD); e.if_jump(e.NE, constructed); e.load_this(); e.load_args(); e.super_invoke(); e.return_value(); e.mark(constructed); } return e; } };
private void addReadMethod(String name, Type type) { CodeEmitter e = super.begin_method(Constants.ACC_PUBLIC, readMethodSig(name, type.getDescriptor()), null); e.load_this(); e.getfield(name); e.load_this(); e.invoke_interface(ENABLED,ENABLED_GET); Label intercept = e.make_label(); e.ifnonnull(intercept); e.return_value(); e.mark(intercept); Local result = e.make_local(type); e.store_local(result); e.load_this(); e.invoke_interface(ENABLED,ENABLED_GET); e.load_this(); e.push(name); e.load_local(result); e.invoke_interface(CALLBACK, readCallbackSig(type)); if (!TypeUtils.isPrimitive(type)) { e.checkcast(type); } e.return_value(); e.end_method(); }