Package net.sf.cglib.core

Examples of net.sf.cglib.core.CodeEmitter$State


/*     */
/*     */   private void generateKeySet(String[] allNames)
/*     */   {
/* 157 */     declare_field(10, "keys", FIXED_KEY_SET, null, null);
/*     */
/* 159 */     CodeEmitter e = begin_static();
/* 160 */     e.new_instance(FIXED_KEY_SET);
/* 161 */     e.dup();
/* 162 */     EmitUtils.push_array(e, allNames);
/* 163 */     e.invoke_constructor(FIXED_KEY_SET, CSTRUCT_STRING_ARRAY);
/* 164 */     e.putfield("keys");
/* 165 */     e.return_value();
/* 166 */     e.end_method();
/*     */
/* 169 */     e = begin_method(1, KEY_SET, null, null);
/* 170 */     e.load_this();
/* 171 */     e.getfield("keys");
/* 172 */     e.return_value();
/* 173 */     e.end_method();
/*     */   }
View Full Code Here


/* 172 */     e.return_value();
/* 173 */     e.end_method();
/*     */   }
/*     */
/*     */   private void generateGetPropertyType(Map allProps, String[] allNames) {
/* 177 */     CodeEmitter e = begin_method(1, GET_PROPERTY_TYPE, null, null);
/* 178 */     e.load_arg(0);
/* 179 */     EmitUtils.string_switch(e, allNames, 1, new ObjectSwitchCallback(allProps, e) {
/*     */       public void processCase(Object key, Label end) {
/* 181 */         PropertyDescriptor pd = (PropertyDescriptor)this.val$allProps.get(key);
/* 182 */         EmitUtils.load_class(this.val$e, Type.getType(pd.getPropertyType()));
/* 183 */         this.val$e.return_value();
/*     */       }
/*     */       public void processDefault() {
/* 186 */         this.val$e.aconst_null();
/* 187 */         this.val$e.return_value();
/*     */       }
/*     */     });
/* 190 */     e.end_method();
/*     */   }
View Full Code Here

/*  71 */       ClassEmitter ce = new ClassEmitter(v);
/*  72 */       ce.begin_class(46, 1, getClassName(), targetType, null, "<generated>");
/*     */
/*  79 */       ce.declare_field(18, "CGLIB$RWBean", targetType, null, null);
/*     */
/*  81 */       CodeEmitter e = ce.begin_method(1, ImmutableBean.CSTRUCT_OBJECT, null, null);
/*  82 */       e.load_this();
/*  83 */       e.super_invoke_constructor();
/*  84 */       e.load_this();
/*  85 */       e.load_arg(0);
/*  86 */       e.checkcast(targetType);
/*  87 */       e.putfield("CGLIB$RWBean");
/*  88 */       e.return_value();
/*  89 */       e.end_method();
/*     */
/*  91 */       PropertyDescriptor[] descriptors = ReflectUtils.getBeanProperties(this.target);
/*  92 */       Method[] getters = ReflectUtils.getPropertyMethods(descriptors, true, false);
/*  93 */       Method[] setters = ReflectUtils.getPropertyMethods(descriptors, false, true);
/*     */
/*  95 */       for (int i = 0; i < getters.length; i++) {
/*  96 */         MethodInfo getter = ReflectUtils.getMethodInfo(getters[i]);
/*  97 */         e = EmitUtils.begin_method(ce, getter, 1);
/*  98 */         e.load_this();
/*  99 */         e.getfield("CGLIB$RWBean");
/* 100 */         e.invoke(getter);
/* 101 */         e.return_value();
/* 102 */         e.end_method();
/*     */       }
/*     */
/* 105 */       for (int i = 0; i < setters.length; i++) {
/* 106 */         MethodInfo setter = ReflectUtils.getMethodInfo(setters[i]);
/* 107 */         e = EmitUtils.begin_method(ce, setter, 1);
/* 108 */         e.throw_exception(ImmutableBean.ILLEGAL_STATE_EXCEPTION, "Bean is immutable");
/* 109 */         e.end_method();
/*     */       }
/*     */
/* 112 */       ce.end_class();
/*     */     }
View Full Code Here

/*  53 */     generateSet(target, setters);
/*  54 */     end_class();
/*     */   }
/*     */
/*     */   private void generateGet(Class target, Method[] getters) {
/*  58 */     CodeEmitter e = begin_method(1, GET_PROPERTY_VALUES, null, null);
/*  59 */     if (getters.length >= 0) {
/*  60 */       e.load_arg(0);
/*  61 */       e.checkcast(Type.getType(target));
/*  62 */       Local bean = e.make_local();
/*  63 */       e.store_local(bean);
/*  64 */       for (int i = 0; i < getters.length; i++) {
/*  65 */         if (getters[i] != null) {
/*  66 */           MethodInfo getter = ReflectUtils.getMethodInfo(getters[i]);
/*  67 */           e.load_arg(1);
/*  68 */           e.push(i);
/*  69 */           e.load_local(bean);
/*  70 */           e.invoke(getter);
/*  71 */           e.box(getter.getSignature().getReturnType());
/*  72 */           e.aastore();
/*     */         }
/*     */       }
/*     */     }
/*  76 */     e.return_value();
/*  77 */     e.end_method();
/*     */   }
View Full Code Here

/*      */
/*      */   private void emitConstructors(ClassEmitter ce, List constructors) {
/*  698 */     boolean seenNull = false;
/*  699 */     for (Iterator it = constructors.iterator(); it.hasNext(); ) {
/*  700 */       MethodInfo constructor = (MethodInfo)it.next();
/*  701 */       CodeEmitter e = EmitUtils.begin_method(ce, constructor, 1);
/*  702 */       e.load_this();
/*  703 */       e.dup();
/*  704 */       e.load_args();
/*  705 */       Signature sig = constructor.getSignature();
/*  706 */       seenNull = (seenNull) || (sig.getDescriptor().equals("()V"));
/*  707 */       e.super_invoke_constructor(sig);
/*  708 */       e.invoke_static_this(BIND_CALLBACKS);
/*  709 */       if (!this.interceptDuringConstruction) {
/*  710 */         e.load_this();
/*  711 */         e.push(1);
/*  712 */         e.putfield("CGLIB$CONSTRUCTED");
/*      */       }
/*  714 */       e.return_value();
/*  715 */       e.end_method();
/*      */     }
/*  717 */     if ((!this.classOnly) && (!seenNull) && (this.arguments == null))
/*  718 */       throw new IllegalArgumentException("Superclass has no null constructors but no arguments were given");
/*      */   }
View Full Code Here

/*      */     }
/*  726 */     return keys;
/*      */   }
/*      */
/*      */   private void emitGetCallback(ClassEmitter ce, int[] keys) {
/*  730 */     CodeEmitter e = ce.begin_method(1, GET_CALLBACK, null, null);
/*  731 */     e.load_this();
/*  732 */     e.invoke_static_this(BIND_CALLBACKS);
/*  733 */     e.load_this();
/*  734 */     e.load_arg(0);
/*  735 */     e.process_switch(keys, new ProcessSwitchCallback(e) {
/*      */       public void processCase(int key, Label end) {
/*  737 */         this.val$e.getfield(Enhancer.access$000(key));
/*  738 */         this.val$e.goTo(end);
/*      */       }
/*      */       public void processDefault() {
/*  741 */         this.val$e.pop();
/*  742 */         this.val$e.aconst_null();
/*      */       }
/*      */     });
/*  745 */     e.return_value();
/*  746 */     e.end_method();
/*      */   }
View Full Code Here

/*  745 */     e.return_value();
/*  746 */     e.end_method();
/*      */   }
/*      */
/*      */   private void emitSetCallback(ClassEmitter ce, int[] keys) {
/*  750 */     CodeEmitter e = ce.begin_method(1, SET_CALLBACK, null, null);
/*  751 */     e.load_this();
/*  752 */     e.load_arg(1);
/*  753 */     e.load_arg(0);
/*  754 */     e.process_switch(keys, new ProcessSwitchCallback(e) {
/*      */       public void processCase(int key, Label end) {
/*  756 */         this.val$e.checkcast(Enhancer.this.callbackTypes[key]);
/*  757 */         this.val$e.putfield(Enhancer.access$000(key));
/*  758 */         this.val$e.goTo(end);
/*      */       }
/*      */
/*      */       public void processDefault() {
/*  762 */         this.val$e.pop2();
/*      */       }
/*      */     });
/*  765 */     e.return_value();
/*  766 */     e.end_method();
/*      */   }
View Full Code Here

/*  765 */     e.return_value();
/*  766 */     e.end_method();
/*      */   }
/*      */
/*      */   private void emitSetCallbacks(ClassEmitter ce) {
/*  770 */     CodeEmitter e = ce.begin_method(1, SET_CALLBACKS, null, null);
/*  771 */     e.load_this();
/*  772 */     e.load_arg(0);
/*  773 */     for (int i = 0; i < this.callbackTypes.length; i++) {
/*  774 */       e.dup2();
/*  775 */       e.aaload(i);
/*  776 */       e.checkcast(this.callbackTypes[i]);
/*  777 */       e.putfield(getCallbackField(i));
/*      */     }
/*  779 */     e.return_value();
/*  780 */     e.end_method();
/*      */   }
View Full Code Here

/*  779 */     e.return_value();
/*  780 */     e.end_method();
/*      */   }
/*      */
/*      */   private void emitGetCallbacks(ClassEmitter ce) {
/*  784 */     CodeEmitter e = ce.begin_method(1, GET_CALLBACKS, null, null);
/*  785 */     e.load_this();
/*  786 */     e.invoke_static_this(BIND_CALLBACKS);
/*  787 */     e.load_this();
/*  788 */     e.push(this.callbackTypes.length);
/*  789 */     e.newarray(CALLBACK);
/*  790 */     for (int i = 0; i < this.callbackTypes.length; i++) {
/*  791 */       e.dup();
/*  792 */       e.push(i);
/*  793 */       e.load_this();
/*  794 */       e.getfield(getCallbackField(i));
/*  795 */       e.aastore();
/*      */     }
/*  797 */     e.return_value();
/*  798 */     e.end_method();
/*      */   }
View Full Code Here

/*  797 */     e.return_value();
/*  798 */     e.end_method();
/*      */   }
/*      */
/*      */   private void emitNewInstanceCallbacks(ClassEmitter ce) {
/*  802 */     CodeEmitter e = ce.begin_method(1, NEW_INSTANCE, null, null);
/*  803 */     e.load_arg(0);
/*  804 */     e.invoke_static_this(SET_THREAD_CALLBACKS);
/*  805 */     emitCommonNewInstance(e);
/*      */   }
View Full Code Here

TOP

Related Classes of net.sf.cglib.core.CodeEmitter$State

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.