當前位置: 首頁>>代碼示例>>Java>>正文


Java TranslateAlloyToKodkod.execute_commandFromBook方法代碼示例

本文整理匯總了Java中edu.mit.csail.sdg.alloy4compiler.translator.TranslateAlloyToKodkod.execute_commandFromBook方法的典型用法代碼示例。如果您正苦於以下問題:Java TranslateAlloyToKodkod.execute_commandFromBook方法的具體用法?Java TranslateAlloyToKodkod.execute_commandFromBook怎麽用?Java TranslateAlloyToKodkod.execute_commandFromBook使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在edu.mit.csail.sdg.alloy4compiler.translator.TranslateAlloyToKodkod的用法示例。


在下文中一共展示了TranslateAlloyToKodkod.execute_commandFromBook方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import edu.mit.csail.sdg.alloy4compiler.translator.TranslateAlloyToKodkod; //導入方法依賴的package包/類
public void run(WorkerCallback out) throws Exception {
    cb(out, "S2", "Starting the solver...\n\n");
    final SimpleReporter rep = new SimpleReporter(out, options.recordKodkod);
    final Module world = CompUtil.parseEverything_fromFile(rep, map, options.originalFilename, resolutionMode);
    final List<Sig> sigs = world.getAllReachableSigs();
    final ConstList<Command> cmds = world.getAllCommands();
    cb(out, "warnings", bundleWarningNonFatal);
    if (rep.warn>0 && !bundleWarningNonFatal) return;
    List<String> result = new ArrayList<String>(cmds.size());
    if (bundleIndex==-2) {
        final String outf=tempdir+File.separatorChar+"m.xml";
        cb(out, "S2", "Generating the metamodel...\n");
        PrintWriter of = new PrintWriter(outf, "UTF-8");
        Util.encodeXMLs(of, "\n<alloy builddate=\"", Version.buildDate(), "\">\n\n");
        A4SolutionWriter.writeMetamodel(ConstList.make(sigs), options.originalFilename, of);
        Util.encodeXMLs(of, "\n</alloy>");
        Util.close(of);
        if ("yes".equals(System.getProperty("debug"))) validate(outf);
        cb(out, "metamodel", outf);
        synchronized(SimpleReporter.class) { latestMetamodelXML=outf; }
    } else for(int i=0; i<cmds.size(); i++) if (bundleIndex<0 || i==bundleIndex) {
        synchronized(SimpleReporter.class) { latestModule=world; latestKodkodSRC=ConstMap.make(map); }
        final String tempXML=tempdir+File.separatorChar+i+".cnf.xml";
        final String tempCNF=tempdir+File.separatorChar+i+".cnf";
        final Command cmd=cmds.get(i);
        rep.tempfile=tempCNF;
        cb(out, "bold", "Executing \""+cmd+"\"\n");
        A4Solution ai=TranslateAlloyToKodkod.execute_commandFromBook(rep, world.getAllReachableSigs(), cmd, options);
        if (ai==null) result.add(null);
        else if (ai.satisfiable()) result.add(tempXML);
        else if (ai.highLevelCore().a.size()>0) result.add(tempCNF+".core");
        else result.add("");
    }
    (new File(tempdir)).delete(); // In case it was UNSAT, or canceled...
    if (result.size()>1) {
        rep.cb("bold", "" + result.size() + " commands were executed. The results are:\n");
        for(int i=0; i<result.size(); i++) {
            Command r=world.getAllCommands().get(i);
            if (result.get(i)==null) { rep.cb("", "   #"+(i+1)+": Unknown.\n"); continue; }
            if (result.get(i).endsWith(".xml")) {
                rep.cb("", "   #"+(i+1)+": ");
                rep.cb("link", r.check?"Counterexample found. ":"Instance found. ", "XML: "+result.get(i));
                rep.cb("", r.label+(r.check?" is invalid":" is consistent"));
                if (r.expects==0) rep.cb("", ", contrary to expectation");
                else if (r.expects==1) rep.cb("", ", as expected");
            } else if (result.get(i).endsWith(".core")) {
                rep.cb("", "   #"+(i+1)+": ");
                rep.cb("link", r.check?"No counterexample found. ":"No instance found. ", "CORE: "+result.get(i));
                rep.cb("", r.label+(r.check?" may be valid":" may be inconsistent"));
                if (r.expects==1) rep.cb("", ", contrary to expectation");
                else if (r.expects==0) rep.cb("", ", as expected");
            } else {
                if (r.check) rep.cb("", "   #"+(i+1)+": No counterexample found. "+r.label+" may be valid");
                else rep.cb("", "   #"+(i+1)+": No instance found. "+r.label+" may be inconsistent");
                if (r.expects==1) rep.cb("", ", contrary to expectation");
                else if (r.expects==0) rep.cb("", ", as expected");
            }
            rep.cb("", ".\n");
        }
        rep.cb("", "\n");
    }
    if (rep.warn>1) rep.cb("bold", "Note: There were "+rep.warn+" compilation warnings. Please scroll up to see them.\n");
    if (rep.warn==1) rep.cb("bold", "Note: There was 1 compilation warning. Please scroll up to see it.\n");
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:65,代碼來源:SimpleReporter.java


注:本文中的edu.mit.csail.sdg.alloy4compiler.translator.TranslateAlloyToKodkod.execute_commandFromBook方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。