コード例 #1
0
 /**
  * Constructor. Creates an empty frame.
  *
  * @param pDeclaration Function for which the frame is created
  *     <p>TODO: [PARAMETERS] Create objects for function parameters
  */
 public CLangStackFrame(CFunctionDeclaration pDeclaration, MachineModel pMachineModel) {
   stack_function = pDeclaration;
   CType returnType = pDeclaration.getType().getReturnType().getCanonicalType();
   if (returnType instanceof CVoidType) {
     // use a plain int as return type for void functions
     returnValueObject = null;
   } else {
     int return_value_size = pMachineModel.getSizeof(returnType);
     returnValueObject = new SMGRegion(return_value_size, CLangStackFrame.RETVAL_LABEL);
   }
 }
コード例 #2
0
  /**
   * Adds a SMG object pObj to a stack frame, representing variable pVariableName
   *
   * <p>Throws {@link IllegalArgumentException} when some object is already present with the name
   * {@link pVariableName}
   *
   * @param pVariableName A name of the variable
   * @param pObject An object to put into the stack frame
   */
  public void addStackVariable(String pVariableName, SMGRegion pObject) {
    if (stack_variables.containsKey(pVariableName)) {
      throw new IllegalArgumentException(
          "Stack frame for function '"
              + stack_function.toASTString()
              + "' already contains a variable '"
              + pVariableName
              + "'");
    }

    stack_variables.put(pVariableName, pObject);
  }
コード例 #3
0
  /**
   * Getter for obtaining an object corresponding to a variable name
   *
   * <p>Throws {@link NoSuchElementException} when passed a name not present
   *
   * @param pName Variable name
   * @return SMG object corresponding to pName in the frame
   */
  public SMGRegion getVariable(String pName) {
    SMGRegion to_return = stack_variables.get(pName);

    if (to_return == null) {
      throw new NoSuchElementException(
          "No variable with name '"
              + pName
              + "' in stack frame for function '"
              + stack_function.toASTString()
              + "'");
    }

    return to_return;
  }