当前位置: 首页>>代码示例>>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;未经允许,请勿转载。