当前位置: 首页>>代码示例>>Java>>正文


Java Sig.getFields方法代码示例

本文整理汇总了Java中edu.mit.csail.sdg.alloy4compiler.ast.Sig.getFields方法的典型用法代码示例。如果您正苦于以下问题:Java Sig.getFields方法的具体用法?Java Sig.getFields怎么用?Java Sig.getFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.mit.csail.sdg.alloy4compiler.ast.Sig的用法示例。


在下文中一共展示了Sig.getFields方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createEReferencesFromSigs

import edu.mit.csail.sdg.alloy4compiler.ast.Sig; //导入方法依赖的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);
      }
    }
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:22,代码来源:AlloyToEMF.java

示例2: rejectNameClash

import edu.mit.csail.sdg.alloy4compiler.ast.Sig; //导入方法依赖的package包/类
private static void rejectNameClash(final List<CompModule> modules) throws Err {
   // The Alloy language forbids two overlapping sigs from having fields with the same name.
   // In other words: if 2 fields have the same name, then their type's first column must not intersect.
   final Map<String,List<Field>> fieldname2fields=new LinkedHashMap<String,List<Field>>();
   for(CompModule m: modules) {
      for(Sig sig: m.sigs.values()) {
         for(Field field: sig.getFields()) {
            List<Field> peers=fieldname2fields.get(field.label);
            if (peers==null) { peers=new ArrayList<Field>(); fieldname2fields.put(field.label, peers); }
            for(Field field2: peers)
               if (field.type().firstColumnOverlaps(field2.type()))
                  throw new ErrorType(field.pos,
                        "Two overlapping signatures cannot have\n" + "two fields with the same name \""+field.label
                        +"\":\n\n1) one is in sig \""+field.sig+"\"\n"+field.pos
                        +"\n\n2) the other is in sig \""+field2.sig+"\"\n"+field2.pos);
            peers.add(field);
         }
      }
   }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:21,代码来源:CompModule.java

示例3: parseField

import edu.mit.csail.sdg.alloy4compiler.ast.Sig; //导入方法依赖的package包/类
/** Parse field. */
private Field parseField(String id) throws IOException, Err {
   final XMLNode node = nmap.get(id);
   if (node==null) throw new IOException("Unknown FieldID "+id+" encountered.");
   if (!node.is("field")) throw new IOException("ID "+id+" is not a field.");
   String label  = label(node);
   Pos isPrivate = yes(node,"private") ? Pos.UNKNOWN : null;
   Pos isMeta = yes(node,"meta") ? Pos.UNKNOWN : null;
   Expr type = null;
   for(XMLNode sub:node) if (sub.is("types")) { Expr t=parseType(sub); if (type==null) type=t; else type=type.plus(t); }
   int arity;
   if (type==null || (arity=type.type().arity())<2) throw new IOException("Field "+label+" is maltyped.");
   String parentID = node.getAttribute("parentID");
   Sig parent = id2sig.get(parentID);
   if (parent==null) throw new IOException("ID "+parentID+" is not a sig.");
   Field field = null;
   for(Field f: parent.getFields())
       if (f.label.equals(label) && f.type().arity()==arity && choices.contains(f))
          { field=f; choices.remove(f); break; }
   if (field==null) field = parent.addTrickyField(Pos.UNKNOWN, isPrivate, null, null, isMeta, new String[] {label}, UNIV.join(type)) [0];
   TupleSet ts = parseTuples(node, arity);
   expr2ts.put(field, ts);
   return field;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:25,代码来源:A4SolutionReader.java

示例4: toString

import edu.mit.csail.sdg.alloy4compiler.ast.Sig; //导入方法依赖的package包/类
/** Dumps the Kodkod solution into String. */
@Override public String toString() {
    if (!solved) return "---OUTCOME---\nUnknown.\n";
    if (eval == null) return "---OUTCOME---\nUnsatisfiable.\n";
    String answer = toStringCache;
    if (answer != null) return answer;
    Instance sol = eval.instance();
    StringBuilder sb = new StringBuilder();
    sb.append("---INSTANCE---\n" + "integers={");
    boolean firstTuple = true;
    for(IndexedEntry<TupleSet> e:sol.intTuples()) {
        if (firstTuple) firstTuple=false; else sb.append(", ");
        // No need to print e.index() since we've ensured the Int atom's String representation is always equal to ""+e.index()
        Object atom = e.value().iterator().next().atom(0);
        sb.append(atom2name(atom));
    }
    sb.append("}\n");
    try {
        for(Sig s:sigs) {
            sb.append(s.label).append("=").append(eval(s)).append("\n");
            for(Field f:s.getFields()) sb.append(s.label).append("<:").append(f.label).append("=").append(eval(f)).append("\n");
        }
        for(ExprVar v:skolems) {
            sb.append("skolem ").append(v.label).append("=").append(eval(v)).append("\n");
        }
        return toStringCache = sb.toString();
    } catch(Err er) {
        return toStringCache = ("<Evaluator error occurred: "+er+">");
    }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:31,代码来源:A4Solution.java

示例5: writesig

import edu.mit.csail.sdg.alloy4compiler.ast.Sig; //导入方法依赖的package包/类
/** Write the given Sig. */
private A4TupleSet writesig(final Sig x) throws Err {
   A4TupleSet ts = null, ts2 = null;
   if (x==Sig.NONE) return null; // should not happen, but we test for it anyway
   if (sol==null && x.isMeta!=null) return null; // When writing the metamodel, skip the metamodel sigs!
   if (x instanceof PrimSig) for(final PrimSig sub:children((PrimSig)x)) {
      A4TupleSet ts3 = writesig(sub);
      if (ts2==null) ts2 = ts3; else ts2 = ts2.plus(ts3);
   }
   if (rep!=null) rep.write(x);
   Util.encodeXMLs(out, "\n<sig label=\"", x.label, "\" ID=\"", map(x));
   if (x instanceof PrimSig && x!=Sig.UNIV) Util.encodeXMLs(out, "\" parentID=\"", map(((PrimSig)x).parent));
   if (x.builtin) out.print("\" builtin=\"yes");
   if (x.isAbstract!=null) out.print("\" abstract=\"yes");
   if (x.isOne!=null) out.print("\" one=\"yes");
   if (x.isLone!=null) out.print("\" lone=\"yes");
   if (x.isSome!=null) out.print("\" some=\"yes");
   if (x.isPrivate!=null) out.print("\" private=\"yes");
   if (x.isMeta!=null) out.print("\" meta=\"yes");
   if (x instanceof SubsetSig && ((SubsetSig)x).exact) out.print("\" exact=\"yes");
   if (x.isEnum!=null) out.print("\" enum=\"yes");
   out.print("\">\n");
   try {
       if (sol!=null && x!=Sig.UNIV && x!=Sig.SIGINT && x!=Sig.SEQIDX) {
          ts = (A4TupleSet)(sol.eval(x));
          for(A4Tuple t: ts.minus(ts2))  Util.encodeXMLs(out, "   <atom label=\"", t.atom(0), "\"/>\n");
       }
   } catch(Throwable ex) {
       throw new ErrorFatal("Error evaluating sig " + x.label, ex);
   }
   if (x instanceof SubsetSig) for(Sig p:((SubsetSig)x).parents) Util.encodeXMLs(out, "   <type ID=\"", map(p), "\"/>\n");
   out.print("</sig>\n");
   for(Field field: x.getFields()) writeField(field);
   return ts;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:36,代码来源:A4SolutionWriter.java


注:本文中的edu.mit.csail.sdg.alloy4compiler.ast.Sig.getFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。