|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkorat.instrumentation.AbstractInstrumenter
korat.instrumentation.FieldInstrumenter
korat.instrumentation.ArrayFieldInstrumenter
class ArrayFieldInstrumenter
This class does all the instrumentation related to array fields.
First, it replaces declarations all array fields with the corresponding
IKoratArray
field declarations. Then, in all methods, it
replaces accesses to those fields with appropriate method calls to their
corresponding IKoratArray
fields. For instance, the following
piece of code
class C { int[] foo; void f() { foo = new int[10]; foo[0] = 15; int x = foo[0]; x += foo.length() } }after the instrumentation looks like
class C { Korat_Array_int __koratArray_foo; // ... (stuff that FieldInstrumenter adds to foo field) void f() { __koratArray_foo = new Korat_Array_int(10); __koratArray_foo.set(0, 15); int x = __koratArray_foo.get(0); x += __koratArray_foo.getLength(); } }
ArrayGenerator
,
AbstractInstrumenter
,
FieldInstrumenter
,
SpecialConstructorInstrumenter
Field Summary | |
---|---|
private Set<CtField> |
fieldsToRemove
Keep the track of the arrays fields that need to be removed at the end. |
Fields inherited from class korat.instrumentation.AbstractInstrumenter |
---|
cp |
Constructor Summary | |
---|---|
ArrayFieldInstrumenter()
|
Method Summary | |
---|---|
protected void |
handleArrayFieldDeclaration(CtClass clz,
CtField f)
For the given array field creates new field of the corresponding KoratArray_fieldType type. |
protected void |
instrumentFieldDeclarations(CtClass clz)
For each field in the given class adds additional stuff needed for instrumentation (by calling handleFieldDeclaration . |
private void |
removeOriginalArrayFields(CtClass clz)
Removes original array fields from the class. |
protected void |
replaceFieldAccesses(CtClass clz)
Traverses through all methods in the given class, looks for the bytecode instructions related to arrays and modifies them appropriately. |
Methods inherited from class korat.instrumentation.FieldInstrumenter |
---|
addGetSetterMethod, addGetterMethod, addIdField, createNestedSetterClass, getGetSetterSrc, getGetterSrc, handleFieldDeclaration, instrument |
Methods inherited from class korat.instrumentation.AbstractInstrumenter |
---|
getBytecode, shouldProcessField, shouldProcessMethod |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Set<CtField> fieldsToRemove
Constructor Detail |
---|
ArrayFieldInstrumenter()
Method Detail |
---|
protected void instrumentFieldDeclarations(CtClass clz) throws NotFoundException, CannotCompileException
FieldInstrumenter
For each field in the given class adds additional stuff needed for
instrumentation (by calling handleFieldDeclaration
.
Fields of type array are not handled by this class.
instrumentFieldDeclarations
in class FieldInstrumenter
NotFoundException
CannotCompileException
protected void handleArrayFieldDeclaration(CtClass clz, CtField f) throws CannotCompileException, NotFoundException
handleNonArrayField
is called. The given field is than
added to fieldsToRemove
set since it is not possible to
delete it right away.
CannotCompileException
NotFoundException
FieldInstrumenter.handleFieldDeclaration(CtClass, CtField)
protected void replaceFieldAccesses(CtClass clz)
Traverses through all methods in the given class, looks for the bytecode instructions related to arrays and modifies them appropriately. Since all array fields have been replaced with fields of the KoratArray classes, field accesses also have to be replaced with method calls to corresponding substitution field.
replaceFieldAccesses
in class FieldInstrumenter
private void removeOriginalArrayFields(CtClass clz) throws NotFoundException
clz
- - class of the fields to be removed
NotFoundException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |