Package wycs.core

Examples of wycs.core.Code$Nary


     * @param code the tuple load code to simplify.
     * @return the (if possible) simplified code.
     */
    private Code simplify(Code.Load code) {
        // Recurse into the operand first
        Code operand = simplify(code.operands[0]);

        // Simplify known tuples
        if (operand.opcode == Code.Op.TUPLE) {
            operand = operand.operands[code.index];
        }
View Full Code Here


                // Create a binding that replaces the named return variable with the function call
                Map<Integer, Code> binding = new HashMap();
                binding.put(0, Code.FunCall(type, Code.Variable(type.from(), 1), code.nid));

                // Substitute and instantiate to get the new operand for the assertion
                Code operand = function.constraint.substitute(binding).instantiate(generics);
                Pair<SemanticType, Integer>[] types = new Pair[] {new Pair(type.from(), 1)};
                // TODO: What type should a quantifier have?
                Code assertion = Code.Quantifier(SemanticType.Bool, Code.Op.FORALL, operand, types);

                block.append(new Stmt.Assert(translate(assertion)));
            }
        }
View Full Code Here

        return "(" + id + " " + translate(code.operands[0]) + ")";
    }

    private String translate(Code.Load code) {
        Code operand = simplify(code.operands[0]);

        // Check to see if we can simplify this expression
        if (operand.opcode == Code.Op.CONST) {
            Value.Tuple tuple = (Value.Tuple) ((Code.Constant) operand).value;
View Full Code Here

    return Code.Load(e.type, transform(e.operands[0]), e.index,
        e.attributes());
  }

  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
View Full Code Here

    long startMemory = runtime.freeMemory();

    Automaton automaton = new Automaton();
    Automaton original = null;

    Code neg = Code.Unary(SemanticType.Bool,
        Code.Op.NOT, stmt.condition);
    // The following conversion is potentially very expensive, but is
    // currently necessary for the instantiate axioms phase.
    Code nnf = NormalForms.negationNormalForm(neg);

    ///debug(nnf,filename);
    int maxVar = findLargestVariable(nnf);

    Code vc = instantiateAxioms(nnf, maxVar + 1);

    //debug(vc,filename);

    int assertion = translate(vc,automaton,new HashMap<String,Integer>());
    automaton.setRoot(0, assertion);
View Full Code Here

        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.
          HashMap<String,SemanticType> generics = buildGenericBinding(fn.type.generics(),condition.type.generics());
          Code axiom = renameToAvoidCapture(fn.constraint,freeVariable);
          HashMap<Integer,Code> binding = new HashMap<Integer,Code>();
          binding.put(1, condition.operands[0]);
          binding.put(0, condition);
          axiom = axiom.substitute(binding).instantiate(
              generics);
          axioms.add(axiom);
        }
      } else if(d instanceof WycsFile.Macro){
        // we can ignore macros, because they are inlined separately by
View Full Code Here

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

    if(expression.opcode == Code.Op.LENGTH) {
      Code lez = Code.Binary(SemanticType.Int, Code.Op.LTEQ,
          Code.Constant(Value.Integer(BigInteger.ZERO)), expression);
      axioms.add(lez);
    }
  }
View Full Code Here

      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(
            fn.type.generics(), expression.type.generics());
        Code axiom = renameToAvoidCapture(fn.constraint,freeVariable);
        HashMap<Integer,Code> binding = new HashMap<Integer,Code>();
        binding.put(1, expression.operands[0]);
        binding.put(0, expression);
        axiom = axiom.substitute(binding).instantiate(
            generics);
        axioms.add(axiom);
      }
    } catch (Exception ex) {
      internalFailure(ex.getMessage(), filename, expression, ex);
View Full Code Here

TOP

Related Classes of wycs.core.Code$Nary

Copyright © 2018 www.massapicom. 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.