Package ch.epfl.labos.iu.orm.queryll2.symbolic.BasicSymbolicInterpreter

Examples of ch.epfl.labos.iu.orm.queryll2.symbolic.BasicSymbolicInterpreter.OperationSideEffect


      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))
                  {
                     transformConstructorsCalled.add(m);
                     return true;
                  }
                  else if (entityInfo.dbSetMethods.contains(m))
                  {
                     Type[] argTypes = Type.getArgumentTypes(m.desc);
                     try {
                        base.visit(checkDBSets, unresolvedDBSets);
                        for (int n = 0; n < argTypes.length; n++)
                        {
                           Type t = argTypes[n];
                           if (t.getSort() != Type.OBJECT) continue;
                           if (!t.getInternalName().equals("Lch/epfl/labos/iu/orm/DBSet;")) continue;
                           args.get(n).visit(checkDBSets, unresolvedDBSets);
                        }
                     } catch (TypedValueVisitorException e)
                     {
                        return false;
                     }
                     return true;
                  }
                  else
                     return safeMethods.contains(m);
               }});
     
      for (PathInstruction instruction: path)
      {
         // Skip "fake" instructions like Frame, LineNumber, and Label
         if (instruction.node.getOpcode() < 0) continue;
        
         if (instruction.isBranch)
            pathConditions.isBranchTaken = instruction.isBranchTaken;
         frame.execute(instruction.node, interpreter);
      }
     
      TypedValue returnValue = interpreter.returnValue;
      List<TypedValue.ComparisonValue> conditions = pathConditions.conditions;
     
View Full Code Here


               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;
        
         if (instruction.isBranch)
            pathConditions.isBranchTaken = instruction.isBranchTaken;
         frame.execute(instruction.node, interpreter);
      }
     
      TypedValue returnValue = interpreter.returnValue;
      List<TypedValue.ComparisonValue> conditions = pathConditions.conditions;
     
View Full Code Here

         LambdaAnalysis lambda = null;
         if (val.args.size() > 0)
         {
            if (!(val.args.get(0) instanceof LambdaFactory))
               throw new TypedValueVisitorException("Expecting a lambda factory for aggregate method");
            LambdaFactory lambdaFactory = (LambdaFactory)val.args.get(0);
            try {
               lambda = LambdaAnalysis.analyzeMethod(config.metamodel, config.alternateClassLoader, config.isObjectEqualsSafe,
                     lambdaFactory.getLambdaMethod(), lambdaFactory.getCapturedArgs(), true);
            } catch (Exception e)
            {
               throw new TypedValueVisitorException("Could not analyze the lambda code", e);
            }
         }
View Full Code Here

         LambdaAnalysis lambda = null;
         if (val.args.size() > 0)
         {
            if (!(val.args.get(0) instanceof LambdaFactory))
               throw new TypedValueVisitorException("Expecting a lambda factory for aggregate method");
            LambdaFactory lambdaFactory = (LambdaFactory)val.args.get(0);
            try {
               lambda = LambdaAnalysis.analyzeMethod(config.metamodel, config.alternateClassLoader, config.isObjectEqualsSafe, lambdaFactory.getLambdaMethod(), lambdaFactory.getCapturedArgs(), true);
            } catch (Exception e)
            {
               throw new TypedValueVisitorException("Could not analyze the lambda code", e);
            }
         }
View Full Code Here

         if (numericPromotionPriority.get(toType) > numericPromotionPriority.get(fromType))
            return true;
      }
      else if (val instanceof MethodCallValue.VirtualMethodCallValue)
      {
         MethodCallValue methodCall = (MethodCallValue.VirtualMethodCallValue)val;
         MethodSignature sig = methodCall.getSignature();
         if (sig.equals(TransformationClassAnalyzer.newBigDecimalLong)
               || sig.equals(TransformationClassAnalyzer.newBigDecimalInt)
               || sig.equals(TransformationClassAnalyzer.newBigDecimalBigInteger))
         {
            return true;
         }
         else if (sig.equals(TransformationClassAnalyzer.bigDecimalDoubleValue)
               || sig.equals(TransformationClassAnalyzer.bigIntegerDoubleValue))
         {
            return true;
         }

      }
      else if (val instanceof MethodCallValue.StaticMethodCallValue)
      {
         MethodCallValue methodCall = (MethodCallValue.StaticMethodCallValue)val;
         MethodSignature sig = methodCall.getSignature();
         if (sig.equals(TransformationClassAnalyzer.bigIntegerValueOfLong))
         {
            return true;
         }
      }
View Full Code Here

            return skipWideningCast(methodCall.base);
         }
      }
      else if (val instanceof MethodCallValue.StaticMethodCallValue)
      {
         MethodCallValue methodCall = (MethodCallValue.StaticMethodCallValue)val;
         MethodSignature sig = methodCall.getSignature();
         if (sig.equals(TransformationClassAnalyzer.bigIntegerValueOfLong))
         {
            return skipWideningCast(methodCall.args.get(0));
         }
      }
View Full Code Here

      return sql;
   }

   @Override public SQLColumnValues staticMethodCallValue(MethodCallValue.StaticMethodCallValue val, T in) throws TypedValueVisitorException
   {
      MethodSignature sig = val.getSignature();
      if (entityInfo.passThroughStaticMethods.contains(sig))
      {
         SQLColumnValues base = val.args.get(0).visit(this, in);
         return base;
      }
View Full Code Here

         return super.staticMethodCallValue(val, in);
   }
  
   @Override public SQLColumnValues virtualMethodCallValue(MethodCallValue.VirtualMethodCallValue val, T in) throws TypedValueVisitorException
   {
      MethodSignature sig = val.getSignature();
      if (TransformationClassAnalyzer.stringEquals.equals(sig))
      {
         assert(false); // This should never happen because the simplifier should eliminate these
         SQLColumnValues sql = new SQLColumnValues(new SQLReader.BooleanSQLReader());
         sql.add("(");
         sql.add(val.base.visit(this, in));
         sql.add(")");
         sql.add(" = ");
         sql.add("(");
         sql.add(val.args.get(0).visit(this, in));
         sql.add(")");
         return sql;
      }
      else if (TransformationClassAnalyzer.newPair.equals(sig)
            || TransformationClassAnalyzer.newTuple3.equals(sig)
            || TransformationClassAnalyzer.newTuple4.equals(sig)
            || TransformationClassAnalyzer.newTuple5.equals(sig)
            || TransformationClassAnalyzer.newTuple8.equals(sig))
      {
         SQLColumnValues [] vals = new SQLColumnValues[val.args.size()];
         for (int n = 0; n < vals.length; n++)
            vals[n] = val.args.get(n).visit(this, in);
         SQLReader [] valReaders = new SQLReader[vals.length];
         for (int n = 0; n < vals.length; n++)
            valReaders[n] = vals[n].reader;
        
         SQLColumnValues sql = new SQLColumnValues(SQLReader.TupleSQLReader.createReaderForTuple(sig.owner, valReaders));
         int offset = 0;
         for (int n = 0; n < vals.length; n++)
         {
            for (int col = 0; col < vals[n].columns.length; col++)
            {
               sql.columns[offset] = vals[n].columns[col];
               offset++;
            }
         }
         return sql;
      }
      else if (entityInfo.fieldMethods.containsKey(sig))
      {
         String fieldName = entityInfo.fieldMethods.get(sig);
         SQLColumnValues base = val.base.visit(this, in);
         SQLColumnValues sql = new SQLColumnValues(base.reader.getReaderForField(fieldName));
         for (int n = 0; n < sql.reader.getNumColumns(); n++)
            sql.columns[n] = base.columns[base.reader.getColumnForField(fieldName) + n];
         return sql;
      }
      else if (entityInfo.passThroughMethods.contains(sig))
      {
         SQLColumnValues base = val.base.visit(this, in);
         return base;
      }
      else if (entityInfo.dbSetMethods.contains(sig))
      {
         if (lambdaContext.joins == null)
            throw new TypedValueVisitorException("Need a join handler here for subqueries just in case there's an embedded navigational query: " + val);
         // TODO: Handle checking out the constructor and verifying how
         // parameters pass through the constructor
         SQLQuery subQuery = val.base.visit(subQueryHandler, in);
         if (sig.equals(TransformationClassAnalyzer.dbsetSumInt)
               || sig.equals(TransformationClassAnalyzer.dbsetMaxInt))
         {
            // TODO: do subqueries need to be copied before being passed in here?
            SQLQuery<Integer> newQuery = null;
            if (sig.equals(TransformationClassAnalyzer.dbsetSumInt))
               newQuery = queryMethodHandler.sumInt(subQuery, val.args.get(0), lambdaContext.joins.getEntityManager());
            else if (sig.equals(TransformationClassAnalyzer.dbsetMaxInt))
               newQuery = queryMethodHandler.maxInt(subQuery, val.args.get(0), lambdaContext.joins.getEntityManager());
            if (newQuery == null) throw new TypedValueVisitorException("Could not decode a subquery " + val);
            if (newQuery instanceof SQLQuery.InternalGroup)
            {
               SQLQuery.InternalGroup<Integer> agg = (SQLQuery.InternalGroup<Integer>)newQuery;
View Full Code Here

   public void registerORMEntity(ORMEntity entity)
   {
      entities.add(entity);
      for (ORMField field: entity.fields)
      {
         MethodSignature m = makeFieldMethodSignature(entity.entityPackage, entity.name,
                                                 field.name,
                                                 ormTypeStringToType(field.type));
         sideEffectFreeMethods.add(m);
         fieldMethods.put(m, field.name);
      }
      MethodSignature getAllEntities =
         makeMethodSignature(entity.entityPackage,
                             "EntityManager",
                             "all" + capitalizeFirstLetter(entity.name),
                             Type.getObjectType("ch/epfl/labos/iu/orm/DBSet"));
      sideEffectFreeMethods.add(getAllEntities);
View Full Code Here

   {
      ORMEntity fromEntity = entityFor(fromEntityName);
      ORMEntity toEntity = entityFor(toEntityName);
      String fromInternalName = makeInternalName(fromEntity.entityPackage, fromEntity.name);
      String toInternalName = makeInternalName(toEntity.entityPackage, toEntity.name);
      MethodSignature from1Signature =
         makeMethodSignature(entityPackage,
                             fromEntity.name,
                             "get" + capitalizeFirstLetter(fromField),
                             Type.getObjectType(toInternalName));
      MethodSignature to1Signature =
         makeMethodSignature(entityPackage,
                             toEntity.name,
                             "get" + capitalizeFirstLetter(toField),
                             Type.getObjectType(fromInternalName));
View Full Code Here

TOP

Related Classes of ch.epfl.labos.iu.orm.queryll2.symbolic.BasicSymbolicInterpreter.OperationSideEffect

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.