fixed: assignment of multidimensional arrays
This commit is contained in:
parent
db501b4b9e
commit
372c14c575
|
@ -65,12 +65,6 @@ TargetLinkConfig* lld_create_link_config(__attribute__((unused)) const Target* t
|
|||
g_array_append_val(config->object_file_names, target_object);
|
||||
INFO("resolved path of target object: %s", target_object);
|
||||
|
||||
// if it is an app, add entrypoint library
|
||||
if (target_config->mode == Application) {
|
||||
char* entrypoint = g_strdup("libentrypoint.a");
|
||||
g_array_append_val(module->imports, entrypoint);
|
||||
}
|
||||
|
||||
// resolve absolute paths to dependent library object files
|
||||
DEBUG("resolving target dependencies...");
|
||||
for (guint i = 0; i < module->imports->len; i++) {
|
||||
|
@ -78,9 +72,9 @@ TargetLinkConfig* lld_create_link_config(__attribute__((unused)) const Target* t
|
|||
|
||||
const char* dependency_object = get_absolute_link_path(target_config, dependency);
|
||||
if (dependency_object == NULL) {
|
||||
ERROR("failed to resolve path to dependency object: %s", dependency);
|
||||
lld_delete_link_config(config);
|
||||
return NULL;
|
||||
INFO("failed to resolve path to dependency object: %s", dependency);
|
||||
print_message(Warning, "failed to resolve path to dependency object: %s", dependency);
|
||||
continue;
|
||||
}
|
||||
g_array_append_val(config->object_file_names, dependency_object);
|
||||
INFO("resolved path of target object: %s", dependency_object);
|
||||
|
@ -91,53 +85,8 @@ TargetLinkConfig* lld_create_link_config(__attribute__((unused)) const Target* t
|
|||
return config;
|
||||
}
|
||||
|
||||
GArray* lld_create_lld_arguments(TargetLinkConfig* config) {
|
||||
GArray* argv = g_array_new(TRUE, FALSE, sizeof(char*));
|
||||
|
||||
gchar* arg = g_strdup("ld.lld");
|
||||
g_array_append_val(argv, arg);
|
||||
|
||||
if (config->fatal_warnings) {
|
||||
arg = g_strdup("--fatal-warnings");
|
||||
g_array_append_val(argv, arg);
|
||||
}
|
||||
|
||||
if (config->colorize) {
|
||||
arg = g_strdup("--color-diagnostics=always");
|
||||
g_array_append_val(argv, arg);
|
||||
}
|
||||
|
||||
{
|
||||
arg = g_strjoin("", "-o", config->output_file, NULL);
|
||||
g_array_append_val(argv, arg);
|
||||
}
|
||||
|
||||
for (guint i = 0; i < config->object_file_names->len; i++) {
|
||||
char* object_file_path = g_array_index(config->object_file_names, char*, i);
|
||||
arg = g_strjoin("", object_file_path, NULL);
|
||||
g_array_append_val(argv, arg);
|
||||
}
|
||||
|
||||
return argv;
|
||||
}
|
||||
|
||||
BackendError lld_link_target(TargetLinkConfig* config) {
|
||||
DEBUG("linking target...");
|
||||
BackendError err = SUCCESS;
|
||||
|
||||
GArray* argv = lld_create_lld_arguments(config);
|
||||
|
||||
INFO("Linking target...");
|
||||
|
||||
char* arguments = g_strjoinv(" ", (char**) argv->data);
|
||||
print_message(Info, "%s", arguments);
|
||||
g_free(arguments);
|
||||
|
||||
INFO("done linking target...");
|
||||
|
||||
g_array_free(argv, TRUE);
|
||||
|
||||
return err;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
void lld_delete_link_config(TargetLinkConfig* config) {
|
||||
|
|
|
@ -41,16 +41,22 @@ BackendError impl_storage_expr(
|
|||
return err;
|
||||
}
|
||||
|
||||
if (expr->impl.dereference.array->kind == StorageExprKindDereference) {
|
||||
LLVMTypeRef deref_type = NULL;
|
||||
err = get_type_impl(unit, scope->func_scope->global_scope, expr->target_type, &deref_type);
|
||||
err = get_type_impl(unit, scope->func_scope->global_scope, expr->impl.dereference.array->target_type, &deref_type);
|
||||
if (err.kind != Success) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (expr->target_type->kind == TypeKindReference) {
|
||||
array = LLVMBuildLoad2(builder, deref_type, array, "strg.deref.indirect-load");
|
||||
}
|
||||
|
||||
LLVMTypeRef deref_type = NULL;
|
||||
err = get_type_impl(unit, scope->func_scope->global_scope, expr->target_type, &deref_type);
|
||||
if (err.kind != Success) {
|
||||
return err;
|
||||
}
|
||||
|
||||
*storage_target = LLVMBuildGEP2(builder, deref_type, array, &index, 1, "strg.deref");
|
||||
|
||||
break;
|
||||
|
@ -210,6 +216,8 @@ BackendError impl_func_call(LLVMBackendCompileUnit *unit,
|
|||
Parameter parameter = g_array_index(param_list, Parameter, i);
|
||||
if (is_parameter_out(¶meter)) {
|
||||
reference = TRUE;
|
||||
} else if (parameter.impl.declaration.type->kind == TypeKindReference) {
|
||||
reference = TRUE;
|
||||
}
|
||||
|
||||
LLVMValueRef llvm_arg = NULL;
|
||||
|
|
|
@ -259,9 +259,13 @@ BackendError parse_module(const Module* module, const TargetConfig* config) {
|
|||
if (config->mode == Application) {
|
||||
TargetLinkConfig* link_config = lld_create_link_config(&target, config, module);
|
||||
|
||||
if (link_config != NULL) {
|
||||
lld_link_target(link_config);
|
||||
|
||||
lld_delete_link_config(link_config);
|
||||
} else {
|
||||
err = new_backend_impl_error(Implementation, NULL, "libclang error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue