-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from baszalmstra/function_calls
- Loading branch information
Showing
38 changed files
with
1,376 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
use inkwell::context::ContextRef; | ||
use inkwell::types::{ArrayType, IntType, StructType}; | ||
use inkwell::AddressSpace; | ||
|
||
pub(super) struct AbiTypes { | ||
pub guid_type: ArrayType, | ||
pub privacy_type: IntType, | ||
pub type_info_type: StructType, | ||
pub function_signature_type: StructType, | ||
pub function_info_type: StructType, | ||
pub module_info_type: StructType, | ||
pub dispatch_table_type: StructType, | ||
pub assembly_info_type: StructType, | ||
} | ||
|
||
/// Returns an `AbiTypes` struct that contains references to all LLVM ABI types. | ||
pub(super) fn gen_abi_types(context: ContextRef) -> AbiTypes { | ||
let str_type = context.i8_type().ptr_type(AddressSpace::Const); | ||
|
||
// Construct the `MunGuid` type | ||
let guid_type = context.i8_type().array_type(16); | ||
|
||
// Construct the `MunPrivacy` enum | ||
let privacy_type = context.i8_type(); | ||
|
||
// Construct the `MunTypeInfo` struct | ||
let type_info_type = context.opaque_struct_type("struct.MunTypeInfo"); | ||
type_info_type.set_body( | ||
&[ | ||
guid_type.into(), // guid | ||
str_type.into(), // name | ||
], | ||
false, | ||
); | ||
|
||
// Construct the `MunFunctionSignature` type | ||
let function_signature_type = context.opaque_struct_type("struct.MunFunctionSignature"); | ||
function_signature_type.set_body( | ||
&[ | ||
str_type.into(), // name | ||
type_info_type.ptr_type(AddressSpace::Const).into(), // arg_types | ||
type_info_type.ptr_type(AddressSpace::Const).into(), // return_type | ||
context.i16_type().into(), // num_arg_types | ||
privacy_type.into(), // privacy | ||
], | ||
false, | ||
); | ||
|
||
// Construct the `MunFunctionInfo` struct | ||
let function_info_type = context.opaque_struct_type("struct.MunFunctionInfo"); | ||
function_info_type.set_body( | ||
&[ | ||
function_signature_type.into(), // signature | ||
context | ||
.void_type() | ||
.fn_type(&[], false) | ||
.ptr_type(AddressSpace::Const) | ||
.into(), // fn_ptr | ||
], | ||
false, | ||
); | ||
|
||
// Construct the `MunModuleInfo` struct | ||
let module_info_type = context.opaque_struct_type("struct.MunModuleInfo"); | ||
module_info_type.set_body( | ||
&[ | ||
str_type.into(), // path | ||
function_info_type.ptr_type(AddressSpace::Const).into(), // functions | ||
context.i32_type().into(), // num_functions | ||
], | ||
false, | ||
); | ||
|
||
// Construct the `MunDispatchTable` struct | ||
let dispatch_table_type = context.opaque_struct_type("struct.MunDispatchTable"); | ||
dispatch_table_type.set_body( | ||
&[ | ||
function_signature_type.ptr_type(AddressSpace::Const).into(), // signatures | ||
context | ||
.void_type() | ||
.fn_type(&[], false) | ||
.ptr_type(AddressSpace::Generic) | ||
.ptr_type(AddressSpace::Const) | ||
.into(), // fn_ptrs | ||
context.i32_type().into(), // num_entries | ||
], | ||
false, | ||
); | ||
|
||
// Construct the `MunAssemblyInfo` struct | ||
let assembly_info_type = context.opaque_struct_type("struct.MunAssemblyInfo"); | ||
assembly_info_type.set_body( | ||
&[ | ||
module_info_type.into(), | ||
dispatch_table_type.into(), | ||
str_type.ptr_type(AddressSpace::Const).into(), | ||
context.i32_type().into(), | ||
], | ||
false, | ||
); | ||
|
||
AbiTypes { | ||
guid_type, | ||
privacy_type, | ||
type_info_type, | ||
function_signature_type, | ||
function_info_type, | ||
module_info_type, | ||
dispatch_table_type, | ||
assembly_info_type, | ||
} | ||
} |
Oops, something went wrong.