/** * Push the byte code to load the target (i.e. what was passed as the first argument * to CompiledExpression.getValue(target, context)) * @param mv the visitor into which the load instruction should be inserted */ public void loadTarget(MethodVisitor mv) { mv.visitVarInsn(ALOAD, 1); }
/** * Push the bytecode to load the EvaluationContext (the second parameter passed to * the compiled expression method). * @param mv the visitor into which the load instruction should be inserted * @since 4.3.4 */ public void loadEvaluationContext(MethodVisitor mv) { mv.visitVarInsn(ALOAD, 2); }
/** * Visits a local variable instruction. A local variable instruction is an instruction that loads * or stores the value of a local variable. * * @param opcode the opcode of the local variable instruction to be visited. This opcode is either * ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET. * @param var the operand of the instruction to be visited. This operand is the index of a local * variable. */ public void visitVarInsn(final int opcode, final int var) { if (mv != null) { mv.visitVarInsn(opcode, var); } }
/** * Visits a local variable instruction. A local variable instruction is an instruction that loads * or stores the value of a local variable. * * @param opcode the opcode of the local variable instruction to be visited. This opcode is either * ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET. * @param var the operand of the instruction to be visited. This operand is the index of a local * variable. */ public void visitVarInsn(final int opcode, final int var) { if (mv != null) { mv.visitVarInsn(opcode, var); } }
/** * Push the byte code to load the target (i.e. what was passed as the first argument * to CompiledExpression.getValue(target, context)) * @param mv the visitor into which the load instruction should be inserted */ public void loadTarget(MethodVisitor mv) { mv.visitVarInsn(ALOAD, 1); }
/** * Push the bytecode to load the EvaluationContext (the second parameter passed to * the compiled expression method). * @param mv the visitor into which the load instruction should be inserted * @since 4.3.4 */ public void loadEvaluationContext(MethodVisitor mv) { mv.visitVarInsn(ALOAD, 2); }
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { if (this.name.equals(ROOT)) { mv.visitVarInsn(ALOAD,1); } else { mv.visitVarInsn(ALOAD, 2); mv.visitLdcInsn(this.name); mv.visitMethodInsn(INVOKEINTERFACE, "org/springframework/expression/EvaluationContext", "lookupVariable", "(Ljava/lang/String;)Ljava/lang/Object;",true); } CodeFlow.insertCheckCast(mv, this.exitTypeDescriptor); cf.pushDescriptor(this.exitTypeDescriptor); }
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { if (this.name.equals(ROOT)) { mv.visitVarInsn(ALOAD,1); } else { mv.visitVarInsn(ALOAD, 2); mv.visitLdcInsn(this.name); mv.visitMethodInsn(INVOKEINTERFACE, "org/springframework/expression/EvaluationContext", "lookupVariable", "(Ljava/lang/String;)Ljava/lang/Object;",true); } CodeFlow.insertCheckCast(mv, this.exitTypeDescriptor); cf.pushDescriptor(this.exitTypeDescriptor); }
mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "org/springframework/expression/spel/CompiledExpression", "<init>", "()V", false);
mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "org/springframework/expression/spel/CompiledExpression", "<init>", "()V", false);
case Constants.ALOAD_3: opcode -= Constants.ILOAD_0; methodVisitor.visitVarInsn(Opcodes.ILOAD + (opcode >> 2), opcode & 0x3); currentOffset += 1; break; case Constants.ASTORE_3: opcode -= Constants.ISTORE_0; methodVisitor.visitVarInsn(Opcodes.ISTORE + (opcode >> 2), opcode & 0x3); currentOffset += 1; break; currentOffset += 6; } else { methodVisitor.visitVarInsn(opcode, readUnsignedShort(currentOffset + 2)); currentOffset += 4; case Constants.ASTORE: case Constants.RET: methodVisitor.visitVarInsn(opcode, classFileBuffer[currentOffset + 1] & 0xFF); currentOffset += 2; break;
case Constants.ALOAD_3: opcode -= Constants.ILOAD_0; methodVisitor.visitVarInsn(Opcodes.ILOAD + (opcode >> 2), opcode & 0x3); currentOffset += 1; break; case Constants.ASTORE_3: opcode -= Constants.ISTORE_0; methodVisitor.visitVarInsn(Opcodes.ISTORE + (opcode >> 2), opcode & 0x3); currentOffset += 1; break; currentOffset += 6; } else { methodVisitor.visitVarInsn(opcode, readUnsignedShort(currentOffset + 2)); currentOffset += 4; case Constants.ASTORE: case Constants.RET: methodVisitor.visitVarInsn(opcode, classFileBuffer[currentOffset + 1] & 0xFF); currentOffset += 2; break;
/** * Push the byte code to load the target (i.e. what was passed as the first argument * to CompiledExpression.getValue(target, context)) * @param mv the visitor into which the load instruction should be inserted */ public void loadTarget(MethodVisitor mv) { mv.visitVarInsn(ALOAD, 1); }
/** * Push the bytecode to load the EvaluationContext (the second parameter passed to * the compiled expression method). * @param mv the visitor into which the load instruction should be inserted * @since 4.3.4 */ public void loadEvaluationContext(MethodVisitor mv) { mv.visitVarInsn(ALOAD, 2); }
/** * Visits a local variable instruction. A local variable instruction is an instruction that loads * or stores the value of a local variable. * * @param opcode the opcode of the local variable instruction to be visited. This opcode is either * ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET. * @param var the operand of the instruction to be visited. This operand is the index of a local * variable. */ public void visitVarInsn(final int opcode, final int var) { if (mv != null) { mv.visitVarInsn(opcode, var); } }
/** * Visits a local variable instruction. A local variable instruction is an instruction that loads * or stores the value of a local variable. * * @param opcode the opcode of the local variable instruction to be visited. This opcode is either * ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET. * @param var the operand of the instruction to be visited. This operand is the index of a local * variable. */ public void visitVarInsn(final int opcode, final int var) { if (mv != null) { mv.visitVarInsn(opcode, var); } }
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { if (this.name.equals(ROOT)) { mv.visitVarInsn(ALOAD,1); } else { mv.visitVarInsn(ALOAD, 2); mv.visitLdcInsn(name); mv.visitMethodInsn(INVOKEINTERFACE, "org/springframework/expression/EvaluationContext", "lookupVariable", "(Ljava/lang/String;)Ljava/lang/Object;",true); } CodeFlow.insertCheckCast(mv, this.exitTypeDescriptor); cf.pushDescriptor(this.exitTypeDescriptor); }
private static void visitAssertNotNull(MethodVisitor mv) { // Assert.notNull(property) mv.visitVarInsn(ALOAD, 1); mv.visitLdcInsn("Property must not be null!"); mv.visitMethodInsn(INVOKESTATIC, "org/springframework/util/Assert", "notNull", String.format("(%s%s)V", referenceName(JAVA_LANG_OBJECT), referenceName(JAVA_LANG_STRING)), false); }
/** * 创建构造器 * @param cw */ public static void visitDefaultConstructor(ClassWriter cw) { MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, INIT, "()V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, JAVA_LANG_OBJECT, INIT, "()V", false); mv.visitInsn(RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); }
private void visitDefaultConstructor(ClassWriter cw) { MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, INIT, "()V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, JAVA_LANG_OBJECT, INIT, "()V", false); mv.visitInsn(RETURN); mv.visitMaxs(0, 0); // (0, 0) = computed via ClassWriter.COMPUTE_MAXS mv.visitEnd(); }