Store functions as globals
This commit is contained in:
parent
8274ca7d8a
commit
e63649bdda
@ -842,6 +842,10 @@ pub const Type = opaque {
|
|||||||
pub fn get(return_type: *Type, parameter_types: []const *Type, is_var_args: bool) *Type.Function {
|
pub fn get(return_type: *Type, parameter_types: []const *Type, is_var_args: bool) *Type.Function {
|
||||||
return api.LLVMFunctionType(return_type, parameter_types.ptr, @intCast(parameter_types.len), @intFromBool(is_var_args));
|
return api.LLVMFunctionType(return_type, parameter_types.ptr, @intCast(parameter_types.len), @intFromBool(is_var_args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn to_type(function_type: *Type.Function) *Type {
|
||||||
|
return @ptrCast(function_type);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Integer = opaque {
|
pub const Integer = opaque {
|
||||||
|
@ -944,6 +944,13 @@ pub noinline fn convert(options: ConvertOptions) void {
|
|||||||
});
|
});
|
||||||
handle.set_calling_convention(calling_convention.to_llvm());
|
handle.set_calling_convention(calling_convention.to_llvm());
|
||||||
|
|
||||||
|
const global = module.globals.add();
|
||||||
|
global.* = .{
|
||||||
|
.type = Type.new(function_type.to_type(), false),
|
||||||
|
.storage = handle.to_value(),
|
||||||
|
.name = global_name,
|
||||||
|
};
|
||||||
|
|
||||||
const entry_block = thread.context.create_basic_block("entry", handle);
|
const entry_block = thread.context.create_basic_block("entry", handle);
|
||||||
thread.builder.position_at_end(entry_block);
|
thread.builder.position_at_end(entry_block);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user