Examples of MethodCallInstruction


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

    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    MethodInvocation inv = (MethodInvocation) ((ExpressionStatement) EclipseTACSimpleTestDriver.getLastStatement(m)).getExpression();
    TACInstruction instr = tac.instruction(inv);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof MethodCallInstruction);
    MethodCallInstruction call = (MethodCallInstruction) instr;
   
    List<Variable> args = call.getArgOperands();
    EclipseTACSimpleTestDriver.assertOperands(inv.arguments(), args, tac);
    Assert.assertEquals(1, args.size());
   
    Assignment write = (Assignment) inv.arguments().get(0);
    instr = tac.instruction(write);
View Full Code Here

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

    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    MethodInvocation invoke = (MethodInvocation) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(invoke);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof MethodCallInstruction);
    MethodCallInstruction call = (MethodCallInstruction) instr;
    Assert.assertNull(((ThisVariable) tac.implicitThisVariable(m.resolveBinding())).getQualifier());
    Assert.assertEquals(tac.implicitThisVariable(m.resolveBinding()), call.getReceiverOperand());
    EclipseTACSimpleTestDriver.assertOperands(invoke.arguments(), call.getArgOperands(), tac);
    Assert.assertTrue(call.getArgOperands().get(0) instanceof SourceVariable);
    Assert.assertEquals(
        tac.sourceVariable(((SingleVariableDeclaration) m.parameters().get(0)).resolveBinding()),
        call.getArgOperands().get(0));
  }
View Full Code Here

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

    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    MethodInvocation invoke = (MethodInvocation) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(invoke);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof MethodCallInstruction);
    MethodCallInstruction call = (MethodCallInstruction) instr;
    Assert.assertEquals(tac.typeVariable(m.resolveBinding().getDeclaringClass()), call.getReceiverOperand());
    EclipseTACSimpleTestDriver.assertOperands(invoke.arguments(), call.getArgOperands(), tac);
    Assert.assertTrue(call.getArgOperands().get(0) instanceof SourceVariable);
    Assert.assertEquals(
        tac.sourceVariable(((SingleVariableDeclaration) m.parameters().get(0)).resolveBinding()),
        call.getArgOperands().get(0));
  }
View Full Code Here

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

    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    MethodInvocation inv = (MethodInvocation) ((ExpressionStatement) EclipseTACSimpleTestDriver.getLastStatement(m)).getExpression();
    TACInstruction instr = tac.instruction(inv);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof MethodCallInstruction);
    MethodCallInstruction call = (MethodCallInstruction) instr;
   
    List<Variable> args = call.getArgOperands();
    EclipseTACSimpleTestDriver.assertOperands(inv.arguments(), args, tac);
    Assert.assertEquals(1, args.size());
   
    Assignment write = (Assignment) inv.arguments().get(0);
    instr = tac.instruction(write);
View Full Code Here

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

  public void testMatchWrongMethodName() {
    List<StubVariable> params = new ArrayList<StubVariable>();
    params.add(new StubVariable());
    params.add(new StubVariable());

    MethodCallInstruction instr = getMCI(new StubVariable(), params, 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, "Bazaz", false);
   
    ConsList<Binding> map = op.matches(new EqualityOnlyTypeHierarchy(), null, instr);
View Full Code Here

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

  public void testMatchWrongReceiverType() {
    List<StubVariable> params = new ArrayList<StubVariable>();
    params.add(new StubVariable());
    params.add(new StubVariable());

    MethodCallInstruction instr = getMCI(new StubVariable(), params, new StubVariable());
    SpecVar[] vars = new SpecVar[] {utils.getVar(0), utils.getVar(1)};
    String[] vTypes = new String[] {"Bar", "Baz"};
    MethodInvocationOp op = new MethodInvocationOp("mName", "Foo2", vars, vTypes, "Bazaz", false);
   
    ConsList<Binding> map = op.matches(new EqualityOnlyTypeHierarchy(), null, instr);
View Full Code Here

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

  public void testMatchWrongParamType() {
    List<StubVariable> params = new ArrayList<StubVariable>();
    params.add(new StubVariable());
    params.add(new StubVariable());

    MethodCallInstruction instr = getMCI(new StubVariable(), params, new StubVariable());
    SpecVar[] vars = new SpecVar[] {utils.getVar(0), utils.getVar(1)};
    String[] vTypes = new String[] {"Bar", "Baz2"};
    MethodInvocationOp op = new MethodInvocationOp("mName", "Foo", vars, vTypes, "Bazaz", false);
   
    ConsList<Binding> map = op.matches(new EqualityOnlyTypeHierarchy(), null, instr);
View Full Code Here

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

    List<StubVariable> params = new ArrayList<StubVariable>();
    params.add(new StubVariable());
    params.add(new StubVariable());
    params.add(new StubVariable());

    MethodCallInstruction instr = getMCI(new StubVariable(), params, new StubVariable());
    SpecVar[] vars = new SpecVar[] {utils.getVar(0), utils.getVar(1)};
    String[] vTypes = new String[] {"Bar", "Baz", "blah"};
    MethodInvocationOp op = new MethodInvocationOp("mName", "Foo", vars, vTypes, "Bazaz", false);
   
    ConsList<Binding> map = op.matches(new EqualityOnlyTypeHierarchy(), null, instr);
View Full Code Here

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

    StubVariable p2 = new StubVariable();
    List<StubVariable> params = new ArrayList<StubVariable>();
    params.add(p1);
    params.add(p2);

    MethodCallInstruction instr = getMCI(rVar, params, tVar);
    SpecVar[] vars = new SpecVar[] {utils.getVar(0), utils.getVar(1)};
    String[] vTypes = new String[] {"Bar", "Baz"};
    MethodInvocationOp op = new MethodInvocationOp("mName", "Foo", vars, vTypes, "Bazaz", false);
   
    ConsList<Binding> list = op.matches(new EqualityOnlyTypeHierarchy(), null, instr);
View Full Code Here

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

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

    MethodCallInstruction invoke = (MethodCallInstruction) instr;

    //first, check to see if the instr is right for this op
    if (!name.equals(invoke.getMethodName()))
      return null;
   
    if (isStatic != invoke.isStaticMethodCall())
      return null;

    IMethodBinding binding = invoke.resolveBinding();

    if (!types.existsCommonSubtype(thisType, invoke.getReceiverOperand().resolveType().getQualifiedName()))
      return null;

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

    for (int ndx = 0; ndx < paramTypes.length; ndx++)
      if (!types.existsCommonSubtype(paramTypes[ndx], invoke.getArgOperands().get(ndx).resolveType().getQualifiedName()))
        return null;
   
    ConsList<Binding> vars = ConsList.empty();
   
    if (!isStatic
      vars = ConsList.cons(new Binding(thisVar, invoke.getReceiverOperand()), vars);
    vars = ConsList.cons(new Binding(retVar, invoke.getTarget()), vars);
   
    for (int ndx = 0; ndx < params.length; ndx++)
      vars = ConsList.cons(new Binding(params[ndx], invoke.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.