Examples of WycsFile


Examples of wycs.core.WycsFile

      if (src.contentType() == WycsFile.ContentType) {
        Path.Entry<WycsFile> sf = (Path.Entry<WycsFile>) src;
        Path.Entry<WyalFile> df = (Path.Entry<WyalFile>) dst.create(
            sf.id(), WyalFile.ContentType);
        generatedFiles.add(df);
        WycsFile wf = sf.read();
        // NOTE: following is really a temporary hack
        new WycsFilePrinter(System.err).write(wf);
        WyalFile waf = decompile(wf);
        df.write(waf);
        count++;
View Full Code Here

Examples of wycs.core.WycsFile

        // i.e. abs(int x) => int y: x >= 0 ==> y > 0
        // Has the declaration: abs(int) => int
        // and the assertion: forall (r1 int) . r1 >= 0 ==> abs(r1) > 0
        // (note: functions have the return value numbered as 0, so the parameters start from 1)

        WycsFile module = null;
        try {
            module = builder.getModule(code.nid.module());
        } catch (Exception e) {
            internalFailure(e.getMessage(), wycsFile.filename(), code, e);
        }

        if (module == null) {
            throw new InternalError("module '" + code.nid.module() + "' not found");
        }

        WycsFile.Declaration decl = module.declaration(code.nid.name());

        if (decl == null) {
            throw new InternalError(
                    "function call to a non-declared function (name=" + code.nid.name() + ")");
        }
View Full Code Here

Examples of wycs.core.WycsFile

      if (src.contentType() == WyalFile.ContentType) {
        Path.Entry<WyalFile> source = (Path.Entry<WyalFile>) src;
        Path.Entry<WycsFile> target = (Path.Entry<WycsFile>) dst.create(src.id(),WycsFile.ContentType);
        generatedFiles.add(target);
        WyalFile wf = source.read();
        WycsFile wycs = getModuleStub(wf);
        target.write(wycs);
      }
    }
    logger.logTimedMessage("Generated stubs for " + count + " source file(s).",
        System.currentTimeMillis() - tmpTime, tmpMem - runtime.freeMemory());

    // ========================================================================
    // Type source files
    // ========================================================================
    runtime = Runtime.getRuntime();
    tmpTime = System.currentTimeMillis();
    tmpMem = runtime.freeMemory();

    TypePropagation typer = new TypePropagation(this);
    for(Pair<Path.Entry<?>,Path.Root> p : delta) {
      Path.Entry<?> f = p.first();
      if (f.contentType() == WyalFile.ContentType) {
        Path.Entry<WyalFile> sf = (Path.Entry<WyalFile>) f;
        WyalFile wf = sf.read();
        typer.apply(wf);
      }
    }

    logger.logTimedMessage("Typed " + count + " source file(s).",
        System.currentTimeMillis() - tmpTime, tmpMem - runtime.freeMemory());


    // ========================================================================
    // Code Generation
    // ========================================================================
    runtime = Runtime.getRuntime();
    tmpTime = System.currentTimeMillis();
    tmpMem = runtime.freeMemory();

    CodeGeneration generator = new CodeGeneration(this);
    for (Pair<Path.Entry<?>, Path.Root> p : delta) {
      Path.Entry<?> src = p.first();
      Path.Root dst = p.second();
      if (src.contentType() == WyalFile.ContentType) {
        Path.Entry<WyalFile> source = (Path.Entry<WyalFile>) src;
        Path.Entry<WycsFile> target = (Path.Entry<WycsFile>) dst
            .create(src.id(), WycsFile.ContentType);
        WyalFile wf = source.read();
        WycsFile wycs = generator.generate(wf);
        target.write(wycs);
      }
    }

    logger.logTimedMessage("Generated code for " + count + " source file(s).",
          System.currentTimeMillis() - tmpTime, tmpMem - runtime.freeMemory());

    // ========================================================================
    // Pipeline Stages
    // ========================================================================

    for (Transform<WycsFile> stage : pipeline) {
      for (Pair<Path.Entry<?>, Path.Root> p : delta) {
        Path.Root dst = p.second();
        Path.Entry<WycsFile> df = dst.get(p.first().id(),WycsFile.ContentType);
        WycsFile module = df.read();
        try {
          process(module, stage);
        } catch (VerificationCheck.AssertionFailure ex) {
          // FIXME: this feels a bit like a hack.
          if(debug && ex.original() != null) {
            Rewriter rw = ex.rewriter();
            PrettyAutomataWriter writer = new PrettyAutomataWriter(System.out,SCHEMA,"Or","And");
            writer.write(ex.original());
            writer.flush();
            System.err.println("\n\n=> (" + rw.getStats() + ")\n");
            writer.write(ex.reduction());
            writer.flush();
          }
          syntaxError(ex.getMessage(), module.filename(),
              ex.assertion(), ex);
        } catch (SmtVerificationCheck.AssertionFailure e) {
                    syntaxError(e.getMessage(), module.filename(),
                            e.getAssertion(), e);
                }
      }
    }
View Full Code Here

Examples of wycs.core.WycsFile

      throws ResolveError {

    for (WyalFile.Import imp : context.imports()) {
      for (Path.ID id : imports(imp.filter)) {
        try {
          WycsFile wf = getModule(id);
          if(wf == null) { continue; }
          T d = wf.declaration(name, type);
          if (d != null) {
            return new Pair<NameID, T>(new NameID(id, name), d);
          }
        } catch(SyntaxError e) {
          throw e;
View Full Code Here

Examples of wycs.core.WycsFile

        declarations.add(new WycsFile.Function(fun.name, type, null,
            fun.attribute(Attribute.Source.class)));
      }
    }

    return new WycsFile(wyalFile.id(), wyalFile.filename(), declarations);
  }
View Full Code Here

Examples of wycs.core.WycsFile

  }

  private Code transform(Code.FunCall e) {
    Code r = e;
    try {
      WycsFile module = builder.getModule(e.nid.module());
      // In principle, module should not be null if TypePropagation has
      // already passed. However, in the case of a function call inserted
      // during code generation, there is no guarantee that it was
      // previously resolved. This can cause problems if the standard
      // library is not on the path as e.g. x[i] is translated into
      // a call to wycs.core.Map.IndexOf().
      if(module == null) {
        internalFailure("cannot resolve as module: " + e.nid.module(), filename, e);
      }
      Object d = module.declaration(e.nid.name());
      if(d instanceof WycsFile.Function) {
        // Do nothing, since functions are not expanded like macros.
        // Instead, their axioms may be instantiated later either before
        // or during rewriting.
      } else if (d instanceof WycsFile.Macro) {
View Full Code Here

Examples of wycs.core.WycsFile

  }

  public static void debug(Code code, String filename) {
    ArrayList<WycsFile.Declaration> tmpDecls = new ArrayList();
    tmpDecls.add(new WycsFile.Assert("", code));
    WycsFile tmp = new WycsFile(Trie.ROOT, filename, tmpDecls);
    try {
      new WycsFilePrinter(System.err).write(tmp);
    } catch (IOException e) {
    }
  }
View Full Code Here

Examples of wycs.core.WycsFile

  }

  private Code instantiateAxioms(Code.FunCall condition, int freeVariable) {
    ArrayList<Code> axioms = new ArrayList<Code>();
    try {
      WycsFile module = builder.getModule(condition.nid.module());
      // module should not be null if TypePropagation has already passed.
      Object d = module.declaration(condition.nid.name());
      if(d instanceof WycsFile.Function) {
        WycsFile.Function fn = (WycsFile.Function) d;
        if(fn.constraint != null) {
          // There are some axioms we can instantiate. First, we need to
          // construct the generic binding for this function.
View Full Code Here

Examples of wycs.core.WycsFile

  private void instantiateFromExpression(Code.FunCall expression, ArrayList<Code> axioms, int freeVariable) {
    instantiateFromExpression(expression.operands[0], axioms, freeVariable);

    try {
      WycsFile module = builder.getModule(expression.nid.module());
      // module should not be null if TypePropagation has already passed.
      WycsFile.Function fn = module.declaration(expression.nid.name(),
          WycsFile.Function.class);
      if (fn.constraint != null) {
        // There are some axioms we can instantiate. First, we need to
        // construct the generic binding for this function.
        HashMap<String, SemanticType> generics = buildGenericBinding(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.