Пример #1
0
  public RuleModel() {

    int[] tmp = {0, 1, 2};
    alpha = new TIntHashSet();
    alpha.addAll(tmp);
    work = "(";
    for (int i = 0; i < tmp.length - 1; i++) work += tmp[i] + "|";
    work = work.substring(0, work.length() - 1) + ")";
    all = "(" + tmp[2] + "|" + work.substring(1, work.length());
  }
Пример #2
0
  public UNVDomain(UNVParser parser, int id, Color color) {
    this.id = id;
    this.color = color;
    TIntHashSet nodeset = new TIntHashSet();
    tria3 = parser.getTria3FromGroup(id);
    if (tria3.length > 0) {
      nodeset.ensureCapacity(tria3.length);
      nodeset.addAll(tria3);
    }
    quad4 = parser.getQuad4FromGroup(id);
    if (quad4.length > 0) {
      nodeset.ensureCapacity(nodeset.size() + quad4.length);
      nodeset.addAll(quad4);
    }
    beam2 = parser.getBeam2FromGroup(id);
    if (beam2.length > 0) {
      nodeset.ensureCapacity(nodeset.size() + beam2.length);
      nodeset.addAll(beam2);
    }
    tria6 = parser.getTria6FromGroup(id);
    if (tria6.length > 0) {
      nodeset.ensureCapacity(nodeset.size() + tria6.length);
      nodeset.addAll(tria6);
    }

    int[] nodesID = nodeset.toArray();
    nodes = readNodes(nodesID, parser.getNodesCoordinates());

    // Compute inverse relation
    TIntIntHashMap map = new TIntIntHashMap(nodesID.length);
    for (int i = 0; i < nodesID.length; i++) map.put(nodesID[i], i);

    for (int i = 0; i < tria3.length; i++) tria3[i] = map.get(tria3[i]);
    for (int i = 0; i < quad4.length; i++) quad4[i] = map.get(quad4[i]);
    for (int i = 0; i < beam2.length; i++) beam2[i] = map.get(beam2[i]);
    for (int i = 0; i < tria6.length; i++) tria6[i] = map.get(tria6[i]);
  }
  private static void findReadsBeforeWrites(
      Instruction[] flow,
      TIntHashSet[] definitelyAssigned,
      List<ReadWriteVariableInstruction> result,
      TObjectIntHashMap<String> namesIndex,
      int[] postorder,
      int[] invpostorder,
      boolean onlyFirstRead) {
    // skip instructions that are not reachable from the start
    int start = ArrayUtil.find(invpostorder, 0);

    for (int i = start; i < flow.length; i++) {
      int j = invpostorder[i];
      Instruction curr = flow[j];
      if (curr instanceof ReadWriteVariableInstruction) {
        ReadWriteVariableInstruction rw = (ReadWriteVariableInstruction) curr;
        int name = namesIndex.get(rw.getVariableName());
        TIntHashSet vars = definitelyAssigned[j];
        if (rw.isWrite()) {
          if (vars == null) {
            vars = new TIntHashSet();
            definitelyAssigned[j] = vars;
          }
          vars.add(name);
        } else {
          if (vars == null || !vars.contains(name)) {
            result.add(rw);
            if (onlyFirstRead) {
              if (vars == null) {
                vars = new TIntHashSet();
                definitelyAssigned[j] = vars;
              }
              vars.add(name);
            }
          }
        }
      }

      for (Instruction succ : curr.allSuccessors()) {
        if (postorder[succ.num()] > postorder[curr.num()]) {
          TIntHashSet currDefinitelyAssigned = definitelyAssigned[curr.num()];
          TIntHashSet succDefinitelyAssigned = definitelyAssigned[succ.num()];
          if (currDefinitelyAssigned != null) {
            int[] currArray = currDefinitelyAssigned.toArray();
            if (succDefinitelyAssigned == null) {
              succDefinitelyAssigned = new TIntHashSet();
              succDefinitelyAssigned.addAll(currArray);
              definitelyAssigned[succ.num()] = succDefinitelyAssigned;
            } else {
              succDefinitelyAssigned.retainAll(currArray);
            }
          } else {
            if (succDefinitelyAssigned != null) {
              succDefinitelyAssigned.clear();
            } else {
              succDefinitelyAssigned = new TIntHashSet();
              definitelyAssigned[succ.num()] = succDefinitelyAssigned;
            }
          }
        }
      }
    }
  }