001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.transformer.bytecode.visitor; 020 021import lucee.transformer.bytecode.BytecodeContext; 022 023import org.objectweb.asm.Label; 024import org.objectweb.asm.Opcodes; 025import org.objectweb.asm.commons.GeneratorAdapter; 026 027public final class DecisionDoubleVisitor { 028 /* 029 public static final int GT=Opcodes.IF_ICMPGT; 030 public static final int GTE=Opcodes.IF_ICMPGE; 031 public static final int LT=Opcodes.IF_ICMPLT; 032 public static final int LTE=Opcodes.IF_ICMPLE; 033 public static final int EQ=Opcodes.IF_ICMPEQ; 034 public static final int NEQ=Opcodes.IF_ICMPNE; 035 */ 036 public static final int GT=Opcodes.IFLE; 037 public static final int GTE=Opcodes.IFLT; 038 public static final int LT=Opcodes.IFGE; 039 public static final int LTE=Opcodes.IFGT; 040 public static final int EQ=Opcodes.IFNE; 041 public static final int NEQ=Opcodes.IFEQ; 042 043 private int operation; 044 public void visitBegin() { 045 046 } 047 public void visitMiddle(int operation) { 048 this.operation=operation; 049 } 050 public void visitGT() { 051 this.operation=GT; 052 } 053 public void visitGTE() { 054 this.operation=GTE; 055 } 056 public void visitLT() { 057 this.operation=LT; 058 } 059 public void visitLTE() { 060 this.operation=LTE; 061 } 062 public void visitEQ() { 063 this.operation=EQ; 064 } 065 public void visitNEQ() { 066 this.operation=NEQ; 067 } 068 public void visitEnd(BytecodeContext bc) { 069 GeneratorAdapter adapter = bc.getAdapter(); 070 Label l1 = new Label(); 071 Label l2 = new Label(); 072 adapter.visitInsn(Opcodes.DCMPL); 073 adapter.visitJumpInsn(operation, l1); 074 adapter.visitInsn(Opcodes.ICONST_1); 075 adapter.visitJumpInsn(Opcodes.GOTO, l2); 076 adapter.visitLabel(l1); 077 adapter.visitInsn(Opcodes.ICONST_0); 078 adapter.visitLabel(l2); 079 } 080}