private void generateSelfGetMethodCase(MethodBuilder builder, int labelIdx, MemberRef field) { Class wrapper = null; if (field.type().isPrimitive()) { wrapper = PrimitiveUtil.wrapper(field.type()); } builder.aload(1); builder.ldc(field.name()); builder.invokeVirtual( Type.STRING, BloatJ2MEContext.EQUALS_METHODNAME, new Type[] {Type.OBJECT}, Type.BOOLEAN); builder.ifeq(labelIdx + 1); if (wrapper != null) { builder.newRef(wrapper); builder.dup(); } builder.aload(0); builder.getfield(field); if (wrapper != null) { builder.invokeSpecial( _context.getType(wrapper), BloatJ2MEContext.INIT_METHODNAME, new Type[] {field.type()}, Type.VOID); } builder.areturn(); builder.label(labelIdx + 1); }
protected void generateSelf_get(MemberRef[] fields) { MethodBuilder builder = new MethodBuilder( _context, _ce, Modifiers.PUBLIC, Object.class, SELFGET_METHODNAME, new Class[] {String.class}, new Class[0]); for (int fieldIdx = 0; fieldIdx < fields.length; fieldIdx++) { generateSelfGetMethodCase(builder, fieldIdx, fields[fieldIdx]); } Type superType = _ce.superclass(); if (instrumentedType(superType)) { builder.aload(0); builder.aload(1); builder.invokeSpecial(superType, SELFGET_METHODNAME, new Type[] {Type.STRING}, Type.OBJECT); } else { builder.ldc(null); } builder.areturn(); builder.commit(); }