示例#1
0
  /*
  private void testForDebug(){
  System.out.println("--------test for debug-------");
  int i = 0;
  for (i=0;i<nodes.size();i++){
  JPegStmt stmt = (JPegStmt)nodes.elementAt(i);
  //System.out.println("Tag: "+ ((Tag)stmt.getTags().get(0)).toString());
   if (((Tag)stmt.getTags().get(0)).toString().equals("8")){
   int pos = nodes.indexOf(stmt);
   if (((MonitorSet)valueAfter.elementAt(pos)).size() >0 &&
   !((MonitorSet)valueAfter.elementAt(pos)).contains("&")){
   System.out.println("sp"+stmt.getTags().get(0)+" "+nodes.elementAt(pos));

   ((MonitorSet)valueAfter.elementAt(pos)).test();
   }
   }
   }
   System.out.println("--------test for debug end------");
   }
   */
  protected void copy(Object source, Object dest) {
    MonitorSet sourceSet = (MonitorSet) source;
    MonitorSet destSet = (MonitorSet) dest;

    sourceSet.copy(destSet);
  }
示例#2
0
  //	STEP 5: Define flow equations.
  //	in(s) = ( out(s) minus defs(s) ) union uses(s)
  //
  protected void flowThrough(Object inValue, Object unit, Object outValue) {
    MonitorSet in = (MonitorSet) inValue;
    MonitorSet out = (MonitorSet) outValue;
    JPegStmt s = (JPegStmt) unit;
    Tag tag = (Tag) s.getTags().get(0);
    // System.out.println("s: "+tag+" "+s);
    // Copy in to out
    // if (in.contains("&")) in.remove("&");

    in.copy(out);
    //	System.out.println("-----in: ");
    // in.test();

    if (in.size() > 0) {

      if (!s.getName().equals("waiting") && !s.getName().equals("notified-entry"))
        updateMonitor(in, unit);
    }
    String objName = s.getObject();
    // if (objName == null) throw new RuntimeException("null object: "+s.getUnit());
    if (s.getName().equals("entry") || s.getName().equals("exit")) {
      if (out.contains("&")) out.remove("&");

      Object obj = out.getMonitorDepth(objName);

      if (obj == null) {

        if (s.getName().equals("entry")) {
          MonitorDepth md = new MonitorDepth(objName, 1);
          out.add(md);
          // System.out.println("add to out: "+md.getObjName()+" "+md.getDepth());
        }
        /*
        else{
        throw new RuntimeException("The monitor depth can not be decreased at  "+
        (Tag)((JPegStmt)s).getTags().get(0)+" "+unit);
        }
        */

      } else {
        // System.out.println("obj: "+obj);
        if (obj instanceof MonitorDepth) {
          MonitorDepth md = (MonitorDepth) obj;

          if (s.getName().equals("entry")) {
            md.increaseDepth();
            // System.out.println("===increase depth===");
          } else {

            if (md.getDepth() > 1) {
              // System.out.println("===decrease depth==");
              md.decreaseDepth();
            } else if (md.getDepth() == 1) {
              //  System.out.println("===remove monitordepth: "+md);

              out.remove(md);
            } else throw new RuntimeException("The monitor depth can not be decreased at  " + unit);
          }
        } else throw new RuntimeException("MonitorSet contains non MonitorDepth element!");
      }
    }

    // System.out.println("-----out: "+out);
    // out.test();
    // testForDebug();
  }