Package edu.cmu.cs.fusion.constraint

Examples of edu.cmu.cs.fusion.constraint.SpecVar


  }

  @Test
  public void testFindLabelsDefAndPoss() {
    FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, null, null, testH, new InferenceEnvironment(null), Variant.PRAGMATIC_VARIANT);
    FreeVars fv = new FreeVars().addVar(new SpecVar("a"), "SnaFu").addVar(new SpecVar("b"), "Bazar");
    ConsList<Binding> list = ConsList.empty();
   
    list = ConsList.cons(new Binding(new SpecVar("a"), vars[2]), list);
    list = ConsList.cons(new Binding(new SpecVar("b"), vars[4]), list);
   
    List<Substitution> subs = env.findLabels(list, fv);
   
    assertEquals(4, subs.size());
View Full Code Here


    BooleanValue val = (BooleanValue)pred;
    Assert.assertTrue("Parsed predicate should be positive", val.isPositive());
   
    FreeVars vars = val.getFreeVariables();
    Assert.assertEquals("Should only contain one free variable", 1, vars.size());
    Assert.assertEquals("Foo should have a boolean type", "boolean", vars.getType(new SpecVar("foo")));
  }
View Full Code Here

    BooleanValue val = (BooleanValue)pred;
    Assert.assertTrue("Parsed predicate should be negative", !val.isPositive());
   
    FreeVars vars = val.getFreeVariables();
    Assert.assertEquals("Should only contain one free variable", 1, vars.size());
    Assert.assertEquals("Foo should have a boolean type", "boolean", vars.getType(new SpecVar("foo")));
  }
View Full Code Here

    Assert.assertTrue("Parsed inner predicate should be positive", val.getRelationship().isPositive());
    Assert.assertEquals("Inner relationship incorrect", "Foo", val.getRelationship().getRelation().getName());
   
    FreeVars vars = val.getFreeVariables();
    Assert.assertEquals("Should only contain three free variables", 3, vars.size());
    Assert.assertEquals("c should have a boolean type", "boolean", vars.getType(new SpecVar("c")));   
    Assert.assertEquals("a should have a Bar type", "Bar", vars.getType(new SpecVar("a")));   
    Assert.assertEquals("b should have a Baz type", "Baz", vars.getType(new SpecVar("b")));   
  }
View Full Code Here

    Assert.assertTrue("Parsed inner predicate should be positive", val.getRelationship().isPositive());
    Assert.assertEquals("Inner relationship incorrect", "Foo", val.getRelationship().getRelation().getName());
   
    FreeVars vars = val.getFreeVariables();
    Assert.assertEquals("Should only contain three free variables", 3, vars.size());
    Assert.assertEquals("c should have a boolean type", "boolean", vars.getType(new SpecVar("c")));   
    Assert.assertEquals("a should have a Bar type", "Bar", vars.getType(new SpecVar("a")));   
    Assert.assertEquals("b should have a Baz type", "Baz", vars.getType(new SpecVar("b")));   
  }
View Full Code Here

    Assert.assertTrue("Parsed inner predicate should be negative", !val.getRelationship().isPositive());
    Assert.assertEquals("Inner relationship incorrect", "Foo", val.getRelationship().getRelation().getName());
   
    FreeVars vars = val.getFreeVariables();
    Assert.assertEquals("Should only contain three free variables", 3, vars.size());
    Assert.assertEquals("c should have a boolean type", "boolean", vars.getType(new SpecVar("c")));   
    Assert.assertEquals("a should have a Bar type", "Bar", vars.getType(new SpecVar("a")));   
    Assert.assertEquals("b should have a Baz type", "Baz", vars.getType(new SpecVar("b")));   
  }
View Full Code Here

    Assert.assertTrue("Parsed inner predicate should be negative", !val.getRelationship().isPositive());
    Assert.assertEquals("Inner relationship incorrect", "Foo", val.getRelationship().getRelation().getName());
   
    FreeVars vars = val.getFreeVariables();
    Assert.assertEquals("Should only contain three free variables", 3, vars.size());
    Assert.assertEquals("c should have a boolean type", "boolean", vars.getType(new SpecVar("c")));   
    Assert.assertEquals("a should have a Bar type", "Bar", vars.getType(new SpecVar("a")));   
    Assert.assertEquals("b should have a Baz type", "Baz", vars.getType(new SpecVar("b")));   
  }
View Full Code Here

      String[] paramTypes = new String[method.getParameterTypes().length];
      SpecVar[] opParams = new SpecVar[method.getParameterNames().length];
     
      for (int ndx = 0; ndx < paramTypes.length; ndx++) {
        paramTypes[ndx] = Utilities.resolveType(contextType, Signature.toString(method.getParameterTypes()[ndx]));
        opParams[ndx] = new SpecVar(method.getParameterNames()[ndx]);
      }
      op = new ConstructorOp(type, opParams, paramTypes);
   
    }
    else {
      IType contextType = method.getDeclaringType();
      String methodName = method.getElementName();
      String receiverType = contextType.getFullyQualifiedName();
      String returnType = Utilities.resolveType(contextType, Signature.toString(method.getReturnType()));
      String[] paramTypes = new String[method.getParameterTypes().length];
      SpecVar[] opParams = new SpecVar[method.getParameterNames().length];
      boolean isStatic = Flags.isStatic(method.getFlags());
     
      for (int ndx = 0; ndx < paramTypes.length; ndx++) {
        paramTypes[ndx] = Utilities.resolveType(contextType, Signature.toString(method.getParameterTypes()[ndx]));
        opParams[ndx] = new SpecVar(method.getParameterNames()[ndx]);
      }
      op = new MethodInvocationOp(methodName, receiverType, opParams, paramTypes, returnType, isStatic);
    }
    String owner = method.getDeclaringType().getFullyQualifiedName();
    constraints.add(new Constraint(owner, op, new TruePredicate(), new TruePredicate(), new TruePredicate(), effects));
View Full Code Here

   
    for (int ndx = 0; ndx < objParams.length; ndx++) {
      if (objParams[ndx].equals(SpecVar.WILD_CARD))
        params[ndx] = SpecVar.createWildCard();
      else
        params[ndx] = new SpecVar((String)objParams[ndx]);
    }
   
/*      try {
      checkTypes(rel, params, method);
    } catch (ParseException e) {
      // TODO Put out a real error message
      e.printStackTrace();
    }
*/     
    edu.cmu.cs.fusion.annot.Relation.Effect actualEffect;
   
    if (actEffectPair != null) {
      String strEffect = ((String)actEffectPair.getValue()).substring(((String)actEffectPair.getValue()).lastIndexOf('.') + 1); //SCREW YOU ECLIPSE!!!!!
      actualEffect = edu.cmu.cs.fusion.annot.Relation.Effect.valueOf(strEffect);
    }
    else
      actualEffect = edu.cmu.cs.fusion.annot.Relation.Effect.ADD;
   
    String test = null;
   
    switch (actualEffect) {
    case ADD:
      effect = RelEffect.createAddEffect(rel, params);
      break;
    case REMOVE:
      effect = RelEffect.createRemoveEffect(rel, params);
      break;
    case TEST:
      test = (String) testPair.getValue();
      effect = RelEffect.createTestEffect(rel, params, new SpecVar(test));
      break;
    }
    return effect;
  }
View Full Code Here

   
    String[] paramTypes = new String[methodType.getParameterTypes().length];
    SpecVar[] params = new SpecVar[paramTypes.length];
    for (int ndx = 0; ndx < paramTypes.length; ndx++) {
      paramTypes[ndx] = Utilities.resolveBinaryType(declaringType, methodType.getParameterTypes()[ndx]);
      params[ndx] = new SpecVar(methodType.getParameterNames()[ndx]);
    }
   
    boolean isStatic = Flags.isStatic(methodType.getFlags());
   
    Operation op = new BeginOfMethodOp(declaringType.getFullyQualifiedName(), methodType.getElementName(), params, paramTypes, isStatic);
View Full Code Here

TOP

Related Classes of edu.cmu.cs.fusion.constraint.SpecVar

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.