Package net.sf.cglib.core

Examples of net.sf.cglib.core.CodeEmitter


/*    */     }
/*    */   }
/*    */
/*    */   public CodeEmitter begin_method(int access, Signature sig, Type[] exceptions, Attribute attrs)
/*    */   {
/* 49 */     CodeEmitter emitter = super.begin_method(access, sig, exceptions, attrs);
/*    */
/* 52 */     if (sig.getName().equals("<init>"))
/* 53 */       return new CodeEmitter(emitter) {
/*    */         public void visitInsn(int opcode) {
/* 55 */           if (opcode == 177) {
/* 56 */             load_this();
/* 57 */             invoke(AddInitTransformer.this.info);
/*    */           }
View Full Code Here


/*  70 */       super.begin_class(version, access, className, superType, interfaces, sourceFile);
/*     */     }
/*     */   }
/*     */
/*     */   public CodeEmitter begin_method(int access, Signature sig, Type[] exceptions, Attribute attrs) {
/*  75 */     CodeEmitter e = super.begin_method(access, sig, exceptions, attrs);
/*  76 */     if (sig.getName().equals("<init>"))
/*  77 */       return new CodeEmitter(e) {
/*  78 */         private boolean transformInit = true;
/*     */
/*  80 */         public void visitMethodInsn(int opcode, String owner, String name, String desc) { super.visitMethodInsn(opcode, owner, name, desc);
/*  81 */           if ((this.transformInit) && (opcode == 183)) {
/*  82 */             load_this();
View Full Code Here

/* 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

TOP

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

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.