コード例 #1
0
ファイル: ArrayCopy.java プロジェクト: navicella/streamit
 // Only handles rectangle multi dim arrays now
 public static void acceptInit(JMethodDeclaration init, Hashtable constants) {
   JBlock body = init.getBody();
   JFormalParameter[] params = init.getParameters();
   for (int i = params.length - 1; i >= 0; i--) {
     LinkedList<JIntLiteral> dims = new LinkedList<JIntLiteral>();
     Object val = constants.get(params[i]);
     Object temp = val;
     while (temp instanceof Object[]) {
       dims.add(new JIntLiteral(((Object[]) temp).length));
       temp = ((Object[]) temp)[0];
     }
     if (dims.size() > 0) {
       dumpAssign(val, body, new JLocalVariableExpression(null, params[i]));
       body.addStatementFirst(
           new JExpressionStatement(
               null,
               new JAssignmentExpression(
                   null,
                   new JLocalVariableExpression(null, params[i]),
                   new JNewArrayExpression(
                       null, params[i].getType(), dims.toArray(new JExpression[0]), null)),
               null));
     }
   }
 }
コード例 #2
0
  protected SIRStream doCut(
      LinkedList<PartitionRecord> partitions,
      PartitionRecord curPartition,
      int x1,
      int x2,
      int xPivot,
      int tileLimit,
      int tPivot,
      SIRStream str) {
    // there's a division at this <yPivot>.  We'll
    // return result of a horizontal cut.
    int[] arr = {1 + (xPivot - x1), x2 - xPivot};
    PartitionGroup pg = PartitionGroup.createFromArray(arr);

    SIRContainer result;
    // might have either pipeline or feedback loop at this point...
    if (str instanceof SIRPipeline) {
      result = RefactorPipeline.addHierarchicalChildren((SIRPipeline) str, pg);
    } else if (str instanceof SIRFeedbackLoop) {
      // if we have a feedbackloop, then factored is
      // just the original, since it will have only
      // two children
      result = (SIRContainer) str;
    } else {
      result = null;
      Utils.fail("Unrecognized stream type: " + str);
    }

    // recurse up and down
    SIRStream top = traceback(partitions, curPartition, x1, xPivot, tPivot, result.get(0));
    // mark that we have a partition here
    curPartition = new PartitionRecord();
    partitions.add(curPartition);
    SIRStream bot =
        traceback(partitions, curPartition, xPivot + 1, x2, tileLimit - tPivot, result.get(1));

    // mutate ourselves if we haven't been mutated yet
    result.set(0, top);
    result.set(1, bot);

    // all done
    return result;
  }