org.dellroad.jc.cgen.escape
Class KnownSizeDetector

java.lang.Object
  extended bysoot.jimple.AbstractJimpleValueSwitch
      extended byorg.dellroad.jc.cgen.escape.KnownSizeDetector
All Implemented Interfaces:
ConstantSwitch, ExprSwitch, JimpleValueSwitch, RefSwitch, Switch

public class KnownSizeDetector
extends AbstractJimpleValueSwitch

Instances of this class detect 'new' expressions with a known instance size. The result is an Integer with the estimated size, or null if the type of the 'new' expression does not have a fixed size (or the value is not some kind of 'new' expression).


Nested Class Summary
static class KnownSizeDetector.SizeTypeSwitch
          Computes the size in bytes of an instance of a type.
 
Field Summary
static int OBJECT_HEADER_SIZE
           
static int REFERENCE_SIZE
           
 
Constructor Summary
KnownSizeDetector()
           
 
Method Summary
 void caseNewArrayExpr(NewArrayExpr v)
           
 void caseNewExpr(NewExpr v)
           
 void caseNewMultiArrayExpr(NewMultiArrayExpr v)
           
 void defaultCase(Object obj)
           
static int size(Type type)
          Return our best guess of the size of an instance of the given type, in bytes.
 
Methods inherited from class soot.jimple.AbstractJimpleValueSwitch
caseAddExpr, caseAndExpr, caseArrayRef, caseCastExpr, caseCaughtExceptionRef, caseCmpExpr, caseCmpgExpr, caseCmplExpr, caseDivExpr, caseDoubleConstant, caseEqExpr, caseFloatConstant, caseGeExpr, caseGtExpr, caseInstanceFieldRef, caseInstanceOfExpr, caseIntConstant, caseInterfaceInvokeExpr, caseLeExpr, caseLengthExpr, caseLocal, caseLongConstant, caseLtExpr, caseMulExpr, caseNeExpr, caseNegExpr, caseNullConstant, caseOrExpr, caseParameterRef, caseRemExpr, caseShlExpr, caseShrExpr, caseSpecialInvokeExpr, caseStaticFieldRef, caseStaticInvokeExpr, caseStringConstant, caseSubExpr, caseThisRef, caseUshrExpr, caseVirtualInvokeExpr, caseXorExpr, getResult, setResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REFERENCE_SIZE

public static final int REFERENCE_SIZE
See Also:
Constant Field Values

OBJECT_HEADER_SIZE

public static final int OBJECT_HEADER_SIZE
See Also:
Constant Field Values
Constructor Detail

KnownSizeDetector

public KnownSizeDetector()
Method Detail

caseNewExpr

public void caseNewExpr(NewExpr v)

caseNewArrayExpr

public void caseNewArrayExpr(NewArrayExpr v)

caseNewMultiArrayExpr

public void caseNewMultiArrayExpr(NewMultiArrayExpr v)

defaultCase

public void defaultCase(Object obj)

size

public static int size(Type type)
Return our best guess of the size of an instance of the given type, in bytes. We include OBJECT_HEADER_SIZE for object overhead, but don't include any gaps for alignment.

Parameters:
type - a primitive type, or a non-interface, non-array reference type.
Throws:
IllegalArgumentException - if type