1 11 package org.eclipse.jdt.internal.core.util; 12 13 import org.eclipse.jdt.core.util.ClassFormatException; 14 import org.eclipse.jdt.core.util.IConstantPool; 15 import org.eclipse.jdt.core.util.IStackMapFrame; 16 import org.eclipse.jdt.core.util.IVerificationTypeInfo; 17 18 21 public class DefaultStackMapFrame extends ClassFileStruct implements IStackMapFrame { 22 private static final IVerificationTypeInfo[] EMPTY_LOCALS_OR_STACK_ITEMS = new IVerificationTypeInfo[0]; 23 24 private int readOffset; 25 private int numberOfLocals; 26 private int numberOfStackItems; 27 private IVerificationTypeInfo[] locals; 28 private IVerificationTypeInfo[] stackItems; 29 private int offsetDelta; 30 31 39 public DefaultStackMapFrame( 40 byte[] classFileBytes, 41 IConstantPool constantPool, 42 int offset) throws ClassFormatException { 43 this.offsetDelta = u2At(classFileBytes, 0, offset); 45 int tempLocals = u2At(classFileBytes, 2, offset); 46 this.numberOfLocals = tempLocals; 47 if (tempLocals != 0) { 48 this.locals = new IVerificationTypeInfo[tempLocals]; 49 this.readOffset = 4; 50 for (int i = 0; i < tempLocals; i++) { 51 VerificationInfo verificationInfo = new VerificationInfo(classFileBytes, constantPool, offset + this.readOffset); 52 this.locals[i] = verificationInfo; 53 this.readOffset += verificationInfo.sizeInBytes(); 54 } 55 } else { 56 this.locals = EMPTY_LOCALS_OR_STACK_ITEMS; 57 } 58 int tempStackItems = u2At(classFileBytes, readOffset, offset); 59 this.readOffset += 2; 60 this.numberOfStackItems = tempStackItems; 61 if (tempStackItems != 0) { 62 this.stackItems = new IVerificationTypeInfo[tempStackItems]; 63 for (int i = 0; i < tempStackItems; i++) { 64 VerificationInfo verificationInfo = new VerificationInfo(classFileBytes, constantPool, offset + this.readOffset); 65 this.stackItems[i] = verificationInfo; 66 this.readOffset += verificationInfo.sizeInBytes(); 67 } 68 } else { 69 this.stackItems = EMPTY_LOCALS_OR_STACK_ITEMS; 70 } 71 } 72 int sizeInBytes() { 73 return this.readOffset; 74 } 75 public int getFrameType() { 76 return 255; } 78 public IVerificationTypeInfo[] getLocals() { 79 return this.locals; 80 } 81 public int getNumberOfLocals() { 82 return this.numberOfLocals; 83 } 84 public int getNumberOfStackItems() { 85 return this.numberOfStackItems; 86 } 87 public int getOffsetDelta() { 88 return this.offsetDelta; 89 } 90 public IVerificationTypeInfo[] getStackItems() { 91 return this.stackItems; 92 } 93 } 94 | Popular Tags |