本文整理汇总了Java中org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.ATTR_STACK_MAP属性的典型用法代码示例。如果您正苦于以下问题:Java ClassFileConstants.ATTR_STACK_MAP属性的具体用法?Java ClassFileConstants.ATTR_STACK_MAP怎么用?Java ClassFileConstants.ATTR_STACK_MAP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants
的用法示例。
在下文中一共展示了ClassFileConstants.ATTR_STACK_MAP属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exitUserScope
public void exitUserScope(BlockScope currentScope) {
// mark all the scope's locals as losing their definite assignment
if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
| ClassFileConstants.ATTR_STACK_MAP_TABLE
| ClassFileConstants.ATTR_STACK_MAP)) == 0)
return;
int index = this.visibleLocalsCount - 1;
while (index >= 0) {
LocalVariableBinding visibleLocal = this.visibleLocals[index];
if (visibleLocal == null || visibleLocal.declaringScope != currentScope) {
// left currentScope
index--;
continue;
}
// there may be some preserved locals never initialized
if (visibleLocal.initializationCount > 0) {
visibleLocal.recordInitializationEndPC(this.position);
}
this.visibleLocals[index--] = null; // this variable is no longer visible afterwards
}
}
示例2: ClassFile
public ClassFile(SourceTypeBinding typeBinding) {
// default constructor for subclasses
this.constantPool = new ConstantPool(this);
final CompilerOptions options = typeBinding.scope.compilerOptions();
this.targetJDK = options.targetJDK;
this.produceAttributes = options.produceDebugAttributes;
this.referenceBinding = typeBinding;
this.isNestedType = typeBinding.isNestedType();
if (this.targetJDK >= ClassFileConstants.JDK1_6) {
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP_TABLE;
this.codeStream = new StackMapFrameCodeStream(this);
} else if (this.targetJDK == ClassFileConstants.CLDC_1_1) {
this.targetJDK = ClassFileConstants.JDK1_1; // put back 45.3
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP;
this.codeStream = new StackMapFrameCodeStream(this);
} else {
this.codeStream = new CodeStream(this);
}
initByteArrays();
}
示例3: ClassFile
public ClassFile(SourceTypeBinding typeBinding) {
// default constructor for subclasses
this.constantPool = new ConstantPool(this);
final CompilerOptions options = typeBinding.scope.compilerOptions();
this.targetJDK = options.targetJDK;
this.produceAttributes = options.produceDebugAttributes;
this.referenceBinding = typeBinding;
this.isNestedType = typeBinding.isNestedType();
if (this.targetJDK >= ClassFileConstants.JDK1_6) {
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP_TABLE;
if (this.targetJDK >= ClassFileConstants.JDK1_8) {
this.produceAttributes |= ClassFileConstants.ATTR_TYPE_ANNOTATION;
this.codeStream = new TypeAnnotationCodeStream(this);
if (options.produceMethodParameters) {
this.produceAttributes |= ClassFileConstants.ATTR_METHOD_PARAMETERS;
}
} else {
this.codeStream = new StackMapFrameCodeStream(this);
}
} else if (this.targetJDK == ClassFileConstants.CLDC_1_1) {
this.targetJDK = ClassFileConstants.JDK1_1; // put back 45.3
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP;
this.codeStream = new StackMapFrameCodeStream(this);
} else {
this.codeStream = new CodeStream(this);
}
initByteArrays();
}
示例4: reset
public void reset(SourceTypeBinding typeBinding) {
// the code stream is reinitialized for each method
final CompilerOptions options = typeBinding.scope.compilerOptions();
this.referenceBinding = typeBinding;
this.isNestedType = typeBinding.isNestedType();
this.targetJDK = options.targetJDK;
this.produceAttributes = options.produceDebugAttributes;
if (this.targetJDK >= ClassFileConstants.JDK1_6) {
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP_TABLE;
if (this.targetJDK >= ClassFileConstants.JDK1_8) {
this.produceAttributes |= ClassFileConstants.ATTR_TYPE_ANNOTATION;
if (options.produceMethodParameters) {
this.produceAttributes |= ClassFileConstants.ATTR_METHOD_PARAMETERS;
}
}
} else if (this.targetJDK == ClassFileConstants.CLDC_1_1) {
this.targetJDK = ClassFileConstants.JDK1_1; // put back 45.3
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP;
}
this.bytes = null;
this.constantPool.reset();
this.codeStream.reset(this);
this.constantPoolOffset = 0;
this.contentsOffset = 0;
this.creatingProblemType = false;
this.enclosingClassFile = null;
this.headerOffset = 0;
this.methodCount = 0;
this.methodCountOffset = 0;
if (this.innerClassesBindings != null) {
this.innerClassesBindings.clear();
}
if (this.bootstrapMethods != null) {
this.bootstrapMethods.clear();
}
this.missingTypes = null;
this.visitedTypes = null;
}
示例5: addDefinitelyAssignedVariables
public void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
// Required to fix 1PR0XVS: LFRE:WINNT - Compiler: variable table for method appears incorrect
if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
| ClassFileConstants.ATTR_STACK_MAP_TABLE
| ClassFileConstants.ATTR_STACK_MAP)) == 0)
return;
for (int i = 0; i < this.visibleLocalsCount; i++) {
LocalVariableBinding localBinding = this.visibleLocals[i];
if (localBinding != null) {
// Check if the local is definitely assigned
if (isDefinitelyAssigned(scope, initStateIndex, localBinding)) {
if ((localBinding.initializationCount == 0) || (localBinding.initializationPCs[((localBinding.initializationCount - 1) << 1) + 1] != -1)) {
/* There are two cases:
* 1) there is no initialization interval opened ==> add an opened interval
* 2) there is already some initialization intervals but the last one is closed ==> add an opened interval
* An opened interval means that the value at localBinding.initializationPCs[localBinding.initializationCount - 1][1]
* is equals to -1.
* initializationPCs is a collection of pairs of int:
* first value is the startPC and second value is the endPC. -1 one for the last value means that the interval
* is not closed yet.
*/
localBinding.recordInitializationStartPC(this.position);
}
}
}
}
}
示例6: addVisibleLocalVariable
public void addVisibleLocalVariable(LocalVariableBinding localBinding) {
if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
| ClassFileConstants.ATTR_STACK_MAP_TABLE
| ClassFileConstants.ATTR_STACK_MAP)) == 0)
return;
if (this.visibleLocalsCount >= this.visibleLocals.length)
System.arraycopy(this.visibleLocals, 0, this.visibleLocals = new LocalVariableBinding[this.visibleLocalsCount * 2], 0, this.visibleLocalsCount);
this.visibleLocals[this.visibleLocalsCount++] = localBinding;
}
示例7: record
public void record(LocalVariableBinding local) {
if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
| ClassFileConstants.ATTR_STACK_MAP_TABLE
| ClassFileConstants.ATTR_STACK_MAP)) == 0)
return;
if (this.allLocalsCounter == this.locals.length) {
// resize the collection
System.arraycopy(this.locals, 0, this.locals = new LocalVariableBinding[this.allLocalsCounter + LOCALS_INCREMENT], 0, this.allLocalsCounter);
}
this.locals[this.allLocalsCounter++] = local;
local.initializationPCs = new int[4];
local.initializationCount = 0;
}
示例8: removeNotDefinitelyAssignedVariables
public void removeNotDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
// given some flow info, make sure we did not loose some variables initialization
// if this happens, then we must update their pc entries to reflect it in debug attributes
if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
| ClassFileConstants.ATTR_STACK_MAP_TABLE
| ClassFileConstants.ATTR_STACK_MAP)) == 0)
return;
for (int i = 0; i < this.visibleLocalsCount; i++) {
LocalVariableBinding localBinding = this.visibleLocals[i];
if (localBinding != null && !isDefinitelyAssigned(scope, initStateIndex, localBinding) && localBinding.initializationCount > 0) {
localBinding.recordInitializationEndPC(this.position);
}
}
}
示例9: completeCodeAttributeForMissingAbstractProblemMethod
/**
*
*/
public void completeCodeAttributeForMissingAbstractProblemMethod(
MethodBinding binding,
int codeAttributeOffset,
int[] startLineIndexes,
int problemLine) {
// reinitialize the localContents with the byte modified by the code stream
this.contents = this.codeStream.bCodeStream;
int localContentsOffset = this.codeStream.classFileOffset;
// codeAttributeOffset is the position inside localContents byte array before we started to write// any information about the codeAttribute// That means that to write the attribute_length you need to offset by 2 the value of codeAttributeOffset// to get the right position, 6 for the max_stack etc...
int max_stack = this.codeStream.stackMax;
this.contents[codeAttributeOffset + 6] = (byte) (max_stack >> 8);
this.contents[codeAttributeOffset + 7] = (byte) max_stack;
int max_locals = this.codeStream.maxLocals;
this.contents[codeAttributeOffset + 8] = (byte) (max_locals >> 8);
this.contents[codeAttributeOffset + 9] = (byte) max_locals;
int code_length = this.codeStream.position;
this.contents[codeAttributeOffset + 10] = (byte) (code_length >> 24);
this.contents[codeAttributeOffset + 11] = (byte) (code_length >> 16);
this.contents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
this.contents[codeAttributeOffset + 13] = (byte) code_length;
// write the exception table
if (localContentsOffset + 50 >= this.contents.length) {
resizeContents(50);
}
this.contents[localContentsOffset++] = 0;
this.contents[localContentsOffset++] = 0;
// debug attributes
int codeAttributeAttributeOffset = localContentsOffset;
int attributesNumber = 0; // leave two bytes for the attribute_length
localContentsOffset += 2; // first we handle the linenumber attribute
if (localContentsOffset + 2 >= this.contents.length) {
resizeContents(2);
}
this.contentsOffset = localContentsOffset;
if ((this.produceAttributes & ClassFileConstants.ATTR_LINES) != 0) {
if (problemLine == 0) {
problemLine = Util.getLineNumber(binding.sourceStart(), startLineIndexes, 0, startLineIndexes.length-1);
}
attributesNumber += generateLineNumberAttribute(problemLine);
}
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0) {
attributesNumber += generateStackMapTableAttribute(
binding,
code_length,
codeAttributeOffset,
max_locals,
false);
}
if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
attributesNumber += generateStackMapAttribute(
binding,
code_length,
codeAttributeOffset,
max_locals,
false);
}
// then we do the local variable attribute
// update the number of attributes// ensure first that there is enough space available inside the localContents array
if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
resizeContents(2);
}
this.contents[codeAttributeAttributeOffset++] = (byte) (attributesNumber >> 8);
this.contents[codeAttributeAttributeOffset] = (byte) attributesNumber;
// update the attribute length
int codeAttributeLength = this.contentsOffset - (codeAttributeOffset + 6);
this.contents[codeAttributeOffset + 2] = (byte) (codeAttributeLength >> 24);
this.contents[codeAttributeOffset + 3] = (byte) (codeAttributeLength >> 16);
this.contents[codeAttributeOffset + 4] = (byte) (codeAttributeLength >> 8);
this.contents[codeAttributeOffset + 5] = (byte) codeAttributeLength;
}
示例10: place
public void place() { // Currently lacking wide support.
// if ((this.tagBits & USED) == 0 && this.forwardReferenceCount == 0) {
// return;
// }
//TODO how can position be set already ? cannot place more than once
if (this.position == Label.POS_NOT_SET) {
this.position = this.codeStream.position;
this.codeStream.addLabel(this);
int oldPosition = this.position;
boolean isOptimizedBranch = false;
if (this.forwardReferenceCount != 0) {
isOptimizedBranch = (this.forwardReferences[this.forwardReferenceCount - 1] + 2 == this.position) && (this.codeStream.bCodeStream[this.codeStream.classFileOffset - 3] == Opcodes.OPC_goto);
if (isOptimizedBranch) {
if (this.codeStream.lastAbruptCompletion == this.position) {
this.codeStream.lastAbruptCompletion = -1;
}
this.codeStream.position = (this.position -= 3);
this.codeStream.classFileOffset -= 3;
this.forwardReferenceCount--;
if (this.codeStream.lastEntryPC == oldPosition) {
this.codeStream.lastEntryPC = this.position;
}
// end of new code
if ((this.codeStream.generateAttributes & (ClassFileConstants.ATTR_VARS | ClassFileConstants.ATTR_STACK_MAP_TABLE | ClassFileConstants.ATTR_STACK_MAP)) != 0) {
LocalVariableBinding locals[] = this.codeStream.locals;
for (int i = 0, max = locals.length; i < max; i++) {
LocalVariableBinding local = locals[i];
if ((local != null) && (local.initializationCount > 0)) {
if (local.initializationPCs[((local.initializationCount - 1) << 1) + 1] == oldPosition) {
// we want to prevent interval of size 0 to have a negative size.
// see PR 1GIRQLA: ITPJCORE:ALL - ClassFormatError for local variable attribute
local.initializationPCs[((local.initializationCount - 1) << 1) + 1] = this.position;
}
if (local.initializationPCs[(local.initializationCount - 1) << 1] == oldPosition) {
local.initializationPCs[(local.initializationCount - 1) << 1] = this.position;
}
}
}
}
if ((this.codeStream.generateAttributes & ClassFileConstants.ATTR_LINES) != 0) {
// we need to remove all entries that is beyond this.position inside the pcToSourcerMap table
this.codeStream.removeUnusedPcToSourceMapEntries();
}
}
}
for (int i = 0; i < this.forwardReferenceCount; i++) {
this.codeStream.writePosition(this, this.forwardReferences[i]);
}
// For all labels placed at that position we check if we need to rewrite the jump
// offset. It is the case each time a label had a forward reference to the current position.
// Like we change the current position, we have to change the jump offset. See 1F4IRD9 for more details.
if (isOptimizedBranch) {
this.codeStream.optimizeBranch(oldPosition, this);
}
}
}
示例11: StackMapFrameCodeStream
public StackMapFrameCodeStream(ClassFile givenClassFile) {
super(givenClassFile);
this.generateAttributes |= ClassFileConstants.ATTR_STACK_MAP;
}