Java Code Examples for com.android.dx.rop.code.RegisterSpecList#setImmutable()

The following examples show how to use com.android.dx.rop.code.RegisterSpecList#setImmutable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NormalSsaInsn.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Changes one of the insn's sources. New source should be of same type
 * and category.
 *
 * @param index {@code >=0;} index of source to change
 * @param newSpec spec for new source
 */
public final void changeOneSource(int index, RegisterSpec newSpec) {
    RegisterSpecList origSources = insn.getSources();
    int sz = origSources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
        newSources.set(i, i == index ? newSpec : origSources.get(i));
    }

    newSources.setImmutable();

    RegisterSpec origSpec = origSources.get(index);
    if (origSpec.getReg() != newSpec.getReg()) {
        /*
         * If the register remains unchanged, we're only changing
         * the type or local var name so don't update use list
         */
        getBlock().getParent().onSourceChanged(this, origSpec, newSpec);
    }

    insn = insn.withNewRegisters(getResult(), newSources);
}
 
Example 2
Source File: NormalSsaInsn.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Changes one of the insn's sources. New source should be of same type
 * and category.
 *
 * @param index {@code >=0;} index of source to change
 * @param newSpec spec for new source
 */
public final void changeOneSource(int index, RegisterSpec newSpec) {
    RegisterSpecList origSources = insn.getSources();
    int sz = origSources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
        newSources.set(i, i == index ? newSpec : origSources.get(i));
    }

    newSources.setImmutable();

    RegisterSpec origSpec = origSources.get(index);
    if (origSpec.getReg() != newSpec.getReg()) {
        /*
         * If the register remains unchanged, we're only changing
         * the type or local var name so don't update use list
         */
        getBlock().getParent().onSourceChanged(this, origSpec, newSpec);
    }

    insn = insn.withNewRegisters(getResult(), newSources);
}
 
Example 3
Source File: NormalSsaInsn.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Changes one of the insn's sources. New source should be of same type
 * and category.
 *
 * @param index {@code >=0;} index of source to change
 * @param newSpec spec for new source
 */
public final void changeOneSource(int index, RegisterSpec newSpec) {
    RegisterSpecList origSources = insn.getSources();
    int sz = origSources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
        newSources.set(i, i == index ? newSpec : origSources.get(i));
    }

    newSources.setImmutable();

    RegisterSpec origSpec = origSources.get(index);
    if (origSpec.getReg() != newSpec.getReg()) {
        /*
         * If the register remains unchanged, we're only changing
         * the type or local var name so don't update use list
         */
        getBlock().getParent().onSourceChanged(this, origSpec, newSpec);
    }

    insn = insn.withNewRegisters(getResult(), newSources);
}
 
Example 4
Source File: NormalSsaInsn.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Changes one of the insn's sources. New source should be of same type
 * and category.
 *
 * @param index {@code >=0;} index of source to change
 * @param newSpec spec for new source
 */
public final void changeOneSource(int index, RegisterSpec newSpec) {
    RegisterSpecList origSources = insn.getSources();
    int sz = origSources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
        newSources.set(i, i == index ? newSpec : origSources.get(i));
    }

    newSources.setImmutable();

    RegisterSpec origSpec = origSources.get(index);
    if (origSpec.getReg() != newSpec.getReg()) {
        /*
         * If the register remains unchanged, we're only changing
         * the type or local var name so don't update use list
         */
        getBlock().getParent().onSourceChanged(this, origSpec, newSpec);
    }

    insn = insn.withNewRegisters(getResult(), newSources);
}
 
Example 5
Source File: Form45cc.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a register list which is equivalent to the given one,
 * except that it splits category-2 registers into two explicit
 * entries. This returns the original list if no modification is
 * required
 *
 * @param orig {@code non-null;} the original list
 * @return {@code non-null;} the list with the described transformation
 */
private static RegisterSpecList explicitize(RegisterSpecList orig) {
    int wordCount = wordCount(orig);
    int sz = orig.size();

    if (wordCount == sz) {
        return orig;
    }

    RegisterSpecList result = new RegisterSpecList(wordCount);
    int wordAt = 0;

    for (int i = 0; i < sz; i++) {
        RegisterSpec one = orig.get(i);
        result.set(wordAt, one);
        if (one.getCategory() == 2) {
            result.set(wordAt + 1,
                       RegisterSpec.make(one.getReg() + 1, Type.VOID));
            wordAt += 2;
        } else {
            wordAt++;
        }
    }

    result.setImmutable();
    return result;
}
 
Example 6
Source File: Form35c.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a register list which is equivalent to the given one,
 * except that it splits category-2 registers into two explicit
 * entries. This returns the original list if no modification is
 * required
 *
 * @param orig {@code non-null;} the original list
 * @return {@code non-null;} the list with the described transformation
 */
private static RegisterSpecList explicitize(RegisterSpecList orig) {
    int wordCount = wordCount(orig);
    int sz = orig.size();

    if (wordCount == sz) {
        return orig;
    }

    RegisterSpecList result = new RegisterSpecList(wordCount);
    int wordAt = 0;

    for (int i = 0; i < sz; i++) {
        RegisterSpec one = orig.get(i);
        result.set(wordAt, one);
        if (one.getCategory() == 2) {
            result.set(wordAt + 1,
                       RegisterSpec.make(one.getReg() + 1, Type.VOID));
            wordAt += 2;
        } else {
            wordAt++;
        }
    }

    result.setImmutable();
    return result;
}
 
Example 7
Source File: RegisterMapper.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param sources old register list
 * @return new mapped register list, or old if nothing has changed.
 */
public final RegisterSpecList map(RegisterSpecList sources) {
    int sz = sources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
        newSources.set(i, map(sources.get(i)));
    }

    newSources.setImmutable();

    // Return the old sources if nothing has changed.
    return newSources.equals(sources) ? sources : newSources;
}
 
Example 8
Source File: Form45cc.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a register list which is equivalent to the given one,
 * except that it splits category-2 registers into two explicit
 * entries. This returns the original list if no modification is
 * required
 *
 * @param orig {@code non-null;} the original list
 * @return {@code non-null;} the list with the described transformation
 */
private static RegisterSpecList explicitize(RegisterSpecList orig) {
    int wordCount = wordCount(orig);
    int sz = orig.size();

    if (wordCount == sz) {
        return orig;
    }

    RegisterSpecList result = new RegisterSpecList(wordCount);
    int wordAt = 0;

    for (int i = 0; i < sz; i++) {
        RegisterSpec one = orig.get(i);
        result.set(wordAt, one);
        if (one.getCategory() == 2) {
            result.set(wordAt + 1,
                       RegisterSpec.make(one.getReg() + 1, Type.VOID));
            wordAt += 2;
        } else {
            wordAt++;
        }
    }

    result.setImmutable();
    return result;
}
 
Example 9
Source File: Form35c.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a register list which is equivalent to the given one,
 * except that it splits category-2 registers into two explicit
 * entries. This returns the original list if no modification is
 * required
 *
 * @param orig {@code non-null;} the original list
 * @return {@code non-null;} the list with the described transformation
 */
private static RegisterSpecList explicitize(RegisterSpecList orig) {
    int wordCount = wordCount(orig);
    int sz = orig.size();

    if (wordCount == sz) {
        return orig;
    }

    RegisterSpecList result = new RegisterSpecList(wordCount);
    int wordAt = 0;

    for (int i = 0; i < sz; i++) {
        RegisterSpec one = orig.get(i);
        result.set(wordAt, one);
        if (one.getCategory() == 2) {
            result.set(wordAt + 1,
                       RegisterSpec.make(one.getReg() + 1, Type.VOID));
            wordAt += 2;
        } else {
            wordAt++;
        }
    }

    result.setImmutable();
    return result;
}
 
Example 10
Source File: RegisterMapper.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param sources old register list
 * @return new mapped register list, or old if nothing has changed.
 */
public final RegisterSpecList map(RegisterSpecList sources) {
    int sz = sources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
        newSources.set(i, map(sources.get(i)));
    }

    newSources.setImmutable();

    // Return the old sources if nothing has changed.
    return newSources.equals(sources) ? sources : newSources;
}
 
Example 11
Source File: Form45cc.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a register list which is equivalent to the given one,
 * except that it splits category-2 registers into two explicit
 * entries. This returns the original list if no modification is
 * required
 *
 * @param orig {@code non-null;} the original list
 * @return {@code non-null;} the list with the described transformation
 */
private static RegisterSpecList explicitize(RegisterSpecList orig) {
    int wordCount = wordCount(orig);
    int sz = orig.size();

    if (wordCount == sz) {
        return orig;
    }

    RegisterSpecList result = new RegisterSpecList(wordCount);
    int wordAt = 0;

    for (int i = 0; i < sz; i++) {
        RegisterSpec one = orig.get(i);
        result.set(wordAt, one);
        if (one.getCategory() == 2) {
            result.set(wordAt + 1,
                       RegisterSpec.make(one.getReg() + 1, Type.VOID));
            wordAt += 2;
        } else {
            wordAt++;
        }
    }

    result.setImmutable();
    return result;
}
 
Example 12
Source File: Form35c.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a register list which is equivalent to the given one,
 * except that it splits category-2 registers into two explicit
 * entries. This returns the original list if no modification is
 * required
 *
 * @param orig {@code non-null;} the original list
 * @return {@code non-null;} the list with the described transformation
 */
private static RegisterSpecList explicitize(RegisterSpecList orig) {
    int wordCount = wordCount(orig);
    int sz = orig.size();

    if (wordCount == sz) {
        return orig;
    }

    RegisterSpecList result = new RegisterSpecList(wordCount);
    int wordAt = 0;

    for (int i = 0; i < sz; i++) {
        RegisterSpec one = orig.get(i);
        result.set(wordAt, one);
        if (one.getCategory() == 2) {
            result.set(wordAt + 1,
                       RegisterSpec.make(one.getReg() + 1, Type.VOID));
            wordAt += 2;
        } else {
            wordAt++;
        }
    }

    result.setImmutable();
    return result;
}
 
Example 13
Source File: RegisterMapper.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param sources old register list
 * @return new mapped register list, or old if nothing has changed.
 */
public final RegisterSpecList map(RegisterSpecList sources) {
    int sz = sources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
        newSources.set(i, map(sources.get(i)));
    }

    newSources.setImmutable();

    // Return the old sources if nothing has changed.
    return newSources.equals(sources) ? sources : newSources;
}
 
Example 14
Source File: Form35c.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a register list which is equivalent to the given one,
 * except that it splits category-2 registers into two explicit
 * entries. This returns the original list if no modification is
 * required
 *
 * @param orig {@code non-null;} the original list
 * @return {@code non-null;} the list with the described transformation
 */
private static RegisterSpecList explicitize(RegisterSpecList orig) {
    int wordCount = wordCount(orig);
    int sz = orig.size();

    if (wordCount == sz) {
        return orig;
    }

    RegisterSpecList result = new RegisterSpecList(wordCount);
    int wordAt = 0;

    for (int i = 0; i < sz; i++) {
        RegisterSpec one = orig.get(i);
        result.set(wordAt, one);
        if (one.getCategory() == 2) {
            result.set(wordAt + 1,
                       RegisterSpec.make(one.getReg() + 1, Type.VOID));
            wordAt += 2;
        } else {
            wordAt++;
        }
    }

    result.setImmutable();
    return result;
}
 
Example 15
Source File: RegisterMapper.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param sources old register list
 * @return new mapped register list, or old if nothing has changed.
 */
public final RegisterSpecList map(RegisterSpecList sources) {
    int sz = sources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
        newSources.set(i, map(sources.get(i)));
    }

    newSources.setImmutable();

    // Return the old sources if nothing has changed.
    return newSources.equals(sources) ? sources : newSources;
}