Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 1.56 KB

VoidTypeReference.md

File metadata and controls

40 lines (28 loc) · 1.56 KB

VoidTypeReference

[Transformation Source]

This type reference represents void. It is singleton, accessed via VoidTypeReference.Instance or VoidTypeReference.PointerInstance for void and void* respectively.

PointerInstance is really only provided for convienence. It's possible to manually create void* too.

This is a separate type for two big reasons:

  • void tends to be a bit odd so in some ways (it's a type but not really) it makes sense to make it its own thing for easy identification.
  • Biohazrd uses it during the translation stage (particularly for certain entries of vtables), which does not have access to things like CSharpBuiltinTypeReference.
    • Historically Biohazrd used a ClangTypeReference to Clang's built-in void type, but this proved problematic in certain cases and it makes more sense to pre-reduce it anyway.

Example

Given the following C code:

void MyFunction();
void* malloc();

You can expect the following declaration tree after type reduction has ocurred:

TranslatedFunction MyFunction
    ReturnType: VoidTypeReference void ☣
TranslatedFunction malloc
    ReturnType: PointerTypeReference void*
        Inner: VoidTypeReference void ☣

The corresponding C# variable definitions are:

public static extern void MyFunction();
public static extern void* malloc();
``