Java Code Examples for org.springframework.expression.spel.CodeFlow#insertNumericUnboxOrPrimitiveTypeCoercion()
The following examples show how to use
org.springframework.expression.spel.CodeFlow#insertNumericUnboxOrPrimitiveTypeCoercion() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpDivide.java From spring-analysis-note with MIT License | 5 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; String exitDesc = this.exitTypeDescriptor; Assert.state(exitDesc != null, "No exit type descriptor"); char targetDesc = exitDesc.charAt(0); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, targetDesc); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, targetDesc); switch (targetDesc) { case 'I': mv.visitInsn(IDIV); break; case 'J': mv.visitInsn(LDIV); break; case 'F': mv.visitInsn(FDIV); break; case 'D': mv.visitInsn(DDIV); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 2
Source File: OpMultiply.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, this.exitTypeDescriptor.charAt(0)); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, this.exitTypeDescriptor.charAt(0)); switch (this.exitTypeDescriptor.charAt(0)) { case 'I': mv.visitInsn(IMUL); break; case 'J': mv.visitInsn(LMUL); break; case 'F': mv.visitInsn(FMUL); break; case 'D': mv.visitInsn(DMUL); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 3
Source File: OpModulus.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, this.exitTypeDescriptor.charAt(0)); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, this.exitTypeDescriptor.charAt(0)); switch (this.exitTypeDescriptor.charAt(0)) { case 'I': mv.visitInsn(IREM); break; case 'J': mv.visitInsn(LREM); break; case 'F': mv.visitInsn(FREM); break; case 'D': mv.visitInsn(DREM); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 4
Source File: OpDivide.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, this.exitTypeDescriptor.charAt(0)); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, this.exitTypeDescriptor.charAt(0)); switch (this.exitTypeDescriptor.charAt(0)) { case 'I': mv.visitInsn(IDIV); break; case 'J': mv.visitInsn(LDIV); break; case 'F': mv.visitInsn(FDIV); break; case 'D': mv.visitInsn(DDIV); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 5
Source File: OpMultiply.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, this.exitTypeDescriptor.charAt(0)); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, this.exitTypeDescriptor.charAt(0)); switch (this.exitTypeDescriptor.charAt(0)) { case 'I': mv.visitInsn(IMUL); break; case 'J': mv.visitInsn(LMUL); break; case 'F': mv.visitInsn(FMUL); break; case 'D': mv.visitInsn(DMUL); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 6
Source File: OpModulus.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, this.exitTypeDescriptor.charAt(0)); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, this.exitTypeDescriptor.charAt(0)); switch (this.exitTypeDescriptor.charAt(0)) { case 'I': mv.visitInsn(IREM); break; case 'J': mv.visitInsn(LREM); break; case 'F': mv.visitInsn(FREM); break; case 'D': mv.visitInsn(DREM); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 7
Source File: OpDivide.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, this.exitTypeDescriptor.charAt(0)); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, this.exitTypeDescriptor.charAt(0)); switch (this.exitTypeDescriptor.charAt(0)) { case 'I': mv.visitInsn(IDIV); break; case 'J': mv.visitInsn(LDIV); break; case 'F': mv.visitInsn(FDIV); break; case 'D': mv.visitInsn(DDIV); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 8
Source File: OpMultiply.java From java-technology-stack with MIT License | 5 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; String exitDesc = this.exitTypeDescriptor; Assert.state(exitDesc != null, "No exit type descriptor"); char targetDesc = exitDesc.charAt(0); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, targetDesc); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, targetDesc); switch (targetDesc) { case 'I': mv.visitInsn(IMUL); break; case 'J': mv.visitInsn(LMUL); break; case 'F': mv.visitInsn(FMUL); break; case 'D': mv.visitInsn(DMUL); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 9
Source File: OpModulus.java From java-technology-stack with MIT License | 5 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; String exitDesc = this.exitTypeDescriptor; Assert.state(exitDesc != null, "No exit type descriptor"); char targetDesc = exitDesc.charAt(0); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, targetDesc); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, targetDesc); switch (targetDesc) { case 'I': mv.visitInsn(IREM); break; case 'J': mv.visitInsn(LREM); break; case 'F': mv.visitInsn(FREM); break; case 'D': mv.visitInsn(DREM); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 10
Source File: OpDivide.java From java-technology-stack with MIT License | 5 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; String exitDesc = this.exitTypeDescriptor; Assert.state(exitDesc != null, "No exit type descriptor"); char targetDesc = exitDesc.charAt(0); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, targetDesc); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, targetDesc); switch (targetDesc) { case 'I': mv.visitInsn(IDIV); break; case 'J': mv.visitInsn(LDIV); break; case 'F': mv.visitInsn(FDIV); break; case 'D': mv.visitInsn(DDIV); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 11
Source File: OpMultiply.java From spring-analysis-note with MIT License | 5 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; String exitDesc = this.exitTypeDescriptor; Assert.state(exitDesc != null, "No exit type descriptor"); char targetDesc = exitDesc.charAt(0); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, targetDesc); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, targetDesc); switch (targetDesc) { case 'I': mv.visitInsn(IMUL); break; case 'J': mv.visitInsn(LMUL); break; case 'F': mv.visitInsn(FMUL); break; case 'D': mv.visitInsn(DMUL); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 12
Source File: OpModulus.java From spring-analysis-note with MIT License | 5 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; String exitDesc = this.exitTypeDescriptor; Assert.state(exitDesc != null, "No exit type descriptor"); char targetDesc = exitDesc.charAt(0); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, targetDesc); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, targetDesc); switch (targetDesc) { case 'I': mv.visitInsn(IREM); break; case 'J': mv.visitInsn(LREM); break; case 'F': mv.visitInsn(FREM); break; case 'D': mv.visitInsn(DREM); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 13
Source File: OpPlus.java From java-technology-stack with MIT License | 4 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { if ("Ljava/lang/String".equals(this.exitTypeDescriptor)) { mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); mv.visitInsn(DUP); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "()V", false); walk(mv, cf, getLeftOperand()); walk(mv, cf, getRightOperand()); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); } else { this.children[0].generateCode(mv, cf); String leftDesc = this.children[0].exitTypeDescriptor; String exitDesc = this.exitTypeDescriptor; Assert.state(exitDesc != null, "No exit type descriptor"); char targetDesc = exitDesc.charAt(0); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, targetDesc); if (this.children.length > 1) { cf.enterCompilationScope(); this.children[1].generateCode(mv, cf); String rightDesc = this.children[1].exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, targetDesc); switch (targetDesc) { case 'I': mv.visitInsn(IADD); break; case 'J': mv.visitInsn(LADD); break; case 'F': mv.visitInsn(FADD); break; case 'D': mv.visitInsn(DADD); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 14
Source File: OpMinus.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, this.exitTypeDescriptor.charAt(0)); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, this.exitTypeDescriptor.charAt(0)); switch (this.exitTypeDescriptor.charAt(0)) { case 'I': mv.visitInsn(ISUB); break; case 'J': mv.visitInsn(LSUB); break; case 'F': mv.visitInsn(FSUB); break; case 'D': mv.visitInsn(DSUB); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } else { switch (this.exitTypeDescriptor.charAt(0)) { case 'I': mv.visitInsn(INEG); break; case 'J': mv.visitInsn(LNEG); break; case 'F': mv.visitInsn(FNEG); break; case 'D': mv.visitInsn(DNEG); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 15
Source File: OpMinus.java From java-technology-stack with MIT License | 4 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; String exitDesc = this.exitTypeDescriptor; Assert.state(exitDesc != null, "No exit type descriptor"); char targetDesc = exitDesc.charAt(0); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, targetDesc); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, targetDesc); switch (targetDesc) { case 'I': mv.visitInsn(ISUB); break; case 'J': mv.visitInsn(LSUB); break; case 'F': mv.visitInsn(FSUB); break; case 'D': mv.visitInsn(DSUB); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } else { switch (targetDesc) { case 'I': mv.visitInsn(INEG); break; case 'J': mv.visitInsn(LNEG); break; case 'F': mv.visitInsn(FNEG); break; case 'D': mv.visitInsn(DNEG); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 16
Source File: OpPlus.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { if (this.exitTypeDescriptor == "Ljava/lang/String") { mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); mv.visitInsn(DUP); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "()V", false); walk(mv,cf,getLeftOperand()); walk(mv,cf,getRightOperand()); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); } else { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, this.exitTypeDescriptor.charAt(0)); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, this.exitTypeDescriptor.charAt(0)); switch (this.exitTypeDescriptor.charAt(0)) { case 'I': mv.visitInsn(IADD); break; case 'J': mv.visitInsn(LADD); break; case 'F': mv.visitInsn(FADD); break; case 'D': mv.visitInsn(DADD); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 17
Source File: OpMinus.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, this.exitTypeDescriptor.charAt(0)); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, this.exitTypeDescriptor.charAt(0)); switch (this.exitTypeDescriptor.charAt(0)) { case 'I': mv.visitInsn(ISUB); break; case 'J': mv.visitInsn(LSUB); break; case 'F': mv.visitInsn(FSUB); break; case 'D': mv.visitInsn(DSUB); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } else { switch (this.exitTypeDescriptor.charAt(0)) { case 'I': mv.visitInsn(INEG); break; case 'J': mv.visitInsn(LNEG); break; case 'F': mv.visitInsn(FNEG); break; case 'D': mv.visitInsn(DNEG); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 18
Source File: OpPlus.java From spring-analysis-note with MIT License | 4 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { if ("Ljava/lang/String".equals(this.exitTypeDescriptor)) { mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); mv.visitInsn(DUP); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "()V", false); walk(mv, cf, getLeftOperand()); walk(mv, cf, getRightOperand()); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); } else { this.children[0].generateCode(mv, cf); String leftDesc = this.children[0].exitTypeDescriptor; String exitDesc = this.exitTypeDescriptor; Assert.state(exitDesc != null, "No exit type descriptor"); char targetDesc = exitDesc.charAt(0); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, targetDesc); if (this.children.length > 1) { cf.enterCompilationScope(); this.children[1].generateCode(mv, cf); String rightDesc = this.children[1].exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, targetDesc); switch (targetDesc) { case 'I': mv.visitInsn(IADD); break; case 'J': mv.visitInsn(LADD); break; case 'F': mv.visitInsn(FADD); break; case 'D': mv.visitInsn(DADD); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 19
Source File: OpPlus.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { if (this.exitTypeDescriptor == "Ljava/lang/String") { mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); mv.visitInsn(DUP); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "()V", false); walk(mv,cf,getLeftOperand()); walk(mv,cf,getRightOperand()); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); } else { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, this.exitTypeDescriptor.charAt(0)); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, this.exitTypeDescriptor.charAt(0)); switch (this.exitTypeDescriptor.charAt(0)) { case 'I': mv.visitInsn(IADD); break; case 'J': mv.visitInsn(LADD); break; case 'F': mv.visitInsn(FADD); break; case 'D': mv.visitInsn(DADD); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } } cf.pushDescriptor(this.exitTypeDescriptor); }
Example 20
Source File: OpMinus.java From spring-analysis-note with MIT License | 4 votes |
@Override public void generateCode(MethodVisitor mv, CodeFlow cf) { getLeftOperand().generateCode(mv, cf); String leftDesc = getLeftOperand().exitTypeDescriptor; String exitDesc = this.exitTypeDescriptor; Assert.state(exitDesc != null, "No exit type descriptor"); char targetDesc = exitDesc.charAt(0); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, leftDesc, targetDesc); if (this.children.length > 1) { cf.enterCompilationScope(); getRightOperand().generateCode(mv, cf); String rightDesc = getRightOperand().exitTypeDescriptor; cf.exitCompilationScope(); CodeFlow.insertNumericUnboxOrPrimitiveTypeCoercion(mv, rightDesc, targetDesc); switch (targetDesc) { case 'I': mv.visitInsn(ISUB); break; case 'J': mv.visitInsn(LSUB); break; case 'F': mv.visitInsn(FSUB); break; case 'D': mv.visitInsn(DSUB); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } else { switch (targetDesc) { case 'I': mv.visitInsn(INEG); break; case 'J': mv.visitInsn(LNEG); break; case 'F': mv.visitInsn(FNEG); break; case 'D': mv.visitInsn(DNEG); break; default: throw new IllegalStateException( "Unrecognized exit type descriptor: '" + this.exitTypeDescriptor + "'"); } } cf.pushDescriptor(this.exitTypeDescriptor); }