Examples of NewObjectInstruction


Examples of edu.cmu.cs.crystal.tac.model.NewObjectInstruction

    assertTrue(map == null)
  }
 
  @Test
  public void testMatchWrongParamNums() {
    NewObjectInstruction instr = getNOI(new StubVariable(), new StubVariable());

    SpecVar[] vars = new SpecVar[] {utils.getVar(0), utils.getVar(1)};
    String[] vTypes = new String[] {"Bar", "Baz"};
    ConstructorOp op = new ConstructorOp("Foo", vars, vTypes);
   
View Full Code Here

Examples of edu.cmu.cs.crystal.tac.model.NewObjectInstruction

  @Test
  public void testMatchCorrect() {
    StubVariable target = new StubVariable();
    StubVariable param = new StubVariable();

    NewObjectInstruction instr = getNOI(target, param);
    SpecVar[] vars = new SpecVar[] {utils.getVar(0)};
    String[] vTypes = new String[] {"Bar"};
    ConstructorOp op = new ConstructorOp("Foo", vars, vTypes);
   
    ConsList<Binding> list = op.matches(new EqualityOnlyTypeHierarchy(), null, instr);
View Full Code Here

Examples of edu.cmu.cs.crystal.tac.model.NewObjectInstruction

  @Test
  public void testMatchCorrectAndMultiple() {
    StubVariable target = new StubVariable();

    NewObjectInstruction instr = getNOI(target, target);
    SpecVar[] vars = new SpecVar[] {utils.getVar(0)};
    String[] vTypes = new String[] {"Bar"};
    ConstructorOp op = new ConstructorOp("Foo", vars, vTypes);
   
    ConsList<Binding> list = op.matches(new EqualityOnlyTypeHierarchy(), null, instr);
View Full Code Here

Examples of edu.cmu.cs.crystal.tac.model.NewObjectInstruction

    params.add(v2);
   
    StubMethodBinding binding = new StubMethodBinding(new NamedTypeBinding("Foo"), vBindings);
    Method method = new Method(new Variable[] {v1, v2}, null, binding);
   
    NewObjectInstruction instr = new StubNewObjectInstruction(params, binding, new StubVariable())
    BeginOfMethodOp op = new BeginOfMethodOp(null, null, null, null, false);
   
    ConsList<Binding> map = op.matches(new EqualityOnlyTypeHierarchy(), method, instr);

    assertTrue(map == null);
View Full Code Here

Examples of edu.cmu.cs.crystal.tac.model.NewObjectInstruction

    NamedTypeBinding[] vBindings = new NamedTypeBinding[] {new NamedTypeBinding("Bar"), new NamedTypeBinding("Baz")};
    List<StubVariable> params = new ArrayList<StubVariable>();
    params.add(new StubVariable());
    params.add(new StubVariable());
   
    NewObjectInstruction instr = new StubNewObjectInstruction(params, new StubMethodBinding(new NamedTypeBinding("Foo"), vBindings), new StubVariable())
    SpecVar[] vars = new SpecVar[] {utils.getVar(0), utils.getVar(1)};
    String[] vTypes = new String[] {"Bar", "Baz"};
    MethodInvocationOp op = new MethodInvocationOp("testtesttest", "Foo", vars, vTypes, "void", false);
   
    ConsList<Binding> map = op.matches(new EqualityOnlyTypeHierarchy(), null, instr);
View Full Code Here

Examples of edu.cmu.cs.crystal.tac.model.NewObjectInstruction

  public ConsList<Binding> matches(TypeHierarchy types, Method method, TACInstruction instr) {
    if (!(instr instanceof NewObjectInstruction))
      return null;

    NewObjectInstruction newObj = (NewObjectInstruction) instr;

    IMethodBinding binding = newObj.resolveBinding();

    if (binding.getParameterTypes().length != paramTypes.length)
      return null;

    if (!types.existsCommonSubtype(type, binding.getDeclaringClass().getQualifiedName()))
      return null;

    for (int ndx = 0; ndx < paramTypes.length; ndx++)
      if (!types.existsCommonSubtype(paramTypes[ndx], binding.getParameterTypes()[ndx].getQualifiedName()))
        return null;
   
    ConsList<Binding> vars = ConsList.empty();
   
    vars = ConsList.cons(new Binding(ret, newObj.getTarget()), vars);
   
    for (int ndx = 0; ndx < params.length; ndx++)
      vars = ConsList.cons(new Binding(params[ndx], newObj.getArgOperands().get(ndx)), vars);

    return vars;
  }
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.