本文整理匯總了Java中edu.mit.csail.sdg.alloy4compiler.translator.A4Tuple類的典型用法代碼示例。如果您正苦於以下問題:Java A4Tuple類的具體用法?Java A4Tuple怎麽用?Java A4Tuple使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
A4Tuple類屬於edu.mit.csail.sdg.alloy4compiler.translator包,在下文中一共展示了A4Tuple類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createEReferencesFromSigs
import edu.mit.csail.sdg.alloy4compiler.translator.A4Tuple; //導入依賴的package包/類
private void createEReferencesFromSigs() throws TraceException {
for (Sig sig : solution.getAllReachableSigs()) {
for (Field field : sig.getFields()) {
final String relName = field.label;
SigTrace sigTrace = TraceManager.get().getSigTraceByType(sig.label.replace("this/", ""));
RelationTrace relTrace =
TraceManager.get().getRelationTrace2(sigTrace.getClassName(), relName);
if (relTrace != null) {
String refName = relTrace.getReferenceName();
for (A4Tuple a4Tuple : solution.eval(field)) {
String fromAtom = a4Tuple.atom(0);
String toAtom = a4Tuple.atom(1);
createEReferenceByAtoms(refName, fromAtom, toAtom);
}
} else {
closeWizard();
throw new TraceException("No trace has been found for the relation: " + relName);
}
}
}
}
示例2: convert
import edu.mit.csail.sdg.alloy4compiler.translator.A4Tuple; //導入依賴的package包/類
/** Converts an A4TupleSet into a SimTupleset object. */
private static SimTupleset convert(final Object object) throws Err {
if (!(object instanceof A4TupleSet)) {
throw new ErrorFatal("Unexpected type error: expecting an A4TupleSet.");
}
final A4TupleSet s = (A4TupleSet) object;
if (s.size() == 0) {
return SimTupleset.EMPTY;
}
final List<SimTuple> list = new ArrayList<>(s.size());
final int arity = s.arity();
for (final A4Tuple t : s) {
final String[] array = new String[arity];
for (int i = 0; i < t.arity(); i++) {
array[i] = t.atom(i);
}
list.add(SimTuple.make(array));
}
return SimTupleset.make(list);
}
示例3: convertValueToText
import edu.mit.csail.sdg.alloy4compiler.translator.A4Tuple; //導入依賴的package包/類
/** {@inheritDoc} */
@Override public String convertValueToText(Object val, boolean selected, boolean expanded, boolean leaf, int row, boolean focus) {
String c = ">";
if (onWindows) c = selected ? " style=\"color:#ffffff;\">" : " style=\"color:#000000;\">";
if (val instanceof A4Solution) return "<html> <b" + c + encode(title==null ? "" : title)+"</b></html>";
if (val instanceof Sig) {
String label = ((Sig)val).label;
if (label.startsWith("this/")) label = label.substring(5);
return "<html> <b" + c + "sig " + encode(label) + "</b></html>";
}
if (val instanceof ExprVar) return "<html> <b" + c + "set " + encode(((ExprVar)val).label) + "</b></html>";
if (val instanceof String) return "<html> <span" + c + encode((String)val) + "</span></html>";
if (val instanceof Pair) return "<html> <b" + c + "field " + encode(((ExprHasName)(((Pair<?,?>)val).b)).label) + "</b></html>";
if (val instanceof A4Tuple) {
StringBuilder sb = new StringBuilder("<html> <span" + c);
A4Tuple tp = (A4Tuple) val;
for(int i=1; i<tp.arity(); i++) {
if (i>1) sb.append(" -> ");
sb.append(encode(tp.atom(i)));
}
sb.append("</span></html>");
return sb.toString();
}
return "";
}
示例4: convert
import edu.mit.csail.sdg.alloy4compiler.translator.A4Tuple; //導入依賴的package包/類
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));
}
return SimTupleset.make(list);
}
示例5: atoms
import edu.mit.csail.sdg.alloy4compiler.translator.A4Tuple; //導入依賴的package包/類
/** 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);
}
}
示例6: convert
import edu.mit.csail.sdg.alloy4compiler.translator.A4Tuple; //導入依賴的package包/類
/** 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));
}
return SimTupleset.make(list);
}
示例7: atom2sig
import edu.mit.csail.sdg.alloy4compiler.translator.A4Tuple; //導入依賴的package包/類
/**
* Given an A4Solution, return a map that maps every atom to its most specific signature.
*
* <p> For example, suppose we have "sig Animal { }" and "sig Dog, Cat extends Animal { }".
* Suppose the solution says Animal={A$1, A$2, A$3, A$4} and Dog={A$1} and Cat={A$2, A$3}.
* This method will return a map that maps A$1 to Dog, A$2 to Cat, A$3 to Cat, and A$4 to Animal.
* (A$1 is both an Animal and a Dog, but Dog is a subtype of Animal, so Dog is A$1's most specific signature)
*/
public static Map<String,PrimSig> atom2sig(A4Solution solution) throws Err {
Map<String,PrimSig> map = new HashMap<String,PrimSig>();
for(Sig s: solution.getAllReachableSigs()) if (s instanceof PrimSig) for(A4Tuple t: (A4TupleSet) solution.eval(s)) {
// We skip over SubsetSig and only care about PrimSig
String atom = t.atom(0);
PrimSig old = map.get(atom);
if (old==null || ((PrimSig)s).isSameOrDescendentOf(old)) { map.put(atom, (PrimSig)s); }
}
return map;
}