Past remaining tests #39

Merged
davidgmbb merged 18 commits from macro-tests into main 2025-06-19 16:16:21 +00:00
4 changed files with 1985 additions and 149 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1029,7 +1029,6 @@ struct MacroDeclaration
{ {
Slice<Argument> arguments; Slice<Argument> arguments;
Slice<ConstantArgument> constant_arguments; Slice<ConstantArgument> constant_arguments;
TypeList types;
Type* return_type; Type* return_type;
Block* block; Block* block;
String name; String name;
@ -1934,12 +1933,13 @@ fn Type* get_enum_array_type(Module* module, Type* enum_type, Type* element_type
return last_enum_type; return last_enum_type;
} }
if (!last_enum_type->enum_array.next) auto next = last_enum_type->enum_array.next;
if (!next)
{ {
break; break;
} }
last_enum_type = last_enum_type->enum_array.next; last_enum_type = next;
} }
} }

View File

@ -43,6 +43,7 @@ enum class TypeKind
abi, abi,
memory, memory,
}; };
fn void analyze_block(Module* module, Block* block); fn void analyze_block(Module* module, Block* block);
fn void emit_local_storage(Module* module, Variable* variable); fn void emit_local_storage(Module* module, Variable* variable);
fn void emit_assignment(Module* module, LLVMValueRef left_llvm, Type* left_type, Value* right); fn void emit_assignment(Module* module, LLVMValueRef left_llvm, Type* left_type, Value* right);
@ -340,6 +341,7 @@ fn bool is_arbitrary_bit_integer(Type* type)
{ {
case TypeId::integer: switch (type->integer.bit_count) case TypeId::integer: switch (type->integer.bit_count)
{ {
case 1:
case 8: case 8:
case 16: case 16:
case 32: case 32:
@ -1622,7 +1624,10 @@ fn AbiInformation abi_system_v_get_indirect_result(Module* module, Type* type, u
{ {
if (is_promotable_integer_type_for_abi(type)) if (is_promotable_integer_type_for_abi(type))
{ {
trap(); return abi_system_v_get_extend({
.semantic_type = type,
.sign = type_is_signed(type),
});
} }
else else
{ {
@ -1654,7 +1659,6 @@ fn AbiInformation abi_system_v_get_indirect_result(Module* module, Type* type, u
} }
} }
struct AbiSystemVClassifyArgumentTypeOptions struct AbiSystemVClassifyArgumentTypeOptions
{ {
u32 available_gpr; u32 available_gpr;
@ -1949,7 +1953,7 @@ struct AllocaOptions
fn Global* get_current_function(Module* module) fn Global* get_current_function(Module* module)
{ {
Global* parent_function_global; Global* parent_function_global = 0;
if (module->current_function) if (module->current_function)
{ {
parent_function_global = module->current_function; parent_function_global = module->current_function;
@ -1958,10 +1962,6 @@ fn Global* get_current_function(Module* module)
{ {
parent_function_global = module->current_macro_instantiation->instantiation_function; parent_function_global = module->current_macro_instantiation->instantiation_function;
} }
else
{
report_error();
}
return parent_function_global; return parent_function_global;
} }
@ -4095,7 +4095,10 @@ fn void analyze_type(Module* module, Value* value, Type* expected_type, TypeAnal
bool is_ordered = true; bool is_ordered = true;
auto enum_type = aggregate_type->enum_array.enum_type; auto enum_type = aggregate_type->enum_array.enum_type;
auto element_type = aggregate_type->enum_array.element_type; auto element_type = aggregate_type->enum_array.element_type;
assert(enum_type->id == TypeId::enumerator); if (enum_type->id != TypeId::enumerator)
{
report_error();
}
auto fields = enum_type->enumerator.fields; auto fields = enum_type->enumerator.fields;
assert(fields.length <= 64); assert(fields.length <= 64);
@ -9372,6 +9375,7 @@ void emit(Module* module)
abi_argument_type_count += 1; abi_argument_type_count += 1;
} }
for (u64 i = 0; i < semantic_argument_count; i += 1) for (u64 i = 0; i < semantic_argument_count; i += 1)
{ {
auto& abi = function_type->abi.argument_abis[i]; auto& abi = function_type->abi.argument_abis[i];

View File

@ -2693,7 +2693,11 @@ fn Statement* parse_statement(Module* module, Scope* scope)
} break; } break;
case StatementStartKeyword::return_st: case StatementStartKeyword::return_st:
{ {
auto return_value = parse_value(module, scope, {}); Value* return_value = 0;
if (module->content[module->offset] != ';')
{
return_value = parse_value(module, scope, {});
}
statement->return_st = return_value; statement->return_st = return_value;
statement->id = StatementId::return_st; statement->id = StatementId::return_st;
} break; } break;