Package net.sf.cglib.core

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


/* 104 */       throw new CodeGenerationException(e);
/*     */     }
/*     */     Method delegate;
/* 107 */     Signature sig = ReflectUtils.getSignature(m);
/* 108 */     Type[] exceptions = TypeUtils.getTypes(m.getExceptionTypes());
/* 109 */     CodeEmitter e = super.begin_method(1, sig, exceptions, null);
/* 110 */     e.load_this();
/* 111 */     e.getfield("$CGLIB_DELEGATE");
/* 112 */     e.load_args();
/* 113 */     e.invoke_virtual(this.delegateType, sig);
/* 114 */     e.return_value();
/* 115 */     e.end_method();
/*     */   }
View Full Code Here


/* 39 */     if (!found)
/* 40 */       throw new IllegalArgumentException(wrapper + " does not have a single-arg constructor that takes a Throwable");
/*    */   }
/*    */
/*    */   public CodeEmitter begin_method(int access, Signature sig, Type[] exceptions, Attribute attrs) {
/* 44 */     CodeEmitter e = super.begin_method(access, sig, exceptions, attrs);
/* 45 */     if ((TypeUtils.isAbstract(access)) || (sig.equals(Constants.SIG_STATIC))) {
/* 46 */       return e;
/*    */     }
/* 48 */     return new CodeEmitter(e, exceptions)
/*    */     {
/*    */       private Block handler;
/*    */
/*    */       public void visitMaxs(int maxStack, int maxLocals) {
/* 54 */         this.handler.end();
View Full Code Here

/*  97 */     setByIndex(names, indexes);
/*  98 */     getByIndex(names, indexes);
/*     */   }
/*     */
/*     */   private void initFieldProvider(String[] names) {
/* 102 */     CodeEmitter e = getStaticHook();
/* 103 */     EmitUtils.push_object(e, names);
/* 104 */     e.putstatic(getClassType(), "CGLIB$FIELD_NAMES", Constants.TYPE_STRING_ARRAY);
/*     */
/* 106 */     e.push(names.length);
/* 107 */     e.newarray(Constants.TYPE_CLASS);
/* 108 */     e.dup();
/* 109 */     for (int i = 0; i < names.length; i++) {
/* 110 */       e.dup();
/* 111 */       e.push(i);
/* 112 */       Type type = (Type)this.fields.get(names[i]);
/* 113 */       EmitUtils.load_class(e, type);
/* 114 */       e.aastore();
/*     */     }
/* 116 */     e.putstatic(getClassType(), "CGLIB$FIELD_TYPES", Constants.TYPE_CLASS_ARRAY);
/*     */   }
View Full Code Here

/*     */     }
/* 116 */     e.putstatic(getClassType(), "CGLIB$FIELD_TYPES", Constants.TYPE_CLASS_ARRAY);
/*     */   }
/*     */
/*     */   private void getNames() {
/* 120 */     CodeEmitter e = super.begin_method(1, PROVIDER_GET_NAMES, null, null);
/* 121 */     e.getstatic(getClassType(), "CGLIB$FIELD_NAMES", Constants.TYPE_STRING_ARRAY);
/* 122 */     e.return_value();
/* 123 */     e.end_method();
/*     */   }
View Full Code Here

/* 122 */     e.return_value();
/* 123 */     e.end_method();
/*     */   }
/*     */
/*     */   private void getTypes() {
/* 127 */     CodeEmitter e = super.begin_method(1, PROVIDER_GET_TYPES, null, null);
/* 128 */     e.getstatic(getClassType(), "CGLIB$FIELD_TYPES", Constants.TYPE_CLASS_ARRAY);
/* 129 */     e.return_value();
/* 130 */     e.end_method();
/*     */   }
View Full Code Here

/* 129 */     e.return_value();
/* 130 */     e.end_method();
/*     */   }
/*     */
/*     */   private void setByIndex(String[] names, int[] indexes) throws Exception {
/* 134 */     CodeEmitter e = super.begin_method(1, PROVIDER_SET_BY_INDEX, null, null);
/* 135 */     e.load_this();
/* 136 */     e.load_arg(1);
/* 137 */     e.load_arg(0);
/* 138 */     e.process_switch(indexes, new ProcessSwitchCallback(names, e) {
/*     */       public void processCase(int key, Label end) throws Exception {
/* 140 */         Type type = (Type)FieldProviderTransformer.this.fields.get(this.val$names[key]);
/* 141 */         this.val$e.unbox(type);
/* 142 */         this.val$e.putfield(this.val$names[key]);
/* 143 */         this.val$e.return_value();
/*     */       }
/*     */       public void processDefault() throws Exception {
/* 146 */         this.val$e.throw_exception(FieldProviderTransformer.ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field index");
/*     */       }
/*     */     });
/* 149 */     e.end_method();
/*     */   }
View Full Code Here

/*     */     });
/* 149 */     e.end_method();
/*     */   }
/*     */
/*     */   private void getByIndex(String[] names, int[] indexes) throws Exception {
/* 153 */     CodeEmitter e = super.begin_method(1, PROVIDER_GET_BY_INDEX, null, null);
/* 154 */     e.load_this();
/* 155 */     e.load_arg(0);
/* 156 */     e.process_switch(indexes, new ProcessSwitchCallback(names, e) {
/*     */       public void processCase(int key, Label end) throws Exception {
/* 158 */         Type type = (Type)FieldProviderTransformer.this.fields.get(this.val$names[key]);
/* 159 */         this.val$e.getfield(this.val$names[key]);
/* 160 */         this.val$e.box(type);
/* 161 */         this.val$e.return_value();
/*     */       }
/*     */       public void processDefault() throws Exception {
/* 164 */         this.val$e.throw_exception(FieldProviderTransformer.ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field index");
/*     */       }
/*     */     });
/* 167 */     e.end_method();
/*     */   }
View Full Code Here

/*     */   }
/*     */
/*     */   private void getField(String[] names)
/*     */     throws Exception
/*     */   {
/* 173 */     CodeEmitter e = begin_method(1, PROVIDER_GET, null, null);
/* 174 */     e.load_this();
/* 175 */     e.load_arg(0);
/* 176 */     EmitUtils.string_switch(e, names, 1, new ObjectSwitchCallback(e) {
/*     */       public void processCase(Object key, Label end) {
/* 178 */         Type type = (Type)FieldProviderTransformer.this.fields.get(key);
/* 179 */         this.val$e.getfield((String)key);
/* 180 */         this.val$e.box(type);
/* 181 */         this.val$e.return_value();
/*     */       }
/*     */       public void processDefault() {
/* 184 */         this.val$e.throw_exception(FieldProviderTransformer.ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field name");
/*     */       }
/*     */     });
/* 187 */     e.end_method();
/*     */   }
View Full Code Here

/*     */     });
/* 187 */     e.end_method();
/*     */   }
/*     */
/*     */   private void setField(String[] names) throws Exception {
/* 191 */     CodeEmitter e = begin_method(1, PROVIDER_SET, null, null);
/* 192 */     e.load_this();
/* 193 */     e.load_arg(1);
/* 194 */     e.load_arg(0);
/* 195 */     EmitUtils.string_switch(e, names, 1, new ObjectSwitchCallback(e) {
/*     */       public void processCase(Object key, Label end) {
/* 197 */         Type type = (Type)FieldProviderTransformer.this.fields.get(key);
/* 198 */         this.val$e.unbox(type);
/* 199 */         this.val$e.putfield((String)key);
/* 200 */         this.val$e.return_value();
/*     */       }
/*     */       public void processDefault() {
/* 203 */         this.val$e.throw_exception(FieldProviderTransformer.ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field name");
/*     */       }
/*     */     });
/* 206 */     e.end_method();
/*     */   }
View Full Code Here

/* 37 */     super.declare_field(access, name, type, value, attrs);
/*    */
/* 39 */     String property = TypeUtils.upperFirst(this.callback.getPropertyName(getClassType(), name));
/* 40 */     if (property != null)
/*    */     {
/* 42 */       CodeEmitter e = begin_method(1, new Signature("get" + property, type, Constants.TYPES_EMPTY), null, null);
/*    */
/* 48 */       e.load_this();
/* 49 */       e.getfield(name);
/* 50 */       e.return_value();
/* 51 */       e.end_method();
/*    */
/* 53 */       e = begin_method(1, new Signature("set" + property, Type.VOID_TYPE, new Type[] { type }), null, null);
/*    */
/* 59 */       e.load_this();
/* 60 */       e.load_arg(0);
/* 61 */       e.putfield(name);
/* 62 */       e.return_value();
/* 63 */       e.end_method();
/*    */     }
/*    */   }
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.