Java Code Examples for gnu.trove.list.array.TIntArrayList

The following are top voted examples for showing how to use gnu.trove.list.array.TIntArrayList. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: powsybl-core   File: ArrayChunk.java   View source code 6 votes vote down vote up
static void parseFieldName(JsonParser parser, JsonParsingContext context) throws IOException {
    String fieldName = parser.getCurrentName();
    switch (fieldName) {
        case "offset":
            context.offset = parser.nextIntValue(-1);
            context.doubleValues = null;
            context.stringValues = null;
            break;
        case "uncompressedLength":
            context.uncompressedLength = parser.nextIntValue(-1);
            break;
        case "stepLengths":
            context.stepLengths = new TIntArrayList();
            context.valuesOrLengthArray = true;
            break;
        case "values":
        case "stepValues":
            context.valuesOrLengthArray = true;
            break;
        default:
            break;
    }
}
 
Example 2
Project: powsybl-core   File: UndirectedGraphImpl.java   View source code 6 votes vote down vote up
@Override
public List<E> getEdgeObjects(int v1, int v2) {
    checkVertex(v1);
    checkVertex(v2);
    List<E> edgeObjects = new ArrayList<>(1);
    TIntArrayList[] adjacencyList = getAdjacencyList();
    TIntArrayList adjacentEdges = adjacencyList[v1];
    for (int i = 0; i < adjacentEdges.size(); i++) {
        int e = adjacentEdges.getQuick(i);
        Edge<E> edge = edges.get(e);
        if ((edge.getV1() == v1 && edge.getV2() == v2)
            || (edge.getV1() == v2 && edge.getV2() == v1)) {
            edgeObjects.add(edge.getObject());
        }
    }
    return edgeObjects;
}
 
Example 3
Project: powsybl-core   File: UndirectedGraphImpl.java   View source code 6 votes vote down vote up
@Override
public void traverse(int v, Traverser<E> traverser, boolean[] encountered) {
    checkVertex(v);
    TIntArrayList[] adjacencyList = getAdjacencyList();
    TIntArrayList adjacentEdges = adjacencyList[v];
    encountered[v] = true;
    for (int i = 0; i < adjacentEdges.size(); i++) {
        int e = adjacentEdges.getQuick(i);
        Edge<E> edge = edges.get(e);
        int v1 = edge.getV1();
        int v2 = edge.getV2();
        if (!encountered[v1]) {
            if (traverser.traverse(v2, e, v1) == TraverseResult.CONTINUE) {
                encountered[v1] = true;
                traverse(v1, traverser, encountered);
            }
        } else if (!encountered[v2] && traverser.traverse(v1, e, v2) == TraverseResult.CONTINUE) {
            encountered[v2] = true;
            traverse(v2, traverser, encountered);
        }
    }
}
 
Example 4
Project: powsybl-core   File: AbstractTapChanger.java   View source code 6 votes vote down vote up
protected AbstractTapChanger(Ref<? extends MultiStateObject> network, H parent,
                             int lowTapPosition, List<S> steps, TerminalExt regulationTerminal,
                             int tapPosition, boolean regulating) {
    this.network = network;
    this.parent = parent;
    this.lowTapPosition = lowTapPosition;
    this.steps = steps;
    this.regulationTerminal = regulationTerminal;
    int stateArraySize = network.get().getStateManager().getStateArraySize();
    this.tapPosition = new TIntArrayList(stateArraySize);
    this.regulating = new BitSet(stateArraySize);
    this.regulating.set(0, stateArraySize, regulating);
    for (int i = 0; i < stateArraySize; i++) {
        this.tapPosition.add(tapPosition);
    }
}
 
Example 5
Project: powsybl-core   File: ConfiguredBusImpl.java   View source code 6 votes vote down vote up
ConfiguredBusImpl(String id, VoltageLevelExt voltageLevel) {
    super(id, voltageLevel);
    network = voltageLevel.getNetwork().getRef();
    int stateArraySize = network.get().getStateManager().getStateArraySize();
    terminals = new ArrayList<>(stateArraySize);
    v = new TFloatArrayList(stateArraySize);
    angle = new TFloatArrayList(stateArraySize);
    connectedComponentNumber = new TIntArrayList(stateArraySize);
    synchronousComponentNumber = new TIntArrayList(stateArraySize);
    for (int i = 0; i < stateArraySize; i++) {
        terminals.add(new ArrayList<>());
        v.add(Float.NaN);
        angle.add(Float.NaN);
        connectedComponentNumber.add(-1);
        synchronousComponentNumber.add(-1);
    }
}
 
Example 6
Project: xcc   File: Diagnostic.java   View source code 6 votes vote down vote up
public Diagnostic(DiagnosticClient client)
{
	this.client = client;
	allExtensionsSilenced = 0;
	ignoreAllWarnings = false;
	warningsAsErrors = false;
	suppressSystemWarnings = false;
	extBehavior = Ext_Ignore;
	errorOccurred = false;
	fatalErrorOcurred = false;
	numDiagArgs = 0;
       numErrors = 0;

       customDiagInfo = null;
	curDiagID = ~0;
       lastDiagLevel = Level.Ignored;

       diagMappingsStack = new LinkedList<>();
       TIntArrayList blankDiags = new TIntArrayList();
       blankDiags.fill(0, DIAG_UPPER_LIMIT/2, 0);
       diagMappingsStack.addLast(blankDiags);
       argToStringFtr = DummyArgToStringFunctor;
       fixItHints = new FixItHint[maxFixItHints];
       for (int i = 0; i != fixItHints.length; i++)
           fixItHints[i] = new FixItHint();
}
 
Example 7
Project: xcc   File: TGParser.java   View source code 6 votes vote down vote up
/**
 * RangeList ::= RangePiece (',' RangePiece)*
 * @param ranges
 */
private void parseRangeList(TIntArrayList ranges)
{
    if (parseRangePiece(ranges))
    {
        ranges.clear();
        return;
    }
    while (lexer.getCode() == TGLexer.TokKind.comma)
    {
        lexer.lex();

        if (parseRangePiece(ranges))
        {
            ranges.clear();
            return;
        }
    }
}
 
Example 8
Project: xcc   File: TGParser.java   View source code 6 votes vote down vote up
/**
 * Parse either a bit list in {}'s or nothing.
 * <pre>
 *   OptionalBitList ::= '{' RangeList '}'
 *   OptionalBitList ::=
 * </pre>
 * @param bitlist
 * @return
 */
private boolean parseOptionalBitList(TIntArrayList bitlist)
{
    if (lexer.getCode() != TGLexer.TokKind.l_brace)
        return false;

    SourceMgr.SMLoc startLoc = lexer.getLoc();
    lexer.lex();

    parseRangeList(bitlist);
    if (bitlist.isEmpty()) return true;

    if (lexer.getCode() != TGLexer.TokKind.r_brace)
    {
        tokError("expected '}' at end of bit list");
        return error(startLoc, "to match this '{'");
    }

    lexer.lex();        // eat the '}'
    return false;
}
 
Example 9
Project: xcc   File: Init.java   View source code 6 votes vote down vote up
@Override
public Init convertInitializerBitRange(TIntArrayList bits)
{
    if (!(getType() instanceof BitsRecTy))
        return null;

    BitsRecTy t = (BitsRecTy)getType();
    int numBits = t.getNumBits();

    BitsInit bi = new BitsInit(bits.size());
    for (int i = 0, e = bits.size(); i < e; i++)
    {
        if (bits.get(i) >= numBits)
            return null;

        bi.setBit(i, new VarBitInit(this, bits.get(i)));
    }
    return bi;
}
 
Example 10
Project: xcc   File: CodeGenTarget.java   View source code 6 votes vote down vote up
public CodeGenTarget() throws Exception
{
    pointerType = Other;
    legalValueTypes = new TIntArrayList();

    ArrayList<Record> targets = Record.records.getAllDerivedDefinition("Target");
    if (targets.isEmpty())
        throw new Exception("Error: No target defined!");
    if (targets.size() != 1)
        throw new Exception("Error: Multiple subclasses of Target defined!");

    targetRec = targets.get(0);

    // LLVM 1.0 introduced which is removed in LLVM 2.6.
    // calleeSavedRegisters = targetRec.getValueAsListOfDefs("CalleeSavedRegisters");
    // pointerType = getValueType(targetRec.getValueAsDef("PointerType"));

    readRegisters();

    // Read register classes description information from records.
    readRegisterClasses();

    // Read the instruction description information from records.
    // readInstructions();
}
 
Example 11
Project: xcc   File: CodeGenTarget.java   View source code 6 votes vote down vote up
/**
 * Find the union of all possible SimpleValueTypes for the
 * specified physical register.
 * @param r
 * @return
 */
public TIntArrayList getRegisterVTs(Record r)
{
    TIntArrayList res = new TIntArrayList();
    for (CodeGenRegisterClass rc : registerClasses)
    {
        for (Record elt : rc.elts)
        {
            if (r.equals(elt))
            {
                TIntArrayList inVTs = rc.getValueTypes();
                res.addAll(CodeGenDAGPatterns.convertVTs(inVTs));
            }
        }
    }
    return res;
}
 
Example 12
Project: xcc   File: Record.java   View source code 6 votes vote down vote up
public TIntArrayList getValueAsListOfInts(String fieldName) throws Exception
{
    ListInit list = getValueAsListInit(fieldName);
    TIntArrayList res = new TIntArrayList();
    for (int i = 0; i < list.getSize(); i++)
    {
        IntInit ii = list.getElement(i) instanceof IntInit ?
                (IntInit)list.getElement(i) : null;
        if (ii != null)
            res.add((int) ii.getValue());
        else
            throw new Exception("Record '" + getName() + "', field '" +
                fieldName + "' does not have a list of ints initializer!");
    }
    return res;
}
 
Example 13
Project: xcc   File: CCState.java   View source code 6 votes vote down vote up
public CCState(backend.support.CallingConv cc,
        boolean isVarArg,
        TargetMachine tm,
        ArrayList<CCValAssign> locs)
{
    callingConv = cc;
    this.isVarArg = isVarArg;
    this.tm = tm;
    tri = tm.getRegisterInfo();
    this.locs = locs;
    stackOffset = 0;
    usedRegs = new TIntArrayList();
    for (int capacity = (tri.getNumRegs() + 31) / 32;
         capacity != 0; --capacity)
        usedRegs.add(0);
}
 
Example 14
Project: HCFCore   File: TLinkedHashSet.java   View source code 6 votes vote down vote up
/**
 * initializes the Object set of this hash table.
 *
 * @param initialCapacity an <code>int</code> value
 * @return an <code>int</code> value
 */
@Override
public int setUp(int initialCapacity) {
    order = new TIntArrayList(initialCapacity) {
        /**
         * Grow the internal array as needed to accommodate the specified number of elements.
         * The size of the array bytes on each resize unless capacity requires more than twice
         * the current capacity.
         */
        @Override
        public void ensureCapacity(int capacity) {
            if (capacity > _data.length) {
                int newCap = Math.max(_set.length, capacity);
                int[] tmp = new int[newCap];
                System.arraycopy(_data, 0, tmp, 0, _data.length);
                _data = tmp;
            }
        }
    };
    return super.setUp(initialCapacity);    //To change body of overridden methods use File | Settings | File Templates.
}
 
Example 15
Project: xcc   File: RegAllocPBQP.java   View source code 6 votes vote down vote up
private PBQPVector constructCostVector(int vreg,
        TIntArrayList allowedReg,
        TObjectDoubleHashMap<Pair<Integer, Integer>> coalsceMap,
        double spillCost)
{
    PBQPVector cost = new PBQPVector(allowedReg.size()+1);
    cost.set(0, spillCost);

    for (int i = 0, e = allowedReg.size(); i < e; i++)
    {
        int preg = allowedReg.get(i);
        Pair<Integer, Integer> regPair = Pair.get(preg, vreg);
        if (coalsceMap.containsKey(regPair))
        {
            cost.set(i+1, -coalsceMap.get(regPair));
        }
    }
    return cost;
}
 
Example 16
Project: HCFCore   File: TLinkedHashSet.java   View source code 6 votes vote down vote up
/**
 * initializes the Object set of this hash table.
 *
 * @param initialCapacity an <code>int</code> value
 * @return an <code>int</code> value
 */
@Override
public int setUp(int initialCapacity) {
    order = new TIntArrayList(initialCapacity) {
        /**
         * Grow the internal array as needed to accommodate the specified number of elements.
         * The size of the array bytes on each resize unless capacity requires more than twice
         * the current capacity.
         */
        @Override
        public void ensureCapacity(int capacity) {
            if (capacity > _data.length) {
                int newCap = Math.max(_set.length, capacity);
                int[] tmp = new int[newCap];
                System.arraycopy(_data, 0, tmp, 0, _data.length);
                _data = tmp;
            }
        }
    };
    return super.setUp(initialCapacity);    //To change body of overridden methods use File | Settings | File Templates.
}
 
Example 17
Project: xcc   File: TLinkedHashSet.java   View source code 6 votes vote down vote up
/**
 * initializes the Object set of this hash table.
 *
 * @param initialCapacity an <code>int</code> value
 * @return an <code>int</code> value
 */
@Override
public int setUp(int initialCapacity) {
    order = new TIntArrayList(initialCapacity) {
        /**
         * Grow the internal array as needed to accommodate the specified number of elements.
         * The size of the array bytes on each resize unless capacity requires more than twice
         * the current capacity.
         */
        @Override
        public void ensureCapacity(int capacity) {
            if (capacity > _data.length) {
                int newCap = Math.max(_set.length, capacity);
                int[] tmp = new int[newCap];
                System.arraycopy(_data, 0, tmp, 0, _data.length);
                _data = tmp;
            }
        }
    };
    return super.setUp(initialCapacity);    //To change body of overridden methods use File | Settings | File Templates.
}
 
Example 18
Project: powsybl-core   File: UncompressedStringArrayChunk.java   View source code 5 votes vote down vote up
@Override
public StringArrayChunk tryToCompress() {
    List<String> stepValues = new ArrayList<>();
    TIntArrayList stepLengths = new TIntArrayList();
    int compressedEstimatedSize = 0;
    for (String value : values) {
        if (stepValues.isEmpty()) {
            // create first step
            stepValues.add(value);
            stepLengths.add(1);
            compressedEstimatedSize += CompressedStringArrayChunk.getStepEstimatedSize(value);
        } else {
            int previousIndex = stepValues.size() - 1;
            String previousValue = stepValues.get(previousIndex);
            if (Objects.equals(previousValue, value)) {
                stepLengths.set(previousIndex, stepLengths.getQuick(previousIndex) + 1);
            } else {
                // create a new step
                stepValues.add(value);
                stepLengths.add(1);
                compressedEstimatedSize += CompressedStringArrayChunk.getStepEstimatedSize(value);
            }
        }
        if (compressedEstimatedSize > estimatedSize) {
            // compression is inefficient
            return this;
        }
    }
    return new CompressedStringArrayChunk(offset, values.length, stepValues.toArray(new String[stepValues.size()]),
                                          stepLengths.toArray());
}
 
Example 19
Project: powsybl-core   File: UndirectedGraphImpl.java   View source code 5 votes vote down vote up
@Override
public int[] getVertices() {
    TIntArrayList t = new TIntArrayList(vertices.size());
    for (int i = 0; i < vertices.size(); i++) {
        if (vertices.get(i) != null) {
            t.add(i);
        }
    }
    return t.toArray();
}
 
Example 20
Project: powsybl-core   File: UndirectedGraphImpl.java   View source code 5 votes vote down vote up
@Override
public int[] getEdges() {
    TIntArrayList t = new TIntArrayList(getEdgeCount());
    for (int e = 0; e < edges.size(); e++) {
        if (edges.get(e) != null) {
            t.add(e);
        }
    }
    return t.toArray();
}
 
Example 21
Project: HCFCore   File: TIntArrayStack.java   View source code 5 votes vote down vote up
public void readExternal( ObjectInput in )
	throws IOException, ClassNotFoundException {

	// VERSION
	in.readByte();

	// LIST
	_list = ( TIntArrayList ) in.readObject();
}
 
Example 22
Project: powsybl-core   File: UndirectedGraphImpl.java   View source code 5 votes vote down vote up
@Override
public List<TIntArrayList> findAllPaths(int from, Function<V, Boolean> pathComplete, Function<E, Boolean> pathCanceled) {
    Objects.requireNonNull(pathComplete);
    List<TIntArrayList> paths = new ArrayList<>();
    BitSet encountered = new BitSet(vertices.size());
    TIntArrayList path = new TIntArrayList(1);
    findAllPaths(from, pathComplete, pathCanceled, path, encountered, paths);
    // sort paths by size
    paths.sort((o1, o2) -> o1.size() - o2.size());
    return paths;
}
 
Example 23
Project: powsybl-core   File: UndirectedGraphImpl.java   View source code 5 votes vote down vote up
private boolean findAllPaths(int e, int v1or2, Function<V, Boolean> pathComplete, Function<E, Boolean> pathCanceled,
                             TIntArrayList path, BitSet encountered, List<TIntArrayList> paths) {
    if (encountered.get(v1or2)) {
        return false;
    }
    Vertex<V> obj1or2 = vertices.get(v1or2);
    path.add(e);
    if (pathComplete.apply(obj1or2.getObject())) {
        paths.add(path);
        return true;
    } else {
        findAllPaths(v1or2, pathComplete, pathCanceled, path, encountered, paths);
        return false;
    }
}
 
Example 24
Project: powsybl-core   File: GraphUtil.java   View source code 5 votes vote down vote up
private static void computeConnectedComponents(int v1, int c, int[] componentSize, TIntArrayList[] adjacencyList, int[] componentNumber) {
    componentNumber[v1] = c;
    ++componentSize[c];
    TIntArrayList ls = adjacencyList[v1];
    for (int i = 0; i < ls.size(); i++) {
        int v2 = ls.getQuick(i);
        if (componentNumber[v2] == -1) {
            computeConnectedComponents(v2, c, componentSize, adjacencyList, componentNumber);
        }
    }
}
 
Example 25
Project: powsybl-core   File: StaticVarCompensatorImpl.java   View source code 5 votes vote down vote up
StaticVarCompensatorImpl(String id, String name, float bMin, float bMax, float voltageSetPoint, float reactivePowerSetPoint,
                         RegulationMode regulationMode, Ref<? extends MultiStateObject> ref) {
    super(id, name);
    this.bMin = bMin;
    this.bMax = bMax;
    int stateArraySize = ref.get().getStateManager().getStateArraySize();
    this.voltageSetPoint = new TFloatArrayList(stateArraySize);
    this.reactivePowerSetPoint = new TFloatArrayList(stateArraySize);
    this.regulationMode = new TIntArrayList(stateArraySize);
    for (int i = 0; i < stateArraySize; i++) {
        this.voltageSetPoint.add(voltageSetPoint);
        this.reactivePowerSetPoint.add(reactivePowerSetPoint);
        this.regulationMode.add(regulationMode.ordinal());
    }
}
 
Example 26
Project: powsybl-core   File: ShuntCompensatorImpl.java   View source code 5 votes vote down vote up
ShuntCompensatorImpl(Ref<? extends MultiStateObject> network,
                     String id, String name, float bPerSection, int maximumSectionCount,
                     int currentSectionCount) {
    super(id, name);
    this.network = network;
    this.bPerSection = bPerSection;
    this.maximumSectionCount = maximumSectionCount;
    int stateArraySize = network.get().getStateManager().getStateArraySize();
    this.currentSectionCount = new TIntArrayList(stateArraySize);
    for (int i = 0; i < stateArraySize; i++) {
        this.currentSectionCount.add(currentSectionCount);
    }
}
 
Example 27
Project: powsybl-core   File: NetworkImpl.java   View source code 5 votes vote down vote up
@Override
protected void fillAdjacencyList(Map<String, Integer> id2num, TIntArrayList[] adjacencyList) {
    super.fillAdjacencyList(id2num, adjacencyList);
    for (HvdcLineImpl line : network.objectStore.getAll(HvdcLineImpl.class)) {
        BusExt bus1 = line.getConverterStation1().getTerminal().getBusView().getBus();
        BusExt bus2 = line.getConverterStation2().getTerminal().getBusView().getBus();
        addToAdjacencyList(bus1, bus2, id2num, adjacencyList);
    }
}
 
Example 28
Project: powsybl-core   File: NodeBreakerVoltageLevel.java   View source code 5 votes vote down vote up
@Override
public boolean isValid(UndirectedGraph<? extends TerminalExt, SwitchImpl> graph, TIntArrayList nodes, List<NodeTerminal> terminals) {
    int feederCount = 0;
    int branchCount = 0;
    int busbarSectionCount = 0;
    for (int i = 0; i < nodes.size(); i++) {
        int node = nodes.get(i);
        TerminalExt terminal = graph.getVertexObject(node);
        if (terminal != null) {
            AbstractConnectable connectable = terminal.getConnectable();
            switch (connectable.getType()) {
                case LINE:
                case TWO_WINDINGS_TRANSFORMER:
                case THREE_WINDINGS_TRANSFORMER:
                case HVDC_CONVERTER_STATION:
                    branchCount++;
                    feederCount++;
                    break;

                case LOAD:
                case GENERATOR:
                case SHUNT_COMPENSATOR:
                case DANGLING_LINE:
                case STATIC_VAR_COMPENSATOR:
                    feederCount++;
                    break;

                case BUSBAR_SECTION:
                    busbarSectionCount++;
                    break;

                default:
                    throw new AssertionError();
            }
        }
    }
    return (busbarSectionCount >= 1 && feederCount >= 1)
            || (branchCount >= 1 && feederCount >= 2);
}
 
Example 29
Project: powsybl-core   File: NodeTerminal.java   View source code 5 votes vote down vote up
NodeTerminal(Ref<? extends MultiStateObject> network, int node) {
    super(network);
    this.node = node;
    int stateArraySize = network.get().getStateManager().getStateArraySize();
    v = new TFloatArrayList(stateArraySize);
    angle = new TFloatArrayList(stateArraySize);
    connectedComponentNumber = new TIntArrayList(stateArraySize);
    synchronousComponentNumber = new TIntArrayList(stateArraySize);
    for (int i = 0; i < stateArraySize; i++) {
        v.add(Float.NaN);
        angle.add(Float.NaN);
        connectedComponentNumber.add(0);
        synchronousComponentNumber.add(0);
    }
}
 
Example 30
Project: ProjectAres   File: XMLUtils.java   View source code 5 votes vote down vote up
private static TIntList indexPath(Element child, int size) {
    final Element parent = child.getParentElement();
    if(parent == null) {
        return new TIntArrayList(size);
    } else {
        final TIntList path = indexPath(parent, size + 1);
        final int index = ((BoundedElement) child).indexInParent();
        if(index < 0) {
            throw new IllegalStateException("Parent element " + parent + " does not contain its child element " + child);
        }
        path.add(index);
        return path;
    }
}
 
Example 31
Project: xcc   File: SubtargetEmitter.java   View source code 5 votes vote down vote up
/**
 * Compose a string containing the
 * operand cycle initialization for the specified itinerary.  N is the
 * number of operands that has cycles specified.
 * @param itinData
 * @param itinString
 * @return  The number of operand cycles.
 */
private int formItineraryOperandCycleString(Record itinData,
        StringBuilder itinString) throws Exception
{
    TIntArrayList operandCycleList = itinData.getValueAsListOfInts("OperandCycles");

    for (int i = 0, e = operandCycleList.size(); i != e; i++)
    {
        itinString.append(" ").append(operandCycleList.get(i));
        if (i < e - 1) itinString.append(", ");
    }
    return operandCycleList.size();
}
 
Example 32
Project: xcc   File: TGParser.java   View source code 5 votes vote down vote up
LetRecord(String name, TIntArrayList bits, Init val, SourceMgr.SMLoc loc)
{
    this.name = name;
    value = val;
    this.bits = bits;
    this.loc = loc;
}
 
Example 33
Project: HCFCore   File: TIntArrayStack.java   View source code 5 votes vote down vote up
/**
 * Creates a new <code>TIntArrayStack</code> instance that is
 * a copy of the instanced passed to us.
 *
 * @param stack the instance to copy
 */
public TIntArrayStack( TIntStack stack ) {
    if ( stack instanceof TIntArrayStack ) {
        TIntArrayStack array_stack = ( TIntArrayStack ) stack;
        this._list = new TIntArrayList( array_stack._list );
    } else {
        throw new UnsupportedOperationException( "Only support TIntArrayStack" );
    }
}
 
Example 34
Project: xcc   File: Init.java   View source code 5 votes vote down vote up
@Override
public Init convertInitializerBitRange(TIntArrayList bits)
{
    BitsInit bi = new BitsInit(bits.size());
    for (int i = 0, e = bits.size(); i != e; i++)
    {
        if (bits.get(i) >= getNumBits())
            return null;
        bi.setBit(i, getBit(bits.get(i)));
    }
    return bi;
}
 
Example 35
Project: xcc   File: Init.java   View source code 5 votes vote down vote up
@Override
public Init convertInitializerBitRange(TIntArrayList bits)
{
    BitsInit bi = new BitsInit(bits.size());

    for (int i = 0, e = bits.size(); i < e; i++)
    {
        if (bits.get(i) >= 32)
            return null;

        boolean res = (value & (1 << bits.get(i))) != 0;
        bi.setBit(i, new BitInit(res));
    }
    return bi;
}
 
Example 36
Project: xcc   File: Init.java   View source code 5 votes vote down vote up
@Override
public Init convertIntListSlice(TIntArrayList elements)
{
    ArrayList<Init> vals = new ArrayList<>();
    for (int i = 0, e = elements.size(); i< e; i++)
    {
        if (elements.get(i) >= getSize())
            return null;
        vals.add(getElement(elements.get(i)));
    }
    return new ListInit(vals, getType());
}
 
Example 37
Project: xcc   File: Init.java   View source code 5 votes vote down vote up
@Override
public Init convertIntListSlice(TIntArrayList elements)
{
    if (!(getType() instanceof ListRecTy))
        return null;

    ListRecTy t = (ListRecTy)getType();
    if (elements.size() == 1)
        return new VarListElementInit(this, elements.get(0));

    ArrayList<Init> listInits = new ArrayList<>(elements.size());
    for (int i = 0, e = elements.size(); i < e; i++)
        listInits.add(new VarListElementInit(this, elements.get(i)));
    return new ListInit(listInits, getType());
}
 
Example 38
Project: xcc   File: TreePatternNode.java   View source code 5 votes vote down vote up
public TreePatternNode(Record op, ArrayList<TreePatternNode> chs)
{
    types = new TIntArrayList();
    predicateFns = new ArrayList<>();
    operator = op;
    children = new ArrayList<>();
    children.addAll(chs);
    types.add(EEVT.isUnknown);
}
 
Example 39
Project: NCDSearch   File: SearchMain.java   View source code 5 votes vote down vote up
public static String concat(TIntArrayList list) {
	StringBuilder b = new StringBuilder();
	for (int i=0; i<list.size(); i++) {
		if (i>0) b.append(", ");
		b.append(list.get(i));
	}
	return b.toString();
}
 
Example 40
Project: xcc   File: TreePatternNode.java   View source code 5 votes vote down vote up
public boolean updateNodeType(int extVT, TreePattern pattern)
        throws Exception
{
    TIntArrayList list = new TIntArrayList();
    list.add(extVT);
    return updateNodeType(list, pattern);
}