use of com.android.dx.rop.cst.CstString in project buck by facebook.
the class AnnotationParser method parseElement.
/**
* Parses a {@link NameValuePair}.
*
* @return {@code non-null;} the parsed element
*/
private NameValuePair parseElement() throws IOException {
requireLength(5);
int elementNameIndex = input.readUnsignedShort();
CstString elementName = (CstString) pool.get(elementNameIndex);
if (observer != null) {
parsed(2, "element_name: " + elementName.toHuman());
parsed(0, "value: ");
changeIndent(1);
}
Constant value = parseValue();
if (observer != null) {
changeIndent(-1);
}
return new NameValuePair(elementName, value);
}
use of com.android.dx.rop.cst.CstString in project buck by facebook.
the class DebugInfoEncoder method emitHeader.
/**
* Emits the header sequence, which consists of LEB128-encoded initial
* line number and string indicies for names of all non-"this" arguments.
*
* @param sortedPositions positions, sorted by ascending address
* @param methodArgs local list entries for method argumens arguments,
* in left-to-right order omitting "this"
* @throws IOException
*/
private void emitHeader(ArrayList<PositionList.Entry> sortedPositions, ArrayList<LocalList.Entry> methodArgs) throws IOException {
boolean annotate = (annotateTo != null) || (debugPrint != null);
int mark = output.getCursor();
// Start by initializing the line number register.
if (sortedPositions.size() > 0) {
PositionList.Entry entry = sortedPositions.get(0);
line = entry.getPosition().getLine();
}
output.writeUleb128(line);
if (annotate) {
annotate(output.getCursor() - mark, "line_start: " + line);
}
int curParam = getParamBase();
// paramTypes will not include 'this'
StdTypeList paramTypes = desc.getParameterTypes();
int szParamTypes = paramTypes.size();
/*
* Initialize lastEntryForReg to have an initial
* entry for the 'this' pointer.
*/
if (!isStatic) {
for (LocalList.Entry arg : methodArgs) {
if (curParam == arg.getRegister()) {
lastEntryForReg[curParam] = arg;
break;
}
}
curParam++;
}
// Write out the number of parameter entries that will follow.
mark = output.getCursor();
output.writeUleb128(szParamTypes);
if (annotate) {
annotate(output.getCursor() - mark, String.format("parameters_size: %04x", szParamTypes));
}
/*
* Then emit the string indicies of all the method parameters.
* Note that 'this', if applicable, is excluded.
*/
for (int i = 0; i < szParamTypes; i++) {
Type pt = paramTypes.get(i);
LocalList.Entry found = null;
mark = output.getCursor();
for (LocalList.Entry arg : methodArgs) {
if (curParam == arg.getRegister()) {
found = arg;
if (arg.getSignature() != null) {
/*
* Parameters with signatures will be re-emitted
* in complete as LOCAL_START_EXTENDED's below.
*/
emitStringIndex(null);
} else {
emitStringIndex(arg.getName());
}
lastEntryForReg[curParam] = arg;
break;
}
}
if (found == null) {
/*
* Emit a null symbol for "unnamed." This is common
* for, e.g., synthesized methods and inner-class
* this$0 arguments.
*/
emitStringIndex(null);
}
if (annotate) {
String parameterName = (found == null || found.getSignature() != null) ? "<unnamed>" : found.getName().toHuman();
annotate(output.getCursor() - mark, "parameter " + parameterName + " " + RegisterSpec.PREFIX + curParam);
}
curParam += pt.getCategory();
}
for (LocalList.Entry arg : lastEntryForReg) {
if (arg == null) {
continue;
}
CstString signature = arg.getSignature();
if (signature != null) {
emitLocalStartExtended(arg);
}
}
}
use of com.android.dx.rop.cst.CstString in project buck by facebook.
the class AnnotationItem method annotateTo.
/**
* Write a (listing file) annotation for this instance to the given
* output, that consumes no bytes of output. This is for annotating
* a reference to this instance at the point of the reference.
*
* @param out {@code non-null;} where to output to
* @param prefix {@code non-null;} prefix for each line of output
*/
public void annotateTo(AnnotatedOutput out, String prefix) {
out.annotate(0, prefix + "visibility: " + annotation.getVisibility().toHuman());
out.annotate(0, prefix + "type: " + annotation.getType().toHuman());
for (NameValuePair pair : annotation.getNameValuePairs()) {
CstString name = pair.getName();
Constant value = pair.getValue();
out.annotate(0, prefix + name.toHuman() + ": " + ValueEncoder.constantToHuman(value));
}
}
use of com.android.dx.rop.cst.CstString in project buck by facebook.
the class StringIdsSection method intern.
/**
* Interns an element into this instance.
*
* @param string {@code non-null;} the string to intern
* @return {@code non-null;} the interned string
*/
public synchronized StringIdItem intern(StringIdItem string) {
if (string == null) {
throw new NullPointerException("string == null");
}
throwIfPrepared();
CstString value = string.getValue();
StringIdItem already = strings.get(value);
if (already != null) {
return already;
}
strings.put(value, string);
return string;
}
use of com.android.dx.rop.cst.CstString in project buck by facebook.
the class TypeIdItem method writeTo.
/** {@inheritDoc} */
@Override
public void writeTo(DexFile file, AnnotatedOutput out) {
CstType type = getDefiningClass();
CstString descriptor = type.getDescriptor();
int idx = file.getStringIds().indexOf(descriptor);
if (out.annotates()) {
out.annotate(0, indexString() + ' ' + descriptor.toHuman());
out.annotate(4, " descriptor_idx: " + Hex.u4(idx));
}
out.writeInt(idx);
}
Aggregations