gccrs: Implement extern types by reusing ADT with an extern kind
gccrs now represents extern types using an ADT with a new 'extern' kind.
This commit introduces support for extern types in gccrs by reusing the existing ADTType. A new ADTKind ‘extern’ is added to represent these opaque types. This change is accompanied by updates to various backend and type-checking components, along with new test cases for extern type compilation.
In Details
The gccrs frontend now models extern types, which are opaque types defined in other languages, using a new 'extern' kind within its existing ADTType representation. This avoids introducing a new distinct type and reuses existing infrastructure for handling ADTs. The change impacts type checking, backend compilation, and requires new test cases to ensure correct handling of these types.
- extern types
- In Rust, extern types are types whose layout and size are unknown to the Rust compiler, typically because they are defined in external languages (like C). They are used for FFI (Foreign Function Interface) when the exact definition isn't available or relevant.
- ADT
- Algebraic Data Type. A type that can be constructed from a fixed set of other types. In Rust, enums and structs are forms of ADTs. gccrs uses an ADTType representation for various complex types.
- ADTKind
- An enumeration within gccrs that categorizes different kinds of Algebraic Data Types, such as structs or enums. A new 'extern' kind has been added to specifically represent extern types.
- HIR
- High-level Intermediate Representation. A representation of the code that is closer to the source language than machine code, used by the Rust compiler (and gccrs) for analysis and transformations before generating lower-level code.