Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2015 The Pennsylvania State University and the University of Wisconsin
   * Systems and Internet Infrastructure Security Laboratory
   *
   * Author: Damien Octeau
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package edu.psu.cse.siis.coal.field.transformers;
 
 import java.util.Set;
 
 
 import soot.Unit;
 import soot.Value;
Utility functions for field transformers.
 
 public class FieldTransformerUtils {
   private static Logger logger = LoggerFactory.getLogger(FieldTransformerUtils.class);

  
Returns field transformers that model the influence of a referenced COAL value.

Parameters:
stmt The statement where the COAL value composition occurs.
symbol A COAL symbol that is referenced by the statement.
field The name of the field that is referenced by the statement.
type The type of the field that is referenced by the statement.
solver A propagation solver.
operation A field operation to be performed with the reference value.
returnedTop An array whose first element indicates whether a TopFieldTransformer was returned.
Returns:
The resulting field transformers.
 
   public static Set<FieldTransformermakeTransformersFromReferencedValue(Unit stmtValue symbol,
       String fieldString typePropagationSolver solverString operationBoolean[] returnedTop) {
     BasePropagationValue referencedBaseValue = solver.resultAt(stmtsymbol);
     if (referencedBaseValue == null) {
       if (.isDebugEnabled()) {
         .debug("Returning top0");
       }
       returnedTop[0] = true;
       return Collections.singleton(ArgumentValueManager.v().getTopFieldTransformer(type));
     } else if (referencedBaseValue instanceof TopPropagationValue) {
       if (.isDebugEnabled()) {
         .debug("Returning top1");
       }
       returnedTop[0] = true;
       return Collections.singleton(ArgumentValueManager.v().getTopFieldTransformer(type));
     } else {
 
       PropagationValue referencedValue = (PropagationValuereferencedBaseValue;
       referencedValue.makeFinalValue(solver);
       Set<FieldValuefieldValues = referencedValue.getValuesForField(field);
       Set<FieldTransformerresult = new HashSet<>();
       for (FieldValue fieldValue : fieldValues) {
         if (fieldValue != null) {
           FieldTransformer fieldTransformer = IdentityFieldTransformer.v();
           Set<Objectvalues = fieldValue.getValues();
           if (values != null) {
             for (Object value : values) {
               fieldTransformer =
                   fieldTransformer.compose(FieldTransformerManager.v().makeFieldTransformer(
                       operationvalue));
             }
           }
           result.add(fieldTransformer.intern());
         } else {
           result.add(null);
         }
       }
       if (.isDebugEnabled()) {
         .debug("Returning " + result.toString());
       }
       returnedTop[0] = false;
       return result;
     }
   }
New to GrepCode? Check out our FAQ X