当前位置: 首页>>代码示例>>Java>>正文


Java ClassFileReader.u1At方法代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.u1At方法的典型用法代码示例。如果您正苦于以下问题:Java ClassFileReader.u1At方法的具体用法?Java ClassFileReader.u1At怎么用?Java ClassFileReader.u1At使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader的用法示例。


在下文中一共展示了ClassFileReader.u1At方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildImports

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; //导入方法依赖的package包/类
public ImportReference[] buildImports(ClassFileReader reader) {
	// add remaining references to the list of type names
	// (code extracted from BinaryIndexer#extractReferenceFromConstantPool(...))
	int[] constantPoolOffsets = reader.getConstantPoolOffsets();
	int constantPoolCount = constantPoolOffsets.length;
	for (int i = 0; i < constantPoolCount; i++) {
		int tag = reader.u1At(constantPoolOffsets[i]);
		char[] name = null;
		switch (tag) {
			case ClassFileConstants.MethodRefTag :
			case ClassFileConstants.InterfaceMethodRefTag :
				int constantPoolIndex = reader.u2At(constantPoolOffsets[i] + 3);
				int utf8Offset = constantPoolOffsets[reader.u2At(constantPoolOffsets[constantPoolIndex] + 3)];
				name = reader.utf8At(utf8Offset + 3, reader.u2At(utf8Offset + 1));
				break;
			case ClassFileConstants.ClassTag :
				utf8Offset = constantPoolOffsets[reader.u2At(constantPoolOffsets[i] + 1)];
				name = reader.utf8At(utf8Offset + 3, reader.u2At(utf8Offset + 1));
				break;
		}
		if (name == null || (name.length > 0 && name[0] == '['))
			break; // skip over array references
		this.typeNames.add(CharOperation.splitOn('/', name));
	}

	// convert type names into import references
	int typeNamesLength = this.typeNames.size();
	ImportReference[] imports = new ImportReference[typeNamesLength];
	char[][][] set = this.typeNames.set;
	int index = 0;
	for (int i = 0, length = set.length; i < length; i++) {
		char[][] typeName = set[i];
		if (typeName != null) {
			imports[index++] = new ImportReference(typeName, new long[typeName.length]/*dummy positions*/, false/*not on demand*/, 0);
		}
	}
	return imports;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:39,代码来源:BinaryTypeConverter.java

示例2: extractReferenceFromConstantPool

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; //导入方法依赖的package包/类
/**
 * Extract all type, method, field and interface method references from the constant pool
 */
private void extractReferenceFromConstantPool(byte[] contents, ClassFileReader reader) throws ClassFormatException {
	int[] constantPoolOffsets = reader.getConstantPoolOffsets();
	int constantPoolCount = constantPoolOffsets.length;
	for (int i = 1; i < constantPoolCount; i++) {
		int tag = reader.u1At(constantPoolOffsets[i]);
		/**
		 * u1 tag
		 * u2 class_index
		 * u2 name_and_type_index
		 */
		char[] name = null;
		char[] type = null;
		switch (tag) {
			case ClassFileConstants.FieldRefTag :
				// add reference to the class/interface and field name and type
				name = extractName(constantPoolOffsets, reader, i);
				addFieldReference(name);
				break;
			case ClassFileConstants.MethodRefTag :
				// add reference to the class and method name and type
			case ClassFileConstants.InterfaceMethodRefTag :
				// add reference to the interface and method name and type
				name = extractName(constantPoolOffsets, reader, i);
				type = extractType(constantPoolOffsets, reader, i);
				if (CharOperation.equals(INIT, name)) {
					// get class name and see if it's a local type or not
					char[] className = extractClassName(constantPoolOffsets, reader, i);
					boolean localType = false;
					if (className !=  null) {
						for (int c = 0, max = className.length; c < max; c++) {
							switch (className[c]) {
								case '/':
									className[c] = '.';
									break;
								case '$':
									localType = true;
									break;
							}
						}
					}
					// add a constructor reference, use class name to extract arg count if it's a local type to remove synthetic parameter
					addConstructorReference(className, extractArgCount(type, localType?className:null));
				} else {
					// add a method reference
					addMethodReference(name, extractArgCount(type, null));
				}
				break;
			case ClassFileConstants.ClassTag :
				// add a type reference
				name = extractClassReference(constantPoolOffsets, reader, i);
				if (name.length > 0 && name[0] == '[')
					break; // skip over array references
				name = replace('/', '.', name); // so that it looks like java.lang.String
				addTypeReference(name);

				// also add a simple reference on each segment of the qualification (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=24741)
				char[][] qualification = CharOperation.splitOn('.', name);
				for (int j = 0, length = qualification.length; j < length; j++) {
					addNameReference(qualification[j]);
				}
				break;
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:68,代码来源:BinaryIndexer.java


注:本文中的org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.u1At方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。