Package edu.mit.csail.sdg.alloy4compiler.translator

Examples of edu.mit.csail.sdg.alloy4compiler.translator.A4TupleSet


    };

    /** Converts an A4TupleSet into a SimTupleset object. */
    private static SimTupleset convert(Object object) throws Err {
        if (!(object instanceof A4TupleSet)) throw new ErrorFatal("Unexpected type error: expecting an A4TupleSet.");
        A4TupleSet s = (A4TupleSet)object;
        if (s.size()==0) return SimTupleset.EMPTY;
        List<SimTuple> list = new ArrayList<SimTuple>(s.size());
        int arity = s.arity();
        for(A4Tuple t: s) {
            String[] array = new String[arity];
            for(int i=0; i<t.arity(); i++) array[i] = t.atom(i);
            list.add(SimTuple.make(array));
        }
View Full Code Here


   /** Constructs the atoms corresponding to the given sig. */
   private void atoms(A4Solution sol, PrimSig s) throws Err {
      Expr sum=Sig.NONE;
      for(PrimSig c:s.children()) { sum=sum.plus(c); atoms(sol, c); }
      A4TupleSet ts = (A4TupleSet) (sol.eval(s.minus(sum))); // This ensures that atoms will be associated with the most specific sig
      for(A4Tuple z: ts) {
         String atom = z.atom(0);
         int i, dollar = atom.lastIndexOf('$');
         try { i = Integer.parseInt(dollar>=0 ? atom.substring(dollar+1) : atom); } catch(NumberFormatException ex) { i = Integer.MAX_VALUE; }
         AlloyAtom at = new AlloyAtom(sig(s), ts.size()==1 ? Integer.MAX_VALUE : i, atom);
         atom2sets.put(at, new LinkedHashSet<AlloySet>());
         string2atom.put(atom, at);
      }
   }
View Full Code Here

      List<Object> ans = new ArrayList<Object>();
      try {
         if (parent instanceof A4Solution) {
            return toplevel;
         } else if (parent instanceof Sig || parent instanceof ExprVar) {
            A4TupleSet ts = (A4TupleSet) (instance.eval((Expr)parent));
            for(A4Tuple t: ts) ans.add(t.atom(0));
         } else if (parent instanceof String) {
            String atom = (String)parent;
            for(Sig s: instance.getAllReachableSigs()) for(Field f: s.getFields()) for(A4Tuple t: instance.eval(f)) {
               if (t.atom(0).equals(atom)) { ans.add(new Pair<String,ExprHasName>(atom, f)); break; }
View Full Code Here

TOP

Related Classes of edu.mit.csail.sdg.alloy4compiler.translator.A4TupleSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.