Package ghidra.program.model.pcode

# Class FunctionPrototype

java.lang.Object
ghidra.program.model.pcode.FunctionPrototype

public class FunctionPrototype extends Object
High-level prototype of a function based on Varnodes, describing the inputs and outputs of this function.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FunctionPrototype(FunctionSignature proto, CompilerSpec cspec, boolean voidimpliesdotdotdot)`
  Construct an internally backed prototype based on a FunctionSignature prototype
  `FunctionPrototype(LocalSymbolMap ls, Function func)`
  Construct a FunctionPrototype backed by a local symbolmap.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `decodePrototype(Decoder decoder, PcodeFactory pcodeFactory)`
  Decode the function prototype from a `<prototype>` element in the stream.
  `void`
  `encodePrototype(Encoder encoder, PcodeDataTypeManager dtmanage)`
  Encode this function prototype to a stream.
  `int`
  `getExtraPop()`
  `String`
  `getModelName()`
  `int`
  `getNumParams()`
  `HighSymbol`
  `getParam(int i)`
  `ParameterDefinition[]`
  `getParameterDefinitions()`
  `VariableStorage`
  `getReturnStorage()`
  `DataType`
  `getReturnType()`
  `boolean`
  `hasNoReturn()`
  `boolean`
  `hasThisPointer()`
  `boolean`
  `isBackedByLocalSymbolMap()`
  `boolean`
  `isConstructor()`
  `boolean`
  `isDestructor()`
  `boolean`
  `isInline()`
  `boolean`
  `isVarArg()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### FunctionPrototype

    public FunctionPrototype(LocalSymbolMap ls, Function func)
    Construct a FunctionPrototype backed by a local symbolmap. This is only a partial initialization. It is intended to be followed either by grabFromFunction() or readPrototypeXML()
    Parameters:
      `ls` - is the LocalSymbolMap backing the prototype
      `func` - is the function using the symbolmap

  - ### FunctionPrototype

    public FunctionPrototype(FunctionSignature proto, CompilerSpec cspec, boolean voidimpliesdotdotdot)
    Construct an internally backed prototype based on a FunctionSignature prototype
    Parameters:
      `proto` - is the FunctionSignature used to internally back input parameters
      `cspec` - is the compiler spec used to pick prototype model
      `voidimpliesdotdotdot` - set to true if a void prototype is interpreted as varargs

- ## Method Details

  - ### getNumParams

    public int getNumParams()
    Returns:
      the number of defined parameters for this function prototype

  - ### getParam

    public HighSymbol getParam(int i)
    Parameters:
      `i` - i'th parameter index
    Returns:
      the i'th HighParam to this function prototype or null if this prototype is not backed by a LocalSymbolMap

  - ### getParameterDefinitions

    public ParameterDefinition[] getParameterDefinitions()
    Returns:
      parameter definitions if prototype was produced from a FunctionSignature or null if backed by a LocalSymbolMap

  - ### isBackedByLocalSymbolMap

    public boolean isBackedByLocalSymbolMap()
    Returns:
      true if this prototype is backed by a LocalSymbolMap, or false if generated from a FunctionSignature.

  - ### getReturnType

    public DataType getReturnType()
    Returns:
      the return type for the function

  - ### getReturnStorage

    public VariableStorage getReturnStorage()
    Returns:
      the return storage for the function

  - ### getExtraPop

    public int getExtraPop()
    Returns:
      the number of extra bytes popped off by this functions return

  - ### isVarArg

    public boolean isVarArg()
    Returns:
      true if this function has variable arguments

  - ### isInline

    public boolean isInline()
    Returns:
      true if this function should be inlined by the decompile

  - ### hasNoReturn

    public boolean hasNoReturn()
    Returns:
      true if calls to this function do not return

  - ### hasThisPointer

    public boolean hasThisPointer()
    Returns:
      true if this function is a method taking a 'this' pointer as a parameter

  - ### isConstructor

    public boolean isConstructor()
    Returns:
      true if this function is an (object-oriented) constructor

  - ### isDestructor

    public boolean isDestructor()
    Returns:
      true if this function is an (object-oriented) destructor

  - ### getModelName

    public String getModelName()
    Returns:
      calling convention model name specific to the associated compiler spec

  - ### encodePrototype

    public void encodePrototype(Encoder encoder, PcodeDataTypeManager dtmanage) throws IOException
    Encode this function prototype to a stream.
    Parameters:
      `encoder` - is the stream encoder
      `dtmanage` - is the DataTypeManager for building type reference tags
    Throws:
      `IOException` - for errors in the underlying stream

  - ### decodePrototype

    public void decodePrototype(Decoder decoder, PcodeFactory pcodeFactory) throws DecoderException
    Decode the function prototype from a `<prototype>` element in the stream.
    Parameters:
      `decoder` - is the stream decoder
      `pcodeFactory` - is used to resolve data-type and address space references
    Throws:
      `DecoderException` - for invalid encodings