public void processDefault() { e.pop(); } });
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 processDefault() { e.pop(); } });
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 processDefault() { e.pop(); // stack height e.aconst_null(); } });
public void processCase(int key, Label ignore_end) throws Exception { List bucket = (List)buckets.get(new Integer(key)); if (index + 1 == len) { e.pop(); callback.processCase(bucket.get(0), end); } else { stringSwitchHelper(e, bucket, callback, def, end, index + 1); } } public void processDefault() {
public void processCase(int key, Label ignore_end) throws Exception { List bucket = (List)buckets.get(new Integer(key)); if (index + 1 == len) { e.pop(); callback.processCase(bucket.get(0), end); } else { stringSwitchHelper(e, bucket, callback, def, end, index + 1); } } public void processDefault() {
public void processDefault() { e.pop(); // stack height e.aconst_null(); } });
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 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); }
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); }
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 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); }
/** * 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); } }
/** * 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 })); } } }
/** * 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 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); }