/**
   * Used by WSCallGraphBarrier path. Use simple call graph analyzer to get concurrent content
   *
   * @param ts
   * @param nf
   */
  public WSTransformStateSimple(ExtensionInfo extensionInfo) {
    super(extensionInfo);
    callGraph = new WSCallGraph();

    // start to iterate the ast in jobs and build all;
    for (Job job : extensionInfo.scheduler().jobs()) {
      if (job == null) {
        System.err.println("[WS_ERR] CallGraphBuilding: Find one job is empty!");
        continue;
      }
      Node node = job.ast();
      if (node != null && node instanceof SourceFile) {
        for (TopLevelDecl tld : ((SourceFile) node).decls()) {
          if (tld instanceof ClassDecl) {
            boolean result = callGraph.addClass((ClassDecl) tld);
            if (result) {
              System.out.println(
                  "[WS_INFO] CallGraphBuilding: Add one classDecl to graph: " + tld.toString());
            }
          }
        }
      } else {
        if (node == null) {
          System.err.println(
              "[WS_ERR] CallGraphBuilding: AST node == null for job: " + job.source().toString());
          continue;
        }
        if (!(node instanceof SourceFile)) {
          System.err.println(
              "[WS_ERR] CallGraphBuilding: AST node is not SourceFile for job: "
                  + job.source().toString());
          continue;
        }
      }
    }

    // now do search
    callGraph.doDFSMark();

    // debug print
    List<WSCallGraphNode> methods = callGraph.getAllParallelMethods();
    System.out.println("[WS_INFO] Found Parallel Methods:");

    for (WSCallGraphNode node : methods) {
      ProcedureDef md = node.getMethodDef();
      System.out.printf("    [%s] %s\n", node.isContainsConcurrent() ? "C" : "D", md.toString());

      for (WSCallGraphNode callerNode : node.getCallers()) {
        ProcedureDef cmd = callerNode.getMethodDef();
        System.out.printf(
            "      <-[%s] %s\n", callerNode.isContainsConcurrent() ? "C" : "D", cmd.toString());
      }
    }
  }
示例#2
0
  /** Type check the source file. */
  public Node typeCheck(ContextVisitor tc) {
    boolean hasPublic = false;

    // Override method to not check for duplicate declarations. This will be
    // caught during type building. But, we need to allow duplicates to handle
    // overloaded typedefs.
    for (TopLevelDecl d : decls) {
      if (d instanceof X10ClassDecl && d.flags().flags().isPublic()) {
        if (hasPublic) {
          Errors.issue(
              tc.job(), new Errors.SourceContainsMoreThanOnePublicDeclaration(d.position()), this);
        }
        hasPublic = true;
      }
    }

    return this.hasBeenTypeChecked(true);
  }