本文整理汇总了Java中org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.ATTR_LINES属性的典型用法代码示例。如果您正苦于以下问题:Java ClassFileConstants.ATTR_LINES属性的具体用法?Java ClassFileConstants.ATTR_LINES怎么用?Java ClassFileConstants.ATTR_LINES使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants
的用法示例。
在下文中一共展示了ClassFileConstants.ATTR_LINES属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CodeStream
public CodeStream(ClassFile givenClassFile) {
this.targetLevel = givenClassFile.targetJDK;
this.generateAttributes = givenClassFile.produceAttributes;
if ((givenClassFile.produceAttributes & ClassFileConstants.ATTR_LINES) != 0) {
this.lineSeparatorPositions = givenClassFile.referenceBinding.scope.referenceCompilationUnit().compilationResult.getLineSeparatorPositions();
}
}
示例2: reset
public void reset(ClassFile givenClassFile) {
this.targetLevel = givenClassFile.targetJDK;
int produceAttributes = givenClassFile.produceAttributes;
this.generateAttributes = produceAttributes;
if ((produceAttributes & ClassFileConstants.ATTR_LINES) != 0) {
this.lineSeparatorPositions = givenClassFile.referenceBinding.scope.referenceCompilationUnit().compilationResult.getLineSeparatorPositions();
} else {
this.lineSeparatorPositions = null;
}
}
示例3: 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;
}
示例4: 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);
}
}
}