Package ch.epfl.labos.iu.orm.queryll2.path

Examples of ch.epfl.labos.iu.orm.queryll2.path.PathAnalysisMethodChecker


         return super.virtualMethodCallValue(val, in);
   }

   @Override public ColumnExpressions<?> staticMethodCallValue(MethodCallValue.StaticMethodCallValue val, SymbExPassDown in) throws TypedValueVisitorException
   {
      MethodSignature sig = val.getSignature();
      if (sig.equals(TransformationClassAnalyzer.integerValueOf)
            || sig.equals(TransformationClassAnalyzer.longValueOf)
            || sig.equals(TransformationClassAnalyzer.doubleValueOf)
            || sig.equals(TransformationClassAnalyzer.booleanValueOf))
      {
         // Integer.valueOf() to be like a cast and assume it's correct
         SymbExPassDown passdown = SymbExPassDown.with(val, in.isExpectingConditional);
         ColumnExpressions<?> base = val.args.get(0).visit(this, passdown);
         return base;
      }
      else if (sig.equals(TransformationClassAnalyzer.bigIntegerValueOfLong))
      {
         throw new TypedValueVisitorException("New BigIntegers can only be created in the context of numeric promotion");
      }
      else if (sig.equals(MethodChecker.stringValueOfObject))
      {
         if (!val.args.get(0).getType().equals(Type.getObjectType("java/lang/String")))
            throw new TypedValueVisitorException("Do not know how to convert type " + val.args.get(0).getType() + " to a string");
         SymbExPassDown passdown = SymbExPassDown.with(val, in.isExpectingConditional);
         ColumnExpressions<?> base = val.args.get(0).visit(this, passdown);
         return base;
      }
      else if (MethodChecker.jpqlFunctionStaticMethods.contains(sig))
      {
         if (sig.equals(MethodChecker.jpqlLike))
         {
            SymbExPassDown passdown = SymbExPassDown.with(val, in.isExpectingConditional);
            ColumnExpressions<?> base = val.args.get(0).visit(this, passdown);
            ColumnExpressions<?> pattern = val.args.get(1).visit(this, passdown);
            return ColumnExpressions.singleColumn(new SimpleRowReader<>(),
                  new BinaryExpression("LIKE", base.getOnlyColumn(), pattern.getOnlyColumn()));
         }
         else if (sig.equals(MethodChecker.mathAbsDouble)
               || sig.equals(MethodChecker.mathAbsInt)
               || sig.equals(MethodChecker.mathAbsLong))
         {
            SymbExPassDown passdown = SymbExPassDown.with(val, in.isExpectingConditional);
            ColumnExpressions<?> base = val.args.get(0).visit(this, passdown);
            return ColumnExpressions.singleColumn(base.reader,
                  FunctionExpression.singleParam("ABS", base.getOnlyColumn()));
         }
         else if (sig.equals(MethodChecker.mathSqrt))
         {
            SymbExPassDown passdown = SymbExPassDown.with(val, in.isExpectingConditional);
            TypedValue baseVal = val.args.get(0);
            if (isWideningCast(baseVal))
               baseVal = skipWideningCast(baseVal);
View Full Code Here


      return ColumnExpressions.singleColumn(left.reader, result);
   }
  
   @Override public ColumnExpressions<?> virtualMethodCallValue(MethodCallValue.VirtualMethodCallValue val, Void in) throws TypedValueVisitorException
   {
      MethodSignature sig = val.getSignature();
      if (TransformationClassAnalyzer.newPair.equals(sig)
            || TransformationClassAnalyzer.newTuple3.equals(sig)
            || TransformationClassAnalyzer.newTuple4.equals(sig)
            || TransformationClassAnalyzer.newTuple5.equals(sig)
            || TransformationClassAnalyzer.newTuple8.equals(sig))
      {
         ColumnExpressions<?> [] vals = new ColumnExpressions<?> [val.args.size()];
         for (int n = 0; n < vals.length; n++)
            vals[n] = val.args.get(n).visit(this, in);
         RowReader<?> [] valReaders = new RowReader[vals.length];
         for (int n = 0; n < vals.length; n++)
            valReaders[n] = vals[n].reader;

         ColumnExpressions<?> toReturn = new ColumnExpressions<>(TupleRowReader.createReaderForTuple(sig.owner, valReaders));
         for (int n = 0; n < vals.length; n++)
            toReturn.columns.addAll(vals[n].columns);
         return toReturn;
      }
      else if (metamodel.isFieldGetterMethod(sig))
      {
         Field<?> field = metamodel.fieldMethodToField(sig);
         ColumnExpressions<?> base = val.base.visit(this, in);
         if (!(base.reader instanceof TableRowReader))
            throw new TypedValueVisitorException("Expecting a table");
         TableRowReader<?> tableReader = (TableRowReader<?>)base.reader;
         RowReader<?> columnReader = tableReader.getReaderForField(field);
         ColumnExpressions<?> newColumns = new ColumnExpressions<>(columnReader);
         int idx = tableReader.getIndexForField(field);
         for (int n = 0; n < columnReader.getNumColumns(); n++)
            newColumns.columns.add(base.columns.get(n + idx));
         return newColumns;
      }
      else if (MetamodelUtil.TUPLE_ACCESSORS.containsKey(sig))
      {
         int idx = MetamodelUtil.TUPLE_ACCESSORS.get(sig) - 1;
         ColumnExpressions<?> base = val.base.visit(this, in);
         RowReader<?> subreader = ((TupleRowReader<?>)base.reader).getReaderForIndex(idx);
         ColumnExpressions<?> toReturn = new ColumnExpressions<>(subreader);
         int baseOffset = ((TupleRowReader<?>)base.reader).getColumnForIndex(idx);
         for (int n = 0; n < subreader.getNumColumns(); n++)
            toReturn.columns.add(base.columns.get(n + baseOffset));
         return toReturn;
      }
      else if (sig.equals(TransformationClassAnalyzer.integerIntValue)
            || sig.equals(TransformationClassAnalyzer.doubleDoubleValue))
      {
         ColumnExpressions<?> base = val.base.visit(this, in);
         return base;
      }
//      else if (entityInfo.dbSetMethods.contains(sig))
View Full Code Here

         return super.virtualMethodCallValue(val, in);
   }

   @Override public ColumnExpressions<?> staticMethodCallValue(MethodCallValue.StaticMethodCallValue val, Void in) throws TypedValueVisitorException
   {
      MethodSignature sig = val.getSignature();
      if (sig.equals(TransformationClassAnalyzer.integerValueOf)
            || sig.equals(TransformationClassAnalyzer.doubleValueOf))
      {
         // Integer.valueOf() to be like a cast and assume it's correct
         ColumnExpressions<?> base = val.args.get(0).visit(this, in);
         return base;
      }
View Full Code Here

         String recordClassName = org.objectweb.asm.Type.getInternalName(table.getRecordType());
         for (Field<?> field: table.fields())
         {
            String name = field.getName();
            String getterName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
            MethodSignature methodSig = new MethodSignature(
                  recordClassName,
                  getterName,
                  org.objectweb.asm.Type.getMethodDescriptor(org.objectweb.asm.Type.getType(field.getType())));
            fieldMethods.put(methodSig, field);
         }
View Full Code Here

      }
      final List<MethodSignature> transformConstructorsCalled = new ArrayList<MethodSignature>();
      final DBSetSourceChecker checkDBSets = new DBSetSourceChecker(entityInfo);
      final Set<TypedValue> unresolvedDBSets = new HashSet<TypedValue>();
      ConditionRecorder pathConditions = new ConditionRecorder();
      BasicSymbolicInterpreter interpreter = new SymbolicInterpreterWithFieldAccess(Opcodes.ASM5);
      FrameWithHelpers frame = new FrameWithHelpers(cl, m, interpreter);
      interpreter.setFrameForAliasingFixups(frame);
      interpreter.setBranchHandler(pathConditions);
      interpreter.setMethodChecker(new BasicSymbolicInterpreter.MethodChecker() {
            public boolean isStaticMethodSafe(MethodSignature m)
               { return safeStaticMethods.contains(m); }
            public boolean isMethodSafe(MethodSignature m, TypedValue base, List<TypedValue> args)
               {
                  if (m.name.equals("<init>") && otherTransformClasses.contains(m.owner))
View Full Code Here

            else
               conditions.add(ifTrueValue.inverseValue());
         }
      }
      ConditionRecorder pathConditions = new ConditionRecorder();
      BasicSymbolicInterpreter interpreter = new SymbolicInterpreterWithFieldAccess(Opcodes.ASM5);
      FrameWithHelpers frame = new FrameWithHelpers(cl, m, interpreter);
      interpreter.setFrameForAliasingFixups(frame);
      interpreter.setBranchHandler(pathConditions);
      interpreter.setMethodChecker(methodChecker);
     
      for (PathInstruction instruction: path)
      {
         // Skip "fake" instructions like Frame, LineNumber, and Label
         if (instruction.node.getOpcode() < 0) continue;
View Full Code Here

            SQLFragment newWhere = new SQLFragment();
            if (analysis.paths.size() > 1)
            {
               for (PathAnalysis path: analysis.paths)
               {
                  TypedValue pathReturn = path.getSimplifiedIsTrueReturnValue();
                  if (pathReturn instanceof ConstantValue.IntegerConstant
                        && ((ConstantValue.IntegerConstant)pathReturn).val == 0)
                     continue;
                  SQLFragment pathWhere = new SQLFragment();
                  if (pathReturn instanceof ConstantValue.IntegerConstant
View Full Code Here

         if (instruction.isBranch)
            pathConditions.isBranchTaken = instruction.isBranchTaken;
         frame.execute(instruction.node, interpreter);
      }
     
      TypedValue returnValue = interpreter.returnValue;
      List<TypedValue.ComparisonValue> conditions = pathConditions.conditions;
     
      return new PathAnalysis(returnValue, conditions, transformConstructorsCalled, unresolvedDBSets);
   }
View Full Code Here

public class PathAnalysisSimplifier
{
   public static TypedValue simplify(TypedValue value, Map<MethodSignature, TypedValue.ComparisonValue.ComparisonOp> comparisonMethods)
   {
      TypedValue simplifiedBooleanReturnValue = value
            .visit(new TypedValueRewriterWalker<Object, RuntimeException>(new SymbExSimplifier<Object>(comparisonMethods)), null);
      simplifiedBooleanReturnValue = simplifiedBooleanReturnValue.visit(new SymbExBooleanRewriter(), false);
      return simplifiedBooleanReturnValue;
//      return value.visit(new TypedValueRewriterWalker<Object, RuntimeException>(new SymbExSimplifier<Object>(comparisonMethods)), null);
   }
View Full Code Here

//      }
//      return isTrueReturnValue;
//   }
   public static TypedValue simplifyBoolean(TypedValue value, Map<MethodSignature, TypedValue.ComparisonValue.ComparisonOp> comparisonMethods)
   {
      TypedValue simplifiedBooleanReturnValue = value
            .visit(new TypedValueRewriterWalker<Object, RuntimeException>(new SymbExSimplifier<Object>(comparisonMethods)), null);
      simplifiedBooleanReturnValue = simplifiedBooleanReturnValue.visit(new SymbExBooleanRewriter(), true);
      return simplifiedBooleanReturnValue;
   }
View Full Code Here

TOP

Related Classes of ch.epfl.labos.iu.orm.queryll2.path.PathAnalysisMethodChecker

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.