Pass 'global'
This commit is contained in:
parent
7f5d0834ae
commit
b9d7212169
@ -6238,7 +6238,30 @@ parse = fn (module: &Module) void
|
||||
|
||||
if (!is_global_keyword)
|
||||
{
|
||||
#trap();
|
||||
>initial_value = parse_value(module, scope, zero);
|
||||
skip_space(module);
|
||||
expect_character(module, ';');
|
||||
|
||||
>global_storage = new_value(module);
|
||||
global_storage.& = {
|
||||
.id = .global,
|
||||
zero,
|
||||
};
|
||||
|
||||
>global = new_global(module);
|
||||
global.& = {
|
||||
.variable = {
|
||||
.storage = global_storage,
|
||||
.type = global_type,
|
||||
.scope = scope,
|
||||
.name = global_name,
|
||||
.line = global_line,
|
||||
.column = global_column,
|
||||
},
|
||||
.initial_value = initial_value,
|
||||
.linkage = .internal, // TODO: linkage
|
||||
zero,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10829,14 +10852,14 @@ emit = fn (module: &Module) void
|
||||
continue;
|
||||
}
|
||||
|
||||
>global_pointer_type = global.variable.storage.type;
|
||||
assert(global_pointer_type.id == .pointer);
|
||||
>global_value_type = global_pointer_type.content.pointer.element_type;
|
||||
|
||||
switch (global.variable.storage.id)
|
||||
{
|
||||
.function, .forward_declared_function =>
|
||||
{
|
||||
>global_pointer_type = global.variable.storage.type;
|
||||
assert(global_pointer_type.id == .pointer);
|
||||
>global_value_type = global_pointer_type.content.pointer.element_type;
|
||||
|
||||
>function_type = &global_value_type.content.function;
|
||||
>semantic_argument_types = function_type.base.semantic_argument_types;
|
||||
>semantic_return_type = function_type.base.semantic_return_type;
|
||||
@ -11063,7 +11086,16 @@ emit = fn (module: &Module) void
|
||||
assert(!module.current_macro_instantiation);
|
||||
assert(!module.current_macro_declaration);
|
||||
|
||||
if (global.variable.storage.id == .function)
|
||||
if (global.emitted)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (global.variable.storage.id)
|
||||
{
|
||||
.function,
|
||||
.forward_declared_function,
|
||||
=>
|
||||
{
|
||||
module.current_function = global;
|
||||
|
||||
@ -11096,11 +11128,11 @@ emit = fn (module: &Module) void
|
||||
.ignore => {},
|
||||
.indirect =>
|
||||
{
|
||||
#trap();
|
||||
#trap();
|
||||
},
|
||||
.in_alloca =>
|
||||
{
|
||||
#trap();
|
||||
#trap();
|
||||
},
|
||||
else =>
|
||||
{
|
||||
@ -11142,12 +11174,12 @@ emit = fn (module: &Module) void
|
||||
|
||||
if (coerce_to_type.llvm.abi != LLVMTypeOf(v))
|
||||
{
|
||||
#trap();
|
||||
#trap();
|
||||
}
|
||||
|
||||
if (is_promoted)
|
||||
{
|
||||
#trap();
|
||||
#trap();
|
||||
}
|
||||
|
||||
// TODO: this we can get rid of because we handle all of this inside `create_alloca`, load, stores, etc
|
||||
@ -11179,7 +11211,7 @@ emit = fn (module: &Module) void
|
||||
}
|
||||
else
|
||||
{
|
||||
#trap();
|
||||
#trap();
|
||||
}
|
||||
|
||||
create_store(module, {
|
||||
@ -11214,7 +11246,7 @@ emit = fn (module: &Module) void
|
||||
>is_fixed_vector_type: u1 = 0;
|
||||
if (is_fixed_vector_type)
|
||||
{
|
||||
#trap();
|
||||
#trap();
|
||||
}
|
||||
|
||||
if (coerce_to_type.id == .struct and coerce_to_type.content.struct.fields.length > 1 and argument_abi.flags.kind == .direct and !argument_abi.flags.can_be_flattened)
|
||||
@ -11222,7 +11254,7 @@ emit = fn (module: &Module) void
|
||||
>contains_homogeneous_scalable_vector_types: u1 = 0;
|
||||
if (contains_homogeneous_scalable_vector_types)
|
||||
{
|
||||
#trap();
|
||||
#trap();
|
||||
}
|
||||
}
|
||||
|
||||
@ -11237,7 +11269,7 @@ emit = fn (module: &Module) void
|
||||
|
||||
if (argument_abi.attributes.direct.offset > 0)
|
||||
{
|
||||
#trap();
|
||||
#trap();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -11253,7 +11285,7 @@ emit = fn (module: &Module) void
|
||||
|
||||
if (is_scalable)
|
||||
{
|
||||
#trap();
|
||||
#trap();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -11317,7 +11349,7 @@ emit = fn (module: &Module) void
|
||||
},
|
||||
.indirect =>
|
||||
{
|
||||
#trap();
|
||||
#trap();
|
||||
},
|
||||
else =>
|
||||
{
|
||||
@ -11357,7 +11389,7 @@ emit = fn (module: &Module) void
|
||||
}
|
||||
else
|
||||
{
|
||||
#trap();
|
||||
#trap();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -11381,7 +11413,7 @@ emit = fn (module: &Module) void
|
||||
|
||||
if (has_single_jump_to_return_block)
|
||||
{
|
||||
#trap();
|
||||
#trap();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -11399,7 +11431,7 @@ emit = fn (module: &Module) void
|
||||
>semantic_return_type = return_abi.semantic_type;
|
||||
if (semantic_return_type == noreturn_type(module) or function.content.function.attributes.naked)
|
||||
{
|
||||
#trap();
|
||||
#trap();
|
||||
}
|
||||
else if (semantic_return_type == void_type(module))
|
||||
{
|
||||
@ -11437,12 +11469,12 @@ emit = fn (module: &Module) void
|
||||
}
|
||||
else
|
||||
{
|
||||
#trap();
|
||||
#trap();
|
||||
}
|
||||
},
|
||||
.indirect =>
|
||||
{
|
||||
#trap();
|
||||
#trap();
|
||||
},
|
||||
}
|
||||
|
||||
@ -11451,6 +11483,12 @@ emit = fn (module: &Module) void
|
||||
|
||||
// END OF SCOPE
|
||||
module.current_function = zero;
|
||||
},
|
||||
.global =>
|
||||
{
|
||||
#trap();
|
||||
},
|
||||
else => { report_error(); },
|
||||
}
|
||||
|
||||
global = global.next;
|
||||
@ -11783,6 +11821,7 @@ names: [_][]u8 = [
|
||||
"pointer_cast",
|
||||
"u1_return",
|
||||
"local_type_inference",
|
||||
"global",
|
||||
];
|
||||
|
||||
[export] main = fn [cc(c)] (argument_count: u32, argv: &&u8, envp: &&u8) s32
|
||||
|
Loading…
x
Reference in New Issue
Block a user