Package ghidra.app.util.bin.format.golang.rtti.types

# Class GoType

java.lang.Object
ghidra.app.util.bin.format.golang.rtti.types.GoType

All Implemented Interfaces:
  `StructureMarkup<GoType>`

Direct Known Subclasses:
  `GoArrayType`, `GoChanType`, `GoFuncType`, `GoInterfaceType`, `GoMapType`, `GoPlainType`, `GoPointerType`, `GoSliceType`, `GoStructType`

public abstract class GoType extends Object implements StructureMarkup<GoType>
Common abstract base class for GoType classes

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected StructureContext<GoType>`
  `context`
  `protected GoRttiMapper`
  `programContext`
  `protected GoBaseType`
  `typ`
  `protected GoUncommonType`
  `uncommonType`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GoType()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `additionalMarkup(MarkupSession session)`
  Called to allow the implementor to perform custom markup of itself.
  `boolean`
  `discoverGoTypes(Set<Long> discoveredTypes)`
  Iterates this type, and any types this type refers to, while registering the types with the `GoRttiMapper` context.
  `protected GoBaseType`
  `getBaseType()`
  `String`
  `getDebugId()`
  `long`
  `getEndOfTypeInfo()`
  Returns the location of where this type object, and any known associated optional structures ends.
  `protected String`
  `getImplementsInterfaceString()`
  `List<GoMethod.GoMethodInfo>`
  `getMethodInfoList()`
  Returns a list of all methods defined on this type.
  `protected String`
  `getMethodListString()`
  `FunctionDefinition`
  `getMethodSignature(GoMethod method, boolean allowPartial)`
  Return a funcdef signature for a method that is attached to this type.
  `String`
  `getName()`
  Returns the name of this type.
  `String`
  `getNameWithPackageString()`
  `protected long`
  `getOffsetEndOfFullType()`
  `String`
  `getPackagePathString()`
  Returns the package path of this type.
  `static Class<? extends GoType>`
  `getSpecializedTypeClass(GoRttiMapper programContext, long offset)`
  Returns the specific GoType derived class that will handle the go type located at the specified offset.
  `StructureContext<GoType>`
  `getStructureContext()`
  `String`
  `getStructureName()`
  Returns the name of the instance, typically retrieved from data found inside the instance.
  `String`
  `getStructureNamespace()`
  Returns the namespace that any labels should be placed in.
  `protected String`
  `getTypeDeclString()`
  Returns a descriptive string that defines the declaration of this type.
  `long`
  `getTypeOffset()`
  Returns the starting offset of this type, used as an identifier.
  `GoUncommonType`
  `getUncommonType()`
  `String`
  `getUniqueTypename()`
  Returns the name of this type, after being uniqified against all other types defined in the program.
  `DataType`
  `recoverDataType()`
  Converts a golang RTTI type structure into a Ghidra data type.
  `String`
  `toString()`

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

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

  ### Methods inherited from interface ghidra.app.util.bin.format.golang.structmapping.StructureMarkup

  `getExternalInstancesToMarkup, getStructureLabel`

- ## Field Details

  - ### programContext

    protected GoRttiMapper programContext

  - ### context

    protected StructureContext<GoType> context

  - ### typ

    protected GoBaseType typ

  - ### uncommonType

    protected GoUncommonType uncommonType

- ## Constructor Details

  - ### GoType

    public GoType()

- ## Method Details

  - ### getSpecializedTypeClass

    public static Class<? extends GoType> getSpecializedTypeClass(GoRttiMapper programContext, long offset) throws IOException
    Returns the specific GoType derived class that will handle the go type located at the specified offset.
    Parameters:
      `programContext` - program-level mapper context
      `offset` - absolute location of go type struct
    Returns:
      GoType class that will best handle the type struct
    Throws:
      `IOException` - if error reading

  - ### getBaseType

    protected GoBaseType getBaseType()

  - ### getTypeOffset

    public long getTypeOffset()
    Returns the starting offset of this type, used as an identifier.
    Returns:
      starting offset of this type

  - ### getName

    public String getName()
    Returns the name of this type.
    Returns:
      name of this type

  - ### getNameWithPackageString

    public String getNameWithPackageString()

  - ### getPackagePathString

    public String getPackagePathString()
    Returns the package path of this type.
    Returns:
      package path of this type

  - ### getDebugId

    public String getDebugId()

  - ### getOffsetEndOfFullType

    protected long getOffsetEndOfFullType()

  - ### getEndOfTypeInfo

    public long getEndOfTypeInfo() throws IOException
    Returns the location of where this type object, and any known associated optional structures ends.
    Returns:
      index location of end of this type object
    Throws:
      `IOException` - if error reading

  - ### getUncommonType

    public GoUncommonType getUncommonType() throws IOException
    Throws:
      `IOException`

  - ### getMethodInfoList

    public List<GoMethod.GoMethodInfo> getMethodInfoList() throws IOException
    Returns a list of all methods defined on this type. Methods that specify both a "tfn" address as well as a "ifn" address will be represented twice.
    Returns:
      list of MethodInfo's
    Throws:
      `IOException` - if error reading

  - ### getStructureContext

    public StructureContext<GoType> getStructureContext()
    Specified by:
      `getStructureContext` in interface `StructureMarkup<GoType>`

  - ### getStructureName

    public String getStructureName() throws IOException
    Description copied from interface: `StructureMarkup`
    Returns the name of the instance, typically retrieved from data found inside the instance.
    Specified by:
      `getStructureName` in interface `StructureMarkup<GoType>`
    Returns:
      string name, or null if this instance does not have a name
    Throws:
      `IOException` - if error getting name

  - ### getStructureNamespace

    public String getStructureNamespace() throws IOException
    Description copied from interface: `StructureMarkup`
    Returns the namespace that any labels should be placed in.
    Specified by:
      `getStructureNamespace` in interface `StructureMarkup<GoType>`
    Returns:
      name of namespace to place the label for this structure mapped type, or null
    Throws:
      `IOException` - if error generating namespace name

  - ### additionalMarkup

    public void additionalMarkup(MarkupSession session) throws IOException, CancelledException
    Description copied from interface: `StructureMarkup`
    Called to allow the implementor to perform custom markup of itself.
    Specified by:
      `additionalMarkup` in interface `StructureMarkup<GoType>`
    Parameters:
      `session` - state and methods to assist marking up the program
    Throws:
      `IOException` - if error during markup
      `CancelledException` - if cancelled

  - ### getImplementsInterfaceString

    protected String getImplementsInterfaceString()

  - ### getMethodListString

    protected String getMethodListString() throws IOException
    Throws:
      `IOException`

  - ### getMethodSignature

    public FunctionDefinition getMethodSignature(GoMethod method, boolean allowPartial) throws IOException
    Return a funcdef signature for a method that is attached to this type.
    Parameters:
      `method` - `GoMethod`
      `allowPartial` - boolean flag, if true, allow returning a partially defined signature when the method's funcdef type is not specified
    Returns:
      `FunctionDefinition` (that contains a receiver parameter), or null if the method's funcdef type was not specified and allowPartial was not true
    Throws:
      `IOException` - if error reading type info

  - ### getTypeDeclString

    protected String getTypeDeclString() throws IOException
    Returns a descriptive string that defines the declaration of this type.

    This method should be overloaded by more specific types.

    Returns:
      descriptive string
    Throws:
      `IOException` - if error reading data

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### getUniqueTypename

    public String getUniqueTypename()
    Returns the name of this type, after being uniqified against all other types defined in the program.

    See `GoRttiMapper.getUniqueGoTypename(GoType)`.

    Returns:
      name of this type

  - ### recoverDataType

    public DataType recoverDataType() throws IOException
    Converts a golang RTTI type structure into a Ghidra data type.
    Returns:
      `DataType` that represents the golang type
    Throws:
      `IOException` - if error getting name of the type

  - ### discoverGoTypes

    public boolean discoverGoTypes(Set<Long> discoveredTypes) throws IOException
    Iterates this type, and any types this type refers to, while registering the types with the `GoRttiMapper` context.

    This method should be overloaded by derived type classes to add any additional types referenced by the derived type.

    Parameters:
      `discoveredTypes` - set of already iterated types
    Returns:
      boolean boolean flag, if false the type has already been discovered, if true the type was encountered for the first time
    Throws:
      `IOException` - if error reading type info