Merge remote-tracking branch 'origin/integrate-library' into integrate-library

This commit is contained in:
Sven Vogel 2024-06-13 00:15:43 +02:00
commit 984c34cfc7
2 changed files with 10 additions and 2 deletions

View File

@ -76,6 +76,11 @@ void delete_files(ModuleFileStack *stack) {
// behaves like fgets except that it has defined behavior when n == 1
static void custom_fgets(char *buffer, size_t n, FILE *stream) {
if (feof(stream)) {
buffer[0] = '\n';
buffer[1] = 0;
return;
}
if (n == 1) {
buffer[0] = (char) fgetc(stream);
buffer[1] = 0;

View File

@ -372,10 +372,13 @@ BackendError impl_variable_load(LLVMBackendCompileUnit *unit, LLVMLocalScope *sc
} else {
type = variable->impl.declaration.type;
}
get_type_impl(unit, scope->func_scope->global_scope, type, &llvm_type);
if (LLVMGetTypeKind(LLVMTypeOf(llvm_variable)) == LLVMPointerTypeKind) {
*llvm_result = LLVMBuildLoad2(builder, llvm_type, llvm_variable, "");
} else {
*llvm_result = llvm_variable;
}
}
return SUCCESS;