|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120 |
- package org.aspectj.apache.bcel.verifier.structurals;
-
- /* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache BCEL" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
- * written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * "Apache BCEL", nor may "Apache" appear in their name, without
- * prior written permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
- import org.aspectj.apache.bcel.Constants;
- import org.aspectj.apache.bcel.classfile.Constant;
- import org.aspectj.apache.bcel.classfile.ConstantDouble;
- import org.aspectj.apache.bcel.classfile.ConstantFloat;
- import org.aspectj.apache.bcel.classfile.ConstantInteger;
- import org.aspectj.apache.bcel.classfile.ConstantLong;
- import org.aspectj.apache.bcel.classfile.ConstantString;
- import org.aspectj.apache.bcel.generic.*;
-
- /**
- * This Visitor class may be used for a type-based Java Virtual Machine
- * simulation.
- * It does not check for correct types on the OperandStack or in the
- * LocalVariables; nor does it check their sizes are sufficiently big.
- * Thus, to use this Visitor for bytecode verifying, you have to make sure
- * externally that the type constraints of the Java Virtual Machine instructions
- * are satisfied. An InstConstraintVisitor may be used for this.
- * Anyway, this Visitor does not mandate it. For example, when you
- * visitIADD(IADD o), then there are two stack slots popped and one
- * stack slot containing a Type.INT is pushed (where you could also
- * pop only one slot if you know there are two Type.INT on top of the
- * stack). Monitor-specific behaviour is not simulated.
- *
- * </P><B>Conventions:</B>
- *
- * Type.VOID will never be pushed onto the stack. Type.DOUBLE and Type.LONG
- * that would normally take up two stack slots (like Double_HIGH and
- * Double_LOW) are represented by a simple single Type.DOUBLE or Type.LONG
- * object on the stack here.
- * If a two-slot type is stored into a local variable, the next variable
- * is given the type Type.UNKNOWN.
- *
- * @version $Id: ExecutionVisitor.java,v 1.5 2005/02/02 09:11:39 aclement Exp $
- * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
- * @see #visitDSTORE(DSTORE o)
- * @see InstConstraintVisitor
- */
- public class ExecutionVisitor extends EmptyVisitor implements Visitor{
-
- /**
- * The executionframe we're operating on.
- */
- private Frame frame = null;
-
- /**
- * The ConstantPoolGen we're working with.
- * @see #setConstantPoolGen(ConstantPoolGen)
- */
- private ConstantPoolGen cpg = null;
-
- /**
- * Constructor. Constructs a new instance of this class.
- */
- public ExecutionVisitor(){}
-
- /**
- * The OperandStack from the current Frame we're operating on.
- * @see #setFrame(Frame)
- */
- private OperandStack stack(){
- return frame.getStack();
- }
-
- /**
- * The LocalVariables from the current Frame we're operating on.
- * @see #setFrame(Frame)
- */
- private LocalVariables locals(){
- return frame.getLocals();
- }
-
- /**
- * Sets the ConstantPoolGen needed for symbolic execution.
- */
- public void setConstantPoolGen(ConstantPoolGen cpg){
- this.cpg = cpg;
- }
-
- /**
- * The only method granting access to the single instance of
- * the ExecutionVisitor class. Before actively using this
- * instance, <B>SET THE ConstantPoolGen FIRST</B>.
- * @see #setConstantPoolGen(ConstantPoolGen)
- */
- public void setFrame(Frame f){
- this.frame = f;
- }
-
- ///** Symbolically executes the corresponding Java Virtual Machine instruction. */
- //public void visitWIDE(WIDE o){
- // The WIDE instruction is modelled as a flag
- // of the embedded instructions in BCEL.
- // Therefore BCEL checks for possible errors
- // when parsing in the .class file: We don't
- // have even the possibilty to care for WIDE
- // here.
- //}
-
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitAALOAD(AALOAD o){
- stack().pop(); // pop the index int
- //System.out.print(stack().peek());
- Type t = stack().pop(); // Pop Array type
- if (t == Type.NULL){
- stack().push(Type.NULL);
- } // Do nothing stackwise --- a NullPointerException is thrown at Run-Time
- else{
- ArrayType at = (ArrayType) t;
- stack().push(at.getElementType());
- }
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitAASTORE(AASTORE o){
- stack().pop();
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitACONST_NULL(ACONST_NULL o){
- stack().push(Type.NULL);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitALOAD(ALOAD o){
- stack().push(locals().get(o.getIndex()));
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitANEWARRAY(ANEWARRAY o){
- stack().pop(); //count
- stack().push( new ArrayType(o.getType(cpg), 1) );
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitARETURN(ARETURN o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitARRAYLENGTH(ARRAYLENGTH o){
- stack().pop();
- stack().push(Type.INT);
- }
-
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitASTORE(ASTORE o){
- locals().set(o.getIndex(), stack().pop());
- //System.err.println("TODO-DEBUG: set LV '"+o.getIndex()+"' to '"+locals().get(o.getIndex())+"'.");
- }
-
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitATHROW(ATHROW o){
- Type t = stack().pop();
- stack().clear();
- if (t.equals(Type.NULL))
- stack().push(Type.getType("Ljava/lang/NullPointerException;"));
- else
- stack().push(t);
- }
-
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitBALOAD(BALOAD o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
-
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitBASTORE(BASTORE o){
- stack().pop();
- stack().pop();
- stack().pop();
- }
-
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitBIPUSH(BIPUSH o){
- stack().push(Type.INT);
- }
-
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitCALOAD(CALOAD o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitCASTORE(CASTORE o){
- stack().pop();
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitCHECKCAST(CHECKCAST o){
- // It's possibly wrong to do so, but SUN's
- // ByteCode verifier seems to do (only) this, too.
- // TODO: One could use a sophisticated analysis here to check
- // if a type cannot possibly be cated to another and by
- // so doing predict the ClassCastException at run-time.
- stack().pop();
- stack().push(o.getType(cpg));
- }
-
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitD2F(D2F o){
- stack().pop();
- stack().push(Type.FLOAT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitD2I(D2I o){
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitD2L(D2L o){
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDADD(DADD o){
- stack().pop();
- stack().pop();
- stack().push(Type.DOUBLE);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDALOAD(DALOAD o){
- stack().pop();
- stack().pop();
- stack().push(Type.DOUBLE);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDASTORE(DASTORE o){
- stack().pop();
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDCMPG(DCMPG o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDCMPL(DCMPL o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDCONST(DCONST o){
- stack().push(Type.DOUBLE);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDDIV(DDIV o){
- stack().pop();
- stack().pop();
- stack().push(Type.DOUBLE);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDLOAD(DLOAD o){
- stack().push(Type.DOUBLE);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDMUL(DMUL o){
- stack().pop();
- stack().pop();
- stack().push(Type.DOUBLE);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDNEG(DNEG o){
- stack().pop();
- stack().push(Type.DOUBLE);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDREM(DREM o){
- stack().pop();
- stack().pop();
- stack().push(Type.DOUBLE);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDRETURN(DRETURN o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDSTORE(DSTORE o){
- locals().set(o.getIndex(), stack().pop());
- locals().set(o.getIndex()+1, Type.UNKNOWN);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDSUB(DSUB o){
- stack().pop();
- stack().pop();
- stack().push(Type.DOUBLE);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDUP(DUP o){
- Type t = stack().pop();
- stack().push(t);
- stack().push(t);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDUP_X1(DUP_X1 o){
- Type w1 = stack().pop();
- Type w2 = stack().pop();
- stack().push(w1);
- stack().push(w2);
- stack().push(w1);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDUP_X2(DUP_X2 o){
- Type w1 = stack().pop();
- Type w2 = stack().pop();
- if (w2.getSize() == 2){
- stack().push(w1);
- stack().push(w2);
- stack().push(w1);
- }
- else{
- Type w3 = stack().pop();
- stack().push(w1);
- stack().push(w3);
- stack().push(w2);
- stack().push(w1);
- }
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDUP2(DUP2 o){
- Type t = stack().pop();
- if (t.getSize() == 2){
- stack().push(t);
- stack().push(t);
- }
- else{ // t.getSize() is 1
- Type u = stack().pop();
- stack().push(u);
- stack().push(t);
- stack().push(u);
- stack().push(t);
- }
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDUP2_X1(DUP2_X1 o){
- Type t = stack().pop();
- if (t.getSize() == 2){
- Type u = stack().pop();
- stack().push(t);
- stack().push(u);
- stack().push(t);
- }
- else{ //t.getSize() is1
- Type u = stack().pop();
- Type v = stack().pop();
- stack().push(u);
- stack().push(t);
- stack().push(v);
- stack().push(u);
- stack().push(t);
- }
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitDUP2_X2(DUP2_X2 o){
- Type t = stack().pop();
- if (t.getSize() == 2){
- Type u = stack().pop();
- if (u.getSize() == 2){
- stack().push(t);
- stack().push(u);
- stack().push(t);
- }else{
- Type v = stack().pop();
- stack().push(t);
- stack().push(v);
- stack().push(u);
- stack().push(t);
- }
- }
- else{ //t.getSize() is 1
- Type u = stack().pop();
- Type v = stack().pop();
- if (v.getSize() == 2){
- stack().push(u);
- stack().push(t);
- stack().push(v);
- stack().push(u);
- stack().push(t);
- }else{
- Type w = stack().pop();
- stack().push(u);
- stack().push(t);
- stack().push(w);
- stack().push(v);
- stack().push(u);
- stack().push(t);
- }
- }
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitF2D(F2D o){
- stack().pop();
- stack().push(Type.DOUBLE);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitF2I(F2I o){
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitF2L(F2L o){
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitFADD(FADD o){
- stack().pop();
- stack().pop();
- stack().push(Type.FLOAT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitFALOAD(FALOAD o){
- stack().pop();
- stack().pop();
- stack().push(Type.FLOAT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitFASTORE(FASTORE o){
- stack().pop();
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitFCMPG(FCMPG o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitFCMPL(FCMPL o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitFCONST(FCONST o){
- stack().push(Type.FLOAT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitFDIV(FDIV o){
- stack().pop();
- stack().pop();
- stack().push(Type.FLOAT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitFLOAD(FLOAD o){
- stack().push(Type.FLOAT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitFMUL(FMUL o){
- stack().pop();
- stack().pop();
- stack().push(Type.FLOAT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitFNEG(FNEG o){
- stack().pop();
- stack().push(Type.FLOAT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitFREM(FREM o){
- stack().pop();
- stack().pop();
- stack().push(Type.FLOAT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitFRETURN(FRETURN o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitFSTORE(FSTORE o){
- locals().set(o.getIndex(), stack().pop());
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitFSUB(FSUB o){
- stack().pop();
- stack().pop();
- stack().push(Type.FLOAT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitGETFIELD(GETFIELD o){
- stack().pop();
- Type t = o.getFieldType(cpg);
- if ( t.equals(Type.BOOLEAN) ||
- t.equals(Type.CHAR) ||
- t.equals(Type.BYTE) ||
- t.equals(Type.SHORT) )
- t = Type.INT;
- stack().push(t);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitGETSTATIC(GETSTATIC o){
- Type t = o.getFieldType(cpg);
- if ( t.equals(Type.BOOLEAN) ||
- t.equals(Type.CHAR) ||
- t.equals(Type.BYTE) ||
- t.equals(Type.SHORT) )
- t = Type.INT;
- stack().push(t);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitGOTO(GOTO o){
- // no stack changes.
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitGOTO_W(GOTO_W o){
- // no stack changes.
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitI2B(I2B o){
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitI2C(I2C o){
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitI2D(I2D o){
- stack().pop();
- stack().push(Type.DOUBLE);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitI2F(I2F o){
- stack().pop();
- stack().push(Type.FLOAT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitI2L(I2L o){
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitI2S(I2S o){
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIADD(IADD o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIALOAD(IALOAD o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIAND(IAND o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIASTORE(IASTORE o){
- stack().pop();
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitICONST(ICONST o){
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIDIV(IDIV o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIF_ACMPEQ(IF_ACMPEQ o){
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIF_ACMPNE(IF_ACMPNE o){
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIF_ICMPEQ(IF_ICMPEQ o){
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIF_ICMPGE(IF_ICMPGE o){
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIF_ICMPGT(IF_ICMPGT o){
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIF_ICMPLE(IF_ICMPLE o){
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIF_ICMPLT(IF_ICMPLT o){
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIF_ICMPNE(IF_ICMPNE o){
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIFEQ(IFEQ o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIFGE(IFGE o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIFGT(IFGT o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIFLE(IFLE o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIFLT(IFLT o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIFNE(IFNE o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIFNONNULL(IFNONNULL o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIFNULL(IFNULL o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIINC(IINC o){
- // stack is not changed.
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitILOAD(ILOAD o){
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIMUL(IMUL o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitINEG(INEG o){
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitINSTANCEOF(INSTANCEOF o){
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitINVOKEINTERFACE(INVOKEINTERFACE o){
- stack().pop(); //objectref
- for (int i=0; i<o.getArgumentTypes(cpg).length; i++){
- stack().pop();
- }
- // We are sure the invoked method will xRETURN eventually
- // We simulate xRETURNs functionality here because we
- // don't really "jump into" and simulate the invoked
- // method.
- if (o.getReturnType(cpg) != Type.VOID){
- Type t = o.getReturnType(cpg);
- if ( t.equals(Type.BOOLEAN) ||
- t.equals(Type.CHAR) ||
- t.equals(Type.BYTE) ||
- t.equals(Type.SHORT) )
- t = Type.INT;
- stack().push(t);
- }
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitINVOKESPECIAL(INVOKESPECIAL o){
- if (o.getMethodName(cpg).equals(Constants.CONSTRUCTOR_NAME)){
- UninitializedObjectType t = (UninitializedObjectType) stack().peek(o.getArgumentTypes(cpg).length);
- if (t == Frame._this){
- Frame._this = null;
- }
- stack().initializeObject(t);
- locals().initializeObject(t);
- }
- stack().pop(); //objectref
- for (int i=0; i<o.getArgumentTypes(cpg).length; i++){
- stack().pop();
- }
- // We are sure the invoked method will xRETURN eventually
- // We simulate xRETURNs functionality here because we
- // don't really "jump into" and simulate the invoked
- // method.
- if (o.getReturnType(cpg) != Type.VOID){
- Type t = o.getReturnType(cpg);
- if ( t.equals(Type.BOOLEAN) ||
- t.equals(Type.CHAR) ||
- t.equals(Type.BYTE) ||
- t.equals(Type.SHORT) )
- t = Type.INT;
- stack().push(t);
- }
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitINVOKESTATIC(INVOKESTATIC o){
- for (int i=0; i<o.getArgumentTypes(cpg).length; i++){
- stack().pop();
- }
- // We are sure the invoked method will xRETURN eventually
- // We simulate xRETURNs functionality here because we
- // don't really "jump into" and simulate the invoked
- // method.
- if (o.getReturnType(cpg) != Type.VOID){
- Type t = o.getReturnType(cpg);
- if ( t.equals(Type.BOOLEAN) ||
- t.equals(Type.CHAR) ||
- t.equals(Type.BYTE) ||
- t.equals(Type.SHORT) )
- t = Type.INT;
- stack().push(t);
- }
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitINVOKEVIRTUAL(INVOKEVIRTUAL o){
- stack().pop(); //objectref
- for (int i=0; i<o.getArgumentTypes(cpg).length; i++){
- stack().pop();
- }
- // We are sure the invoked method will xRETURN eventually
- // We simulate xRETURNs functionality here because we
- // don't really "jump into" and simulate the invoked
- // method.
- if (o.getReturnType(cpg) != Type.VOID){
- Type t = o.getReturnType(cpg);
- if ( t.equals(Type.BOOLEAN) ||
- t.equals(Type.CHAR) ||
- t.equals(Type.BYTE) ||
- t.equals(Type.SHORT) )
- t = Type.INT;
- stack().push(t);
- }
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIOR(IOR o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIREM(IREM o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIRETURN(IRETURN o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitISHL(ISHL o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitISHR(ISHR o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitISTORE(ISTORE o){
- locals().set(o.getIndex(), stack().pop());
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitISUB(ISUB o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIUSHR(IUSHR o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitIXOR(IXOR o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
-
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitJSR(JSR o){
- stack().push(new ReturnaddressType(o.physicalSuccessor()));
- //System.err.println("TODO-----------:"+o.physicalSuccessor());
- }
-
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitJSR_W(JSR_W o){
- stack().push(new ReturnaddressType(o.physicalSuccessor()));
- }
-
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitL2D(L2D o){
- stack().pop();
- stack().push(Type.DOUBLE);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitL2F(L2F o){
- stack().pop();
- stack().push(Type.FLOAT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitL2I(L2I o){
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLADD(LADD o){
- stack().pop();
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLALOAD(LALOAD o){
- stack().pop();
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLAND(LAND o){
- stack().pop();
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLASTORE(LASTORE o){
- stack().pop();
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLCMP(LCMP o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLCONST(LCONST o){
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLDC(LDC o){
- Constant c = cpg.getConstant(o.getIndex());
- if (c instanceof ConstantInteger){
- stack().push(Type.INT);
- }
- if (c instanceof ConstantFloat){
- stack().push(Type.FLOAT);
- }
- if (c instanceof ConstantString){
- stack().push(Type.STRING);
- }
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLDC_W(LDC_W o){
- Constant c = cpg.getConstant(o.getIndex());
- if (c instanceof ConstantInteger){
- stack().push(Type.INT);
- }
- if (c instanceof ConstantFloat){
- stack().push(Type.FLOAT);
- }
- if (c instanceof ConstantString){
- stack().push(Type.STRING);
- }
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLDC2_W(LDC2_W o){
- Constant c = cpg.getConstant(o.getIndex());
- if (c instanceof ConstantLong){
- stack().push(Type.LONG);
- }
- if (c instanceof ConstantDouble){
- stack().push(Type.DOUBLE);
- }
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLDIV(LDIV o){
- stack().pop();
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLLOAD(LLOAD o){
- stack().push(locals().get(o.getIndex()));
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLMUL(LMUL o){
- stack().pop();
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLNEG(LNEG o){
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLOOKUPSWITCH(LOOKUPSWITCH o){
- stack().pop(); //key
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLOR(LOR o){
- stack().pop();
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLREM(LREM o){
- stack().pop();
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLRETURN(LRETURN o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLSHL(LSHL o){
- stack().pop();
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLSHR(LSHR o){
- stack().pop();
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLSTORE(LSTORE o){
- locals().set(o.getIndex(), stack().pop());
- locals().set(o.getIndex()+1, Type.UNKNOWN);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLSUB(LSUB o){
- stack().pop();
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLUSHR(LUSHR o){
- stack().pop();
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitLXOR(LXOR o){
- stack().pop();
- stack().pop();
- stack().push(Type.LONG);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitMONITORENTER(MONITORENTER o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitMONITOREXIT(MONITOREXIT o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitMULTIANEWARRAY(MULTIANEWARRAY o){
- for (int i=0; i<o.getDimensions(); i++){
- stack().pop();
- }
- stack().push(o.getType(cpg));
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitNEW(NEW o){
- stack().push(new UninitializedObjectType((ObjectType) (o.getType(cpg))));
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitNEWARRAY(NEWARRAY o){
- stack().pop();
- stack().push(o.getType());
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitNOP(NOP o){
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitPOP(POP o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitPOP2(POP2 o){
- Type t = stack().pop();
- if (t.getSize() == 1){
- stack().pop();
- }
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitPUTFIELD(PUTFIELD o){
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitPUTSTATIC(PUTSTATIC o){
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitRET(RET o){
- // do nothing, return address
- // is in in the local variables.
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitRETURN(RETURN o){
- // do nothing.
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitSALOAD(SALOAD o){
- stack().pop();
- stack().pop();
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitSASTORE(SASTORE o){
- stack().pop();
- stack().pop();
- stack().pop();
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitSIPUSH(SIPUSH o){
- stack().push(Type.INT);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitSWAP(SWAP o){
- Type t = stack().pop();
- Type u = stack().pop();
- stack().push(t);
- stack().push(u);
- }
- /** Symbolically executes the corresponding Java Virtual Machine instruction. */
- public void visitTABLESWITCH(TABLESWITCH o){
- stack().pop();
- }
- }
|