| ... | @@ -3896,22 +3896,21 @@ ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *resolved_path, Bu | ... | @@ -3896,22 +3896,21 @@ ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *resolved_path, Bu |
| 3896 | Buf *pkg_root_src_dir = &package->root_src_dir; | 3896 | Buf *pkg_root_src_dir = &package->root_src_dir; |
| 3897 | Buf resolved_root_src_dir = os_path_resolve(&pkg_root_src_dir, 1); | 3897 | Buf resolved_root_src_dir = os_path_resolve(&pkg_root_src_dir, 1); |
| 3898 | | 3898 | |
| 3899 | Buf namespace_name = BUF_INIT; | 3899 | Buf *namespace_name = buf_create_from_buf(&package->pkg_path); |
| 3900 | buf_init_from_buf(&namespace_name, &package->pkg_path); | | |
| 3901 | if (source_kind == SourceKindNonRoot) { | 3900 | if (source_kind == SourceKindNonRoot) { |
| 3902 | assert(buf_starts_with_buf(resolved_path, &resolved_root_src_dir)); | 3901 | assert(buf_starts_with_buf(resolved_path, &resolved_root_src_dir)); |
| 3903 | if (buf_len(&namespace_name) != 0) { | 3902 | if (buf_len(namespace_name) != 0) { |
| 3904 | buf_append_char(&namespace_name, NAMESPACE_SEP_CHAR); | 3903 | buf_append_char(namespace_name, NAMESPACE_SEP_CHAR); |
| 3905 | } | 3904 | } |
| 3906 | // The namespace components are obtained from the relative path to the | 3905 | // The namespace components are obtained from the relative path to the |
| 3907 | // source directory | 3906 | // source directory |
| 3908 | if (buf_len(&noextname) > buf_len(&resolved_root_src_dir)) { | 3907 | if (buf_len(&noextname) > buf_len(&resolved_root_src_dir)) { |
| 3909 | // Skip the trailing separator | 3908 | // Skip the trailing separator |
| 3910 | buf_append_mem(&namespace_name, | 3909 | buf_append_mem(namespace_name, |
| 3911 | buf_ptr(&noextname) + buf_len(&resolved_root_src_dir) + 1, | 3910 | buf_ptr(&noextname) + buf_len(&resolved_root_src_dir) + 1, |
| 3912 | buf_len(&noextname) - buf_len(&resolved_root_src_dir) - 1); | 3911 | buf_len(&noextname) - buf_len(&resolved_root_src_dir) - 1); |
| 3913 | } | 3912 | } |
| 3914 | buf_replace(&namespace_name, ZIG_OS_SEP_CHAR, NAMESPACE_SEP_CHAR); | 3913 | buf_replace(namespace_name, ZIG_OS_SEP_CHAR, NAMESPACE_SEP_CHAR); |
| 3915 | } | 3914 | } |
| 3916 | Buf *bare_name = buf_alloc(); | 3915 | Buf *bare_name = buf_alloc(); |
| 3917 | os_path_extname(src_basename, bare_name, nullptr); | 3916 | os_path_extname(src_basename, bare_name, nullptr); |
| ... | @@ -3922,7 +3921,7 @@ ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *resolved_path, Bu | ... | @@ -3922,7 +3921,7 @@ ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *resolved_path, Bu |
| 3922 | root_struct->line_offsets = tokenization.line_offsets; | 3921 | root_struct->line_offsets = tokenization.line_offsets; |
| 3923 | root_struct->path = resolved_path; | 3922 | root_struct->path = resolved_path; |
| 3924 | root_struct->di_file = ZigLLVMCreateFile(g->dbuilder, buf_ptr(src_basename), buf_ptr(src_dirname)); | 3923 | root_struct->di_file = ZigLLVMCreateFile(g->dbuilder, buf_ptr(src_basename), buf_ptr(src_dirname)); |
| 3925 | ZigType *import_entry = get_root_container_type(g, buf_ptr(&namespace_name), bare_name, root_struct); | 3924 | ZigType *import_entry = get_root_container_type(g, buf_ptr(namespace_name), bare_name, root_struct); |
| 3926 | if (source_kind == SourceKindRoot) { | 3925 | if (source_kind == SourceKindRoot) { |
| 3927 | assert(g->root_import == nullptr); | 3926 | assert(g->root_import == nullptr); |
| 3928 | g->root_import = import_entry; | 3927 | g->root_import = import_entry; |
| ... | @@ -3966,7 +3965,7 @@ ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *resolved_path, Bu | ... | @@ -3966,7 +3965,7 @@ ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *resolved_path, Bu |
| 3966 | } | 3965 | } |
| 3967 | | 3966 | |
| 3968 | TldContainer *tld_container = allocate<TldContainer>(1); | 3967 | TldContainer *tld_container = allocate<TldContainer>(1); |
| 3969 | init_tld(&tld_container->base, TldIdContainer, &namespace_name, VisibModPub, root_node, nullptr); | 3968 | init_tld(&tld_container->base, TldIdContainer, namespace_name, VisibModPub, root_node, nullptr); |
| 3970 | tld_container->type_entry = import_entry; | 3969 | tld_container->type_entry = import_entry; |
| 3971 | tld_container->decls_scope = import_entry->data.structure.decls_scope; | 3970 | tld_container->decls_scope = import_entry->data.structure.decls_scope; |
| 3972 | g->resolve_queue.append(&tld_container->base); | 3971 | g->resolve_queue.append(&tld_container->base); |