Examples of Pair


Examples of soot.toolkits.scalar.Pair

        }
    }
    final public void caseNewMultiArrayExpr( NewMultiArrayExpr nmae ) {
        ArrayType type = (ArrayType) nmae.getType();
        AllocNode prevAn = pag.makeAllocNode(
            new Pair( nmae, new Integer( type.numDimensions ) ), type, method );
        VarNode prevVn = pag.makeLocalVarNode( prevAn, prevAn.getType(), method );
        mpag.addInternalEdge( prevAn, prevVn );
        setResult( prevAn );
        while( true ) {
            Type t = type.getElementType();
            if( !( t instanceof ArrayType ) ) break;
            type = (ArrayType) t;
            AllocNode an = pag.makeAllocNode(
                new Pair( nmae, new Integer( type.numDimensions ) ), type, method );
            VarNode vn = pag.makeLocalVarNode( an, an.getType(), method );
            mpag.addInternalEdge( an, vn );
            mpag.addInternalEdge( vn, pag.makeFieldRefNode( prevVn, ArrayElement.v() ) );
            prevAn = an;
            prevVn = vn;
View Full Code Here

Examples of soot.toolkits.scalar.Pair

                Node thiz = tgtmpag.nodeFactory().caseThis();
                thiz = tgtmpag.parameterize( thiz, e.tgtCtxt() );
                thiz = thiz.getReplacement();

                addEdge( parm, thiz );
                callAssigns.put(ie, new Pair(parm, thiz));
                callToMethod.put(ie, srcmpag.getMethod());

                if( e.srcUnit() instanceof AssignStmt ) {
                    AssignStmt as = (AssignStmt) e.srcUnit();

                    Node ret = tgtmpag.nodeFactory().caseRet();
                    ret = tgtmpag.parameterize( ret, e.tgtCtxt() );
                    ret = ret.getReplacement();

                    Node lhs = srcmpag.nodeFactory().getNode(as.getLeftOp());
                    lhs = srcmpag.parameterize( lhs, e.srcCtxt() );
                    lhs = lhs.getReplacement();

                    addEdge( ret, lhs );
                    callAssigns.put(ie, new Pair(ret, lhs));
                    callToMethod.put(ie, srcmpag.getMethod());
                }
            } else if( e.kind() == Kind.FINALIZE ) {
                Node srcThis = srcmpag.nodeFactory().caseThis();
                srcThis = srcmpag.parameterize( srcThis, e.srcCtxt() );
                srcThis = srcThis.getReplacement();

                Node tgtThis = tgtmpag.nodeFactory().caseThis();
                tgtThis = tgtmpag.parameterize( tgtThis, e.tgtCtxt() );
                tgtThis = tgtThis.getReplacement();

                addEdge( srcThis, tgtThis );
            } else if( e.kind() == Kind.NEWINSTANCE ) {
                Stmt s = (Stmt) e.srcUnit();
                InstanceInvokeExpr iie = (InstanceInvokeExpr) s.getInvokeExpr();

                Node cls = srcmpag.nodeFactory().getNode( iie.getBase() );
                cls = srcmpag.parameterize( cls, e.srcCtxt() );
                cls = cls.getReplacement();
                Node newObject = nodeFactory.caseNewInstance( (VarNode) cls );

                Node initThis = tgtmpag.nodeFactory().caseThis();
                initThis = tgtmpag.parameterize( initThis, e.tgtCtxt() );
                initThis = initThis.getReplacement();

                addEdge( newObject, initThis );
                if (s instanceof AssignStmt) {
                    AssignStmt as = (AssignStmt)s;
                    Node asLHS = srcmpag.nodeFactory().getNode(as.getLeftOp());
                    asLHS = srcmpag.parameterize( asLHS, e.srcCtxt());
                    asLHS = asLHS.getReplacement();
                    addEdge( newObject, asLHS);
                }
                callAssigns.put(s.getInvokeExpr(), new Pair(newObject, initThis));
                callToMethod.put(s.getInvokeExpr(), srcmpag.getMethod());
            } else if( e.kind() == Kind.REFL_INVOKE ) {
              // Flow (1) from first parameter of invoke(..) invocation
                // to this of target, (2) from the contents of the second (array) parameter
              // to all parameters of the target, and (3)  from return of target to the
                // return of invoke(..)
             
              //(1)
                InvokeExpr ie = e.srcStmt().getInvokeExpr();

                Value arg0 = ie.getArg(0);
                //if "null" is passed in, omit the edge
                if(arg0!=NullConstant.v()) {
          Node parm0 = srcmpag.nodeFactory().getNode( arg0 );
                  parm0 = srcmpag.parameterize( parm0, e.srcCtxt() );
                  parm0 = parm0.getReplacement();
 
                  Node thiz = tgtmpag.nodeFactory().caseThis();
                  thiz = tgtmpag.parameterize( thiz, e.tgtCtxt() );
                  thiz = thiz.getReplacement();
 
                  addEdge( parm0, thiz );
                  callAssigns.put(ie, new Pair(parm0, thiz));
                  callToMethod.put(ie, srcmpag.getMethod());
                }

              //(2)
                Value arg1 = ie.getArg(1);
                SootMethod tgt = e.getTgt().method();
                //if "null" is passed in, or target has no parameters, omit the edge
                if(arg1!=NullConstant.v() && tgt.getParameterCount()>0) {
          Node parm1 = srcmpag.nodeFactory().getNode( arg1 );
                  parm1 = srcmpag.parameterize( parm1, e.srcCtxt() );
                  parm1 = parm1.getReplacement();
                  FieldRefNode parm1contents = makeFieldRefNode( (VarNode) parm1, ArrayElement.v() );
                 
                  for(int i=0;i<tgt.getParameterCount(); i++) {
                    //if no reference type, create no edge
                    if(!(tgt.getParameterType(i) instanceof RefLikeType)) continue;
                   
                      Node tgtParmI = tgtmpag.nodeFactory().caseParm( i );
                      tgtParmI = tgtmpag.parameterize( tgtParmI, e.tgtCtxt() );
                      tgtParmI = tgtParmI.getReplacement();
 
                      addEdge( parm1contents, tgtParmI );
                      callAssigns.put(ie, new Pair(parm1contents, tgtParmI));
                  }
                }

                //(3)
                //only create return edge if we are actually assigning the return value and
                //the return type of the callee is actually a reference type
                if( e.srcUnit() instanceof AssignStmt && (tgt.getReturnType() instanceof RefLikeType)) {
                    AssignStmt as = (AssignStmt) e.srcUnit();

                    Node ret = tgtmpag.nodeFactory().caseRet();
                    ret = tgtmpag.parameterize( ret, e.tgtCtxt() );
                    ret = ret.getReplacement();

                    Node lhs = srcmpag.nodeFactory().getNode(as.getLeftOp());
                    lhs = srcmpag.parameterize( lhs, e.srcCtxt() );
                    lhs = lhs.getReplacement();

                    addEdge( ret, lhs );
                    callAssigns.put(ie, new Pair(ret, lhs));
                }
            } else if( e.kind() == Kind.REFL_CLASS_NEWINSTANCE || e.kind() == Kind.REFL_CONSTR_NEWINSTANCE) {
              // (1) create a fresh node for the new object
              // (2) create edge from this object to "this" of the constructor
              // (3) if this is a call to Constructor.newInstance and not Class.newInstance,
              //     create edges passing the contents of the arguments array of the call
              //     to all possible parameters of the target
              // (4) if we are inside an assign statement,
              //     assign the fresh object from (1) to the LHS of the assign statement
             
                Stmt s = (Stmt) e.srcUnit();
                InstanceInvokeExpr iie = (InstanceInvokeExpr) s.getInvokeExpr();

                //(1)
                Node cls = srcmpag.nodeFactory().getNode( iie.getBase() );
                cls = srcmpag.parameterize( cls, e.srcCtxt() );
                cls = cls.getReplacement();
                if( cls instanceof ContextVarNode ) cls = findLocalVarNode( ((VarNode)cls).getVariable() );
               
                VarNode newObject = makeGlobalVarNode( cls, RefType.v( "java.lang.Object" ) );
                SootClass tgtClass = e.getTgt().method().getDeclaringClass();
        RefType tgtType = tgtClass.getType();               
                AllocNode site = makeAllocNode( new Pair(cls, tgtClass), tgtType, null );
                addEdge( site, newObject );

                //(2)
                Node initThis = tgtmpag.nodeFactory().caseThis();
                initThis = tgtmpag.parameterize( initThis, e.tgtCtxt() );
                initThis = initThis.getReplacement();
                addEdge( newObject, initThis );
               
                //(3)
                if(e.kind() == Kind.REFL_CONSTR_NEWINSTANCE) {
                  Value arg = iie.getArg(0);
                  SootMethod tgt = e.getTgt().method();
                  //if "null" is passed in, or target has no parameters, omit the edge
                  if(arg!=NullConstant.v() && tgt.getParameterCount()>0) {
            Node parm0 = srcmpag.nodeFactory().getNode( arg );
                    parm0 = srcmpag.parameterize( parm0, e.srcCtxt() );
                    parm0 = parm0.getReplacement();
                    FieldRefNode parm1contents = makeFieldRefNode( (VarNode) parm0, ArrayElement.v() );
                   
                    for(int i=0;i<tgt.getParameterCount(); i++) {
                      //if no reference type, create no edge
                      if(!(tgt.getParameterType(i) instanceof RefLikeType)) continue;
                     
                        Node tgtParmI = tgtmpag.nodeFactory().caseParm( i );
                        tgtParmI = tgtmpag.parameterize( tgtParmI, e.tgtCtxt() );
                        tgtParmI = tgtParmI.getReplacement();
   
                        addEdge( parm1contents, tgtParmI );
                        callAssigns.put(iie, new Pair(parm1contents, tgtParmI));
                    }
                  }
                }
               
                //(4)
                if (s instanceof AssignStmt) {
                    AssignStmt as = (AssignStmt)s;
                    Node asLHS = srcmpag.nodeFactory().getNode(as.getLeftOp());
                    asLHS = srcmpag.parameterize( asLHS, e.srcCtxt());
                    asLHS = asLHS.getReplacement();
                    addEdge( newObject, asLHS);
                }
                callAssigns.put(s.getInvokeExpr(), new Pair(newObject, initThis));
                callToMethod.put(s.getInvokeExpr(), srcmpag.getMethod());
            } else {
                throw new RuntimeException( "Unhandled edge "+e );
            }
        }
View Full Code Here

Examples of soot.toolkits.scalar.Pair

            Node parm = tgtnf.caseParm( i );
            parm = tgtmpag.parameterize( parm, tgtContext );
            parm = parm.getReplacement();

            addEdge( argNode, parm );
            callAssigns.put(ie, new Pair(argNode, parm));
            callToMethod.put(ie, srcmpag.getMethod());
           
        }
        if( ie instanceof InstanceInvokeExpr ) {
            InstanceInvokeExpr iie = (InstanceInvokeExpr) ie;

            Node baseNode = srcnf.getNode( iie.getBase() );
            baseNode = srcmpag.parameterize( baseNode, srcContext );
            baseNode = baseNode.getReplacement();

            Node thisRef = tgtnf.caseThis();
            thisRef = tgtmpag.parameterize( thisRef, tgtContext );
            thisRef = thisRef.getReplacement();
            addEdge( baseNode, thisRef );
            callAssigns.put(ie, new Pair(baseNode, thisRef));
            callToMethod.put(ie, srcmpag.getMethod());
            if (virtualCall && !virtualCallsToReceivers.containsKey(ie)) {
                virtualCallsToReceivers.put(ie, baseNode);
            }
        }
        if( s instanceof AssignStmt ) {
            Value dest = ( (AssignStmt) s ).getLeftOp();
            if( dest.getType() instanceof RefLikeType && !(dest instanceof NullConstant) ) {

                Node destNode = srcnf.getNode( dest );
                destNode = srcmpag.parameterize( destNode, srcContext );
                destNode = destNode.getReplacement();

                Node retNode = tgtnf.caseRet();
                retNode = tgtmpag.parameterize( retNode, tgtContext );
                retNode = retNode.getReplacement();

                addEdge( retNode, destNode );
                callAssigns.put(ie, new Pair(retNode, destNode));
                callToMethod.put(ie, srcmpag.getMethod());
            }
        }
    }
View Full Code Here

Examples of tools.dictionary.Pair

    for (int i=0; i<list.size(); ++i)
      if (list.get(i).key.equals(key)) {
        list.get(i).setValue(n);
        return ;
      }
    list.add(new Pair(key,n));
    //throw new Exception("Element with the given key not found");
  }
View Full Code Here

Examples of util.Pair

    }

    // 1. Add the near and conn predicates that are given as facts first:
    for (FaspConstant t1 : town) {
      for (FaspConstant t2 : town) {
        if (distances.containsKey(new Pair(t1, t2))) {
          varOrder.add(createRegLiteral("near", t1, t2).toString());
          varOrder.add(createRegLiteral("near", t2, t1).toString());
          varOrder.add(createRegLiteral("conn", t1, t2).toString());
          varOrder.add(createRegLiteral("conn", t2, t1).toString());
        }
View Full Code Here

Examples of voldemort.utils.Pair

                                                    RequestFormatType.ADMIN_PROTOCOL_BUFFERS);
                sands = streamingSocketPool.checkout(destination);
                DataOutputStream outputStream = sands.getOutputStream();
                DataInputStream inputStream = sands.getInputStream();

                nodeIdStoreToSocketRequest.put(new Pair(store, node.getId()), destination);
                nodeIdStoreToOutputStreamRequest.put(new Pair(store, node.getId()), outputStream);
                nodeIdStoreToInputStreamRequest.put(new Pair(store, node.getId()), inputStream);
                nodeIdStoreToSocketAndStreams.put(new Pair(store, node.getId()), sands);
                nodeIdStoreInitialized.put(new Pair(store, node.getId()), false);

                remoteStoreDefs = adminClient.metadataMgmtOps.getRemoteStoreDefList(node.getId())
                                                             .getValue();

            } catch(Exception e) {
View Full Code Here

Examples of voldemort.utils.Pair

                updateRequest = VAdminProto.UpdatePartitionEntriesRequest.newBuilder()
                                                                         .setStore(storeName)
                                                                         .setPartitionEntry(partitionEntry);
            }

            DataOutputStream outputStream = nodeIdStoreToOutputStreamRequest.get(new Pair(storeName,
                                                                                          node.getId()));
            try {
                if(nodeIdStoreInitialized.get(new Pair(storeName, node.getId()))) {
                    ProtoUtils.writeMessage(outputStream, updateRequest.build());
                } else {
                    ProtoUtils.writeMessage(outputStream,
                                            VAdminProto.VoldemortAdminRequest.newBuilder()
                                                                             .setType(VAdminProto.AdminRequestType.UPDATE_PARTITION_ENTRIES)
                                                                             .setUpdatePartitionEntries(updateRequest)
                                                                             .build());
                    outputStream.flush();
                    nodeIdStoreInitialized.put(new Pair(storeName, node.getId()), true);

                }

            } catch(IOException e) {
                e.printStackTrace();
View Full Code Here

Examples of winterwell.utils.containers.Pair

      ResultSetMetaData meta = rs.getMetaData();
      List<Pair<String>> list = new ArrayList();
      for (int i = 0; i < meta.getColumnCount(); i++) {
        String name = meta.getColumnName(i + 1);
        String type = meta.getColumnTypeName(i + 1);
        Pair p = new Pair(name, type);
        list.add(p);
      }
      return list;
    } catch (SQLException e) {
      throw Utils.runtime(e);
View Full Code Here

Examples of wycc.util.Pair

      Pair<Expr, Environment> p = propagateCondition(uop.mhs, !sign,
          environment, context);
      uop.mhs = p.first();
      checkIsSubtype(Type.T_BOOL, uop.mhs, context);
      uop.type = Nominal.T_BOOL;
      return new Pair(uop, p.second());
    } else {
      // Nothing else other than logical not is valid at this point.
      syntaxError(errorMessage(INVALID_BOOLEAN_EXPRESSION), context, expr);
      return null; // deadcode
    }
View Full Code Here

Examples of xbird.util.struct.Pair

    @SuppressWarnings("unchecked")
    protected final Pair<AtomicType[], AtomicType>[] signatures() {
        final Pair<AtomicType[], AtomicType>[] s = new Pair[] {
                // op:numeric-mod(xs:integer, xs:integer) as xs:integer
                new Pair(new AtomicType[] { IntegerType.INTEGER, IntegerType.INTEGER }, IntegerType.INTEGER),
                // op:numeric-mod(xs:decimal, xs:decimal) as xs:decimal
                new Pair(new AtomicType[] { DecimalType.DECIMAL, DecimalType.DECIMAL }, DecimalType.DECIMAL),
                // op:numeric-mod(xs:float, xs:float) as xs:float
                new Pair(new AtomicType[] { FloatType.FLOAT, FloatType.FLOAT }, FloatType.FLOAT),
                // workaround
                new Pair(new AtomicType[] { DecimalType.DECIMAL, FloatType.FLOAT }, FloatType.FLOAT),
                new Pair(new AtomicType[] { FloatType.FLOAT, DecimalType.DECIMAL }, FloatType.FLOAT),
                // op:numeric-mod(xs:double, xs:double) as xs:double
                new Pair(new AtomicType[] { DoubleType.DOUBLE, DoubleType.DOUBLE }, DoubleType.DOUBLE),
                // workaround
                new Pair(new AtomicType[] { NumericType.getInstance(), NumericType.getInstance() }, DoubleType.DOUBLE),
                new Pair(new AtomicType[] { UntypedAtomicType.UNTYPED_ATOMIC,
                        NumericType.getInstance() }, DoubleType.DOUBLE),
                new Pair(new AtomicType[] { NumericType.getInstance(),
                        UntypedAtomicType.UNTYPED_ATOMIC }, DoubleType.DOUBLE),
                new Pair(new AtomicType[] { UntypedAtomicType.UNTYPED_ATOMIC,
                        UntypedAtomicType.UNTYPED_ATOMIC }, DoubleType.DOUBLE) };
        return s;
    }
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.