mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Implement static finalize / initialize. Version bump.
This commit is contained in:
committed by
Christoffer Lerno
parent
58647043f4
commit
e1b5b0b60c
62
test/test_suite/initialize/initialize_finalize.c3t
Normal file
62
test/test_suite/initialize/initialize_finalize.c3t
Normal file
@@ -0,0 +1,62 @@
|
||||
// #target: linux-x64
|
||||
module test;
|
||||
import std::io;
|
||||
|
||||
fn void main()
|
||||
{
|
||||
io::println("Hello, world!");
|
||||
}
|
||||
extern fn void puts(char*);
|
||||
|
||||
static initialize @priority(300)
|
||||
{
|
||||
puts("Hello startup2");
|
||||
}
|
||||
static initialize
|
||||
{
|
||||
puts("Let's start main...");
|
||||
}
|
||||
static initialize @priority(200)
|
||||
{
|
||||
puts("Hello startup");
|
||||
}
|
||||
|
||||
static initialize
|
||||
{}
|
||||
|
||||
static finalize
|
||||
{
|
||||
puts("Bye bye");
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
@llvm.global_ctors = appending global [3 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 300, void ()* @.static_initialize.0, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @.static_initialize.1, i8* null }, { i32, void ()*, i8* } { i32 200, void ()* @.static_initialize.2, i8* null }]
|
||||
@llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @.static_finalize.0, i8* null }]
|
||||
|
||||
define void @.static_initialize.0() {
|
||||
entry:
|
||||
call void @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i32 0, i32 0))
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @puts(i8*) #0
|
||||
|
||||
define void @.static_initialize.1() {
|
||||
entry:
|
||||
call void @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i32 0, i32 0))
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @.static_initialize.2() {
|
||||
entry:
|
||||
call void @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i32 0, i32 0))
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @.static_finalize.0() {
|
||||
entry:
|
||||
call void @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0))
|
||||
ret void
|
||||
}
|
||||
Reference in New Issue
Block a user