Package edu.cmu.cs.crystal.tac.model

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


    ReturnStatement ret = (ReturnStatement) EclipseTACSimpleTestDriver.getLastStatementReturn(m);
    Assert.assertTrue(ret.getExpression() != null);
    TACInstruction instr = tac.instruction(ret);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof ReturnInstruction);
    ReturnInstruction binop = (ReturnInstruction) instr;
    Assert.assertEquals(tac.variable(ret.getExpression()), binop.getReturnedVariable());
  }
View Full Code Here


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

    ReturnInstruction invoke = (ReturnInstruction) instr;

    IMethodBinding binding = method.getBinding();
   
    if (methodName != null && !(methodName.equals(binding.getName())))
      return null;

    if (thisType != null && !types.existsCommonSubtype(thisType, binding.getDeclaringClass().getQualifiedName()))
      return null;
   
    //it should match if the op is static and the method we are in is not, but not
    //the other way around.
    if (method.getThisVar() == null && !isStatic)
      return null;
   
    if (resType != null) {
      if (invoke.getReturnedVariable() == null)
        return null;
     
      String resVarType = invoke.getReturnedVariable().resolveType().getQualifiedName();
      if (!types.existsCommonSubtype(resType, resVarType))
        return null;
    }

    ConsList<Binding> vars = ConsList.empty();
    Variable[] params = method.getParams();
   
    if (paramTypes != null) {
      if (binding.getParameterTypes().length != paramTypes.length)
        return null;
     
      for (int ndx = 0; ndx < paramTypes.length; ndx++) {
        if (!types.existsCommonSubtype(paramTypes[ndx], binding.getParameterTypes()[ndx].getQualifiedName()))
          return null;
        vars = ConsList.cons(new Binding(paramNames[ndx], params[ndx]), vars);
      }
    }

    if (invoke.getReturnedVariable() != null && resType != null)
      vars = ConsList.cons(new Binding(Constraint.RESULT, invoke.getReturnedVariable()), vars);
   
    if (!isStatic)
      vars = ConsList.cons(new Binding(Constraint.RECEIVER, method.getThisVar()), vars);
    return vars;
  }
View Full Code Here

TOP

Related Classes of edu.cmu.cs.crystal.tac.model.ReturnInstruction

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.