| author | |
| committer | |
| log | 02f3a834b014da10e487cb3150120c0dc0a4c119 |
| tree | 8e734bd4a9452b504d96f419f4766cbfe664ad97 |
| parent | 5424b4320def194b205dcfe8e937035d2d80ae09 |
| signature | Commit is signed but in an unrecognized format. |
and function symbol names become fully qualified13 files changed, 172 insertions(+), 135 deletions(-)
src/all_types.hpp+3-3| ... | ... | @@ -1076,6 +1076,7 @@ enum ResolveStatus { |
| 1076 | 1076 | struct ZigPackage { |
| 1077 | 1077 | Buf root_src_dir; |
| 1078 | 1078 | Buf root_src_path; // relative to root_src_dir |
| 1079 | Buf pkg_path; // a.b.c.d which follows the package dependency chain from the root package | |
| 1079 | 1080 | |
| 1080 | 1081 | // reminder: hash tables must be initialized before use |
| 1081 | 1082 | HashMap<Buf *, ZigPackage *, buf_hash, buf_eql_buf> package_table; |
| ... | ... | @@ -1089,7 +1090,6 @@ struct RootStruct { |
| 1089 | 1090 | Buf *source_code; |
| 1090 | 1091 | AstNode *c_import_node; |
| 1091 | 1092 | ZigLLVMDIFile *di_file; |
| 1092 | bool scanned; | |
| 1093 | 1093 | }; |
| 1094 | 1094 | |
| 1095 | 1095 | struct ZigTypeStruct { |
| ... | ... | @@ -1678,8 +1678,6 @@ struct CodeGen { |
| 1678 | 1678 | HashMap<Buf *, ConstExprValue *, buf_hash, buf_eql_buf> string_literals_table; |
| 1679 | 1679 | HashMap<const ZigType *, ConstExprValue *, type_ptr_hash, type_ptr_eql> type_info_cache; |
| 1680 | 1680 | |
| 1681 | ZigList<ZigType *> import_queue; | |
| 1682 | size_t import_queue_index; | |
| 1683 | 1681 | ZigList<Tld *> resolve_queue; |
| 1684 | 1682 | size_t resolve_queue_index; |
| 1685 | 1683 | ZigList<AstNode *> use_queue; |
| ... | ... | @@ -3472,6 +3470,8 @@ static const size_t stack_trace_ptr_count = 30; |
| 3472 | 3470 | #define ERR_RET_TRACE_PTR_FIELD_NAME "err_ret_trace_ptr" |
| 3473 | 3471 | #define RESULT_PTR_FIELD_NAME "result_ptr" |
| 3474 | 3472 | |
| 3473 | #define NAMESPACE_SEP_CHAR '.' | |
| 3474 | #define NAMESPACE_SEP_STR "." | |
| 3475 | 3475 | |
| 3476 | 3476 | enum FloatMode { |
| 3477 | 3477 | FloatModeStrict, |
src/analyze.cpp+76-64| ... | ... | @@ -1295,7 +1295,7 @@ static ZigTypeId container_to_type(ContainerKind kind) { |
| 1295 | 1295 | // This is like get_partial_container_type except it's for the implicit root struct of files. |
| 1296 | 1296 | ZigType *get_root_container_type(CodeGen *g, const char *name, RootStruct *root_struct) { |
| 1297 | 1297 | ZigType *entry = new_type_table_entry(ZigTypeIdStruct); |
| 1298 | entry->data.structure.decls_scope = create_decls_scope(g, nullptr, nullptr, nullptr, entry); | |
| 1298 | entry->data.structure.decls_scope = create_decls_scope(g, nullptr, nullptr, entry, entry); | |
| 1299 | 1299 | entry->data.structure.root_struct = root_struct; |
| 1300 | 1300 | entry->data.structure.layout = ContainerLayoutAuto; |
| 1301 | 1301 | entry->type_ref = LLVMStructCreateNamed(LLVMGetGlobalContext(), name); |
| ... | ... | @@ -3230,27 +3230,16 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) { |
| 3230 | 3230 | return ErrorNone; |
| 3231 | 3231 | } |
| 3232 | 3232 | |
| 3233 | static void get_fully_qualified_decl_name_internal(Buf *buf, Scope *scope, uint8_t sep) { | |
| 3234 | if (!scope) | |
| 3235 | return; | |
| 3236 | ||
| 3237 | if (scope->id == ScopeIdDecls) { | |
| 3238 | get_fully_qualified_decl_name_internal(buf, scope->parent, sep); | |
| 3233 | static void get_fully_qualified_decl_name(Buf *buf, Tld *tld) { | |
| 3234 | buf_resize(buf, 0); | |
| 3239 | 3235 | |
| 3240 | ScopeDecls *scope_decls = (ScopeDecls *)scope; | |
| 3241 | if (scope_decls->container_type) { | |
| 3242 | buf_append_buf(buf, &scope_decls->container_type->name); | |
| 3243 | buf_append_char(buf, sep); | |
| 3244 | } | |
| 3245 | return; | |
| 3236 | Scope *scope = tld->parent_scope; | |
| 3237 | while (scope->id != ScopeIdDecls) { | |
| 3238 | scope = scope->parent; | |
| 3246 | 3239 | } |
| 3247 | ||
| 3248 | get_fully_qualified_decl_name_internal(buf, scope->parent, sep); | |
| 3249 | } | |
| 3250 | ||
| 3251 | static void get_fully_qualified_decl_name(Buf *buf, Tld *tld, uint8_t sep) { | |
| 3252 | buf_resize(buf, 0); | |
| 3253 | get_fully_qualified_decl_name_internal(buf, tld->parent_scope, sep); | |
| 3240 | ScopeDecls *decls_scope = reinterpret_cast<ScopeDecls *>(scope); | |
| 3241 | buf_append_buf(buf, &decls_scope->container_type->name); | |
| 3242 | buf_append_char(buf, NAMESPACE_SEP_CHAR); | |
| 3254 | 3243 | buf_append_buf(buf, tld->name); |
| 3255 | 3244 | } |
| 3256 | 3245 | |
| ... | ... | @@ -3285,8 +3274,7 @@ static bool scope_is_root_decls(Scope *scope) { |
| 3285 | 3274 | while (scope) { |
| 3286 | 3275 | if (scope->id == ScopeIdDecls) { |
| 3287 | 3276 | ScopeDecls *scope_decls = (ScopeDecls *)scope; |
| 3288 | return scope_decls->container_type == nullptr || | |
| 3289 | is_top_level_struct(scope_decls->container_type); | |
| 3277 | return is_top_level_struct(scope_decls->container_type); | |
| 3290 | 3278 | } |
| 3291 | 3279 | scope = scope->parent; |
| 3292 | 3280 | } |
| ... | ... | @@ -3302,7 +3290,7 @@ void typecheck_panic_fn(CodeGen *g, TldFn *tld_fn, ZigFn *panic_fn) { |
| 3302 | 3290 | AstNode *fake_decl = allocate<AstNode>(1); |
| 3303 | 3291 | *fake_decl = *panic_fn->proto_node; |
| 3304 | 3292 | fake_decl->type = NodeTypeSymbol; |
| 3305 | fake_decl->data.symbol_expr.symbol = &panic_fn->symbol_name; | |
| 3293 | fake_decl->data.symbol_expr.symbol = tld_fn->base.name; | |
| 3306 | 3294 | |
| 3307 | 3295 | // call this for the side effects of casting to panic_fn_type |
| 3308 | 3296 | analyze_const_value(g, tld_fn->base.parent_scope, fake_decl, panic_fn_type, nullptr); |
| ... | ... | @@ -3355,16 +3343,21 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { |
| 3355 | 3343 | AstNode *fn_def_node = fn_proto->fn_def_node; |
| 3356 | 3344 | |
| 3357 | 3345 | ZigFn *fn_table_entry = create_fn(g, source_node); |
| 3358 | get_fully_qualified_decl_name(&fn_table_entry->symbol_name, &tld_fn->base, '_'); | |
| 3346 | tld_fn->fn_entry = fn_table_entry; | |
| 3347 | ||
| 3348 | bool is_extern = (fn_table_entry->body_node == nullptr); | |
| 3349 | if (fn_proto->is_export || is_extern) { | |
| 3350 | buf_init_from_buf(&fn_table_entry->symbol_name, tld_fn->base.name); | |
| 3351 | } else { | |
| 3352 | get_fully_qualified_decl_name(&fn_table_entry->symbol_name, &tld_fn->base); | |
| 3353 | } | |
| 3359 | 3354 | |
| 3360 | 3355 | if (fn_proto->is_export) { |
| 3361 | 3356 | bool ccc = (fn_proto->cc == CallingConventionUnspecified || fn_proto->cc == CallingConventionC); |
| 3362 | 3357 | add_fn_export(g, fn_table_entry, &fn_table_entry->symbol_name, GlobalLinkageIdStrong, ccc); |
| 3363 | 3358 | } |
| 3364 | 3359 | |
| 3365 | tld_fn->fn_entry = fn_table_entry; | |
| 3366 | ||
| 3367 | if (fn_table_entry->body_node) { | |
| 3360 | if (!is_extern) { | |
| 3368 | 3361 | fn_table_entry->fndef_scope = create_fndef_scope(g, |
| 3369 | 3362 | fn_table_entry->body_node, tld_fn->base.parent_scope, fn_table_entry); |
| 3370 | 3363 | |
| ... | ... | @@ -3405,10 +3398,10 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { |
| 3405 | 3398 | if (scope_is_root_decls(tld_fn->base.parent_scope) && |
| 3406 | 3399 | (import == g->root_import || import->data.structure.root_struct->package == g->panic_package)) |
| 3407 | 3400 | { |
| 3408 | if (g->have_pub_main && buf_eql_str(&fn_table_entry->symbol_name, "main")) { | |
| 3401 | if (g->have_pub_main && buf_eql_str(tld_fn->base.name, "main")) { | |
| 3409 | 3402 | g->main_fn = fn_table_entry; |
| 3410 | 3403 | } else if ((import->data.structure.root_struct->package == g->panic_package || g->have_pub_panic) && |
| 3411 | buf_eql_str(&fn_table_entry->symbol_name, "panic")) | |
| 3404 | buf_eql_str(tld_fn->base.name, "panic")) | |
| 3412 | 3405 | { |
| 3413 | 3406 | g->panic_fn = fn_table_entry; |
| 3414 | 3407 | g->panic_tld_fn = tld_fn; |
| ... | ... | @@ -3417,7 +3410,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { |
| 3417 | 3410 | } else if (source_node->type == NodeTypeTestDecl) { |
| 3418 | 3411 | ZigFn *fn_table_entry = create_fn_raw(g, FnInlineAuto); |
| 3419 | 3412 | |
| 3420 | get_fully_qualified_decl_name(&fn_table_entry->symbol_name, &tld_fn->base, '_'); | |
| 3413 | get_fully_qualified_decl_name(&fn_table_entry->symbol_name, &tld_fn->base); | |
| 3421 | 3414 | |
| 3422 | 3415 | tld_fn->fn_entry = fn_table_entry; |
| 3423 | 3416 | |
| ... | ... | @@ -3973,6 +3966,12 @@ ZigFn *scope_fn_entry(Scope *scope) { |
| 3973 | 3966 | return nullptr; |
| 3974 | 3967 | } |
| 3975 | 3968 | |
| 3969 | ZigPackage *scope_package(Scope *scope) { | |
| 3970 | ZigType *import = get_scope_import(scope); | |
| 3971 | assert(is_top_level_struct(import)); | |
| 3972 | return import->data.structure.root_struct->package; | |
| 3973 | } | |
| 3974 | ||
| 3976 | 3975 | TypeEnumField *find_enum_type_field(ZigType *enum_type, Buf *name) { |
| 3977 | 3976 | assert(enum_type->id == ZigTypeIdEnum); |
| 3978 | 3977 | if (enum_type->data.enumeration.src_field_count == 0) |
| ... | ... | @@ -4437,7 +4436,9 @@ void preview_use_decl(CodeGen *g, AstNode *node) { |
| 4437 | 4436 | node->data.use.value = result; |
| 4438 | 4437 | } |
| 4439 | 4438 | |
| 4440 | ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *resolved_path, Buf *source_code) { | |
| 4439 | ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *resolved_path, Buf *source_code, | |
| 4440 | SourceKind source_kind) | |
| 4441 | { | |
| 4441 | 4442 | if (g->verbose_tokenize) { |
| 4442 | 4443 | fprintf(stderr, "\nOriginal Source (%s):\n", buf_ptr(resolved_path)); |
| 4443 | 4444 | fprintf(stderr, "----------------\n"); |
| ... | ... | @@ -4470,14 +4471,29 @@ ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *resolved_path, Bu |
| 4470 | 4471 | os_path_split(resolved_path, src_dirname, src_basename); |
| 4471 | 4472 | |
| 4472 | 4473 | Buf noextname = BUF_INIT; |
| 4473 | os_path_extname(src_basename, &noextname, nullptr); | |
| 4474 | os_path_extname(resolved_path, &noextname, nullptr); | |
| 4475 | ||
| 4476 | Buf *pkg_root_src_dir = &package->root_src_dir; | |
| 4477 | Buf resolved_root_src_dir = os_path_resolve(&pkg_root_src_dir, 1); | |
| 4478 | Buf namespace_name = BUF_INIT; | |
| 4479 | buf_init_from_buf(&namespace_name, &package->pkg_path); | |
| 4480 | if (buf_len(&namespace_name) != 0) buf_append_char(&namespace_name, NAMESPACE_SEP_CHAR); | |
| 4481 | buf_append_mem(&namespace_name, buf_ptr(&noextname) + buf_len(&resolved_root_src_dir) + 1, | |
| 4482 | buf_len(&noextname) - (buf_len(&resolved_root_src_dir) + 1)); | |
| 4483 | buf_replace(&namespace_name, ZIG_OS_SEP_CHAR, NAMESPACE_SEP_CHAR); | |
| 4484 | ||
| 4474 | 4485 | RootStruct *root_struct = allocate<RootStruct>(1); |
| 4475 | 4486 | root_struct->package = package; |
| 4476 | 4487 | root_struct->source_code = source_code; |
| 4477 | 4488 | root_struct->line_offsets = tokenization.line_offsets; |
| 4478 | 4489 | root_struct->path = resolved_path; |
| 4479 | 4490 | root_struct->di_file = ZigLLVMCreateFile(g->dbuilder, buf_ptr(src_basename), buf_ptr(src_dirname)); |
| 4480 | ZigType *import_entry = get_root_container_type(g, buf_ptr(&noextname), root_struct); | |
| 4491 | ZigType *import_entry = get_root_container_type(g, buf_ptr(&namespace_name), root_struct); | |
| 4492 | if (source_kind == SourceKindRoot) { | |
| 4493 | assert(g->root_import == nullptr); | |
| 4494 | g->root_import = import_entry; | |
| 4495 | } | |
| 4496 | g->import_table.put(resolved_path, import_entry); | |
| 4481 | 4497 | |
| 4482 | 4498 | AstNode *root_node = ast_parse(source_code, tokenization.tokens, import_entry, g->err_color); |
| 4483 | 4499 | assert(root_node != nullptr); |
| ... | ... | @@ -4488,48 +4504,44 @@ ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *resolved_path, Bu |
| 4488 | 4504 | ast_print(stderr, root_node, 0); |
| 4489 | 4505 | } |
| 4490 | 4506 | |
| 4491 | g->import_table.put(resolved_path, import_entry); | |
| 4492 | g->import_queue.append(import_entry); | |
| 4507 | if (source_kind == SourceKindRoot || package == g->panic_package) { | |
| 4508 | // Look for panic and main | |
| 4509 | for (size_t decl_i = 0; decl_i < root_node->data.container_decl.decls.length; decl_i += 1) { | |
| 4510 | AstNode *top_level_decl = root_node->data.container_decl.decls.at(decl_i); | |
| 4493 | 4511 | |
| 4494 | for (size_t decl_i = 0; decl_i < root_node->data.container_decl.decls.length; decl_i += 1) { | |
| 4495 | AstNode *top_level_decl = root_node->data.container_decl.decls.at(decl_i); | |
| 4512 | if (top_level_decl->type == NodeTypeFnDef) { | |
| 4513 | AstNode *proto_node = top_level_decl->data.fn_def.fn_proto; | |
| 4514 | assert(proto_node->type == NodeTypeFnProto); | |
| 4515 | Buf *proto_name = proto_node->data.fn_proto.name; | |
| 4496 | 4516 | |
| 4497 | if (top_level_decl->type == NodeTypeFnDef) { | |
| 4498 | AstNode *proto_node = top_level_decl->data.fn_def.fn_proto; | |
| 4499 | assert(proto_node->type == NodeTypeFnProto); | |
| 4500 | Buf *proto_name = proto_node->data.fn_proto.name; | |
| 4501 | ||
| 4502 | bool is_pub = (proto_node->data.fn_proto.visib_mod == VisibModPub); | |
| 4503 | bool ok_cc = (proto_node->data.fn_proto.cc == CallingConventionUnspecified || | |
| 4504 | proto_node->data.fn_proto.cc == CallingConventionCold); | |
| 4505 | ||
| 4506 | if (is_pub && ok_cc) { | |
| 4507 | if (buf_eql_str(proto_name, "main")) { | |
| 4508 | g->have_pub_main = true; | |
| 4509 | g->subsystem = TargetSubsystemConsole; | |
| 4510 | } else if (buf_eql_str(proto_name, "panic")) { | |
| 4511 | g->have_pub_panic = true; | |
| 4517 | bool is_pub = (proto_node->data.fn_proto.visib_mod == VisibModPub); | |
| 4518 | if (is_pub) { | |
| 4519 | if (buf_eql_str(proto_name, "main")) { | |
| 4520 | g->have_pub_main = true; | |
| 4521 | g->subsystem = TargetSubsystemConsole; | |
| 4522 | } else if (buf_eql_str(proto_name, "panic")) { | |
| 4523 | g->have_pub_panic = true; | |
| 4524 | } | |
| 4512 | 4525 | } |
| 4513 | 4526 | } |
| 4514 | 4527 | } |
| 4515 | 4528 | } |
| 4516 | 4529 | |
| 4517 | return import_entry; | |
| 4518 | } | |
| 4519 | ||
| 4520 | void scan_import(CodeGen *g, ZigType *import) { | |
| 4521 | if (!import->data.structure.root_struct->scanned) { | |
| 4522 | import->data.structure.root_struct->scanned = true; | |
| 4523 | scan_decls(g, import->data.structure.decls_scope, import->data.structure.decl_node); | |
| 4530 | for (size_t decl_i = 0; decl_i < root_node->data.container_decl.decls.length; decl_i += 1) { | |
| 4531 | AstNode *top_level_decl = root_node->data.container_decl.decls.at(decl_i); | |
| 4532 | scan_decls(g, import_entry->data.structure.decls_scope, top_level_decl); | |
| 4524 | 4533 | } |
| 4534 | ||
| 4535 | TldContainer *tld_container = allocate<TldContainer>(1); | |
| 4536 | init_tld(&tld_container->base, TldIdContainer, &namespace_name, VisibModPub, root_node, nullptr); | |
| 4537 | tld_container->type_entry = import_entry; | |
| 4538 | tld_container->decls_scope = import_entry->data.structure.decls_scope; | |
| 4539 | g->resolve_queue.append(&tld_container->base); | |
| 4540 | ||
| 4541 | return import_entry; | |
| 4525 | 4542 | } |
| 4526 | 4543 | |
| 4527 | 4544 | void semantic_analyze(CodeGen *g) { |
| 4528 | for (; g->import_queue_index < g->import_queue.length; g->import_queue_index += 1) { | |
| 4529 | ZigType *import = g->import_queue.at(g->import_queue_index); | |
| 4530 | scan_import(g, import); | |
| 4531 | } | |
| 4532 | ||
| 4533 | 4545 | for (; g->use_queue_index < g->use_queue.length; g->use_queue_index += 1) { |
| 4534 | 4546 | AstNode *use_decl_node = g->use_queue.at(g->use_queue_index); |
| 4535 | 4547 | preview_use_decl(g, use_decl_node); |
src/analyze.hpp+7-3| ... | ... | @@ -47,8 +47,12 @@ bool type_allowed_in_extern(CodeGen *g, ZigType *type_entry); |
| 47 | 47 | bool ptr_allows_addr_zero(ZigType *ptr_type); |
| 48 | 48 | bool type_is_nonnull_ptr(ZigType *type); |
| 49 | 49 | |
| 50 | ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *abs_full_path, Buf *source_code); | |
| 51 | ||
| 50 | enum SourceKind { | |
| 51 | SourceKindRoot, | |
| 52 | SourceKindNonRoot, | |
| 53 | }; | |
| 54 | ZigType *add_source_file(CodeGen *g, ZigPackage *package, Buf *abs_full_path, Buf *source_code, | |
| 55 | SourceKind source_kind); | |
| 52 | 56 | |
| 53 | 57 | ZigVar *find_variable(CodeGen *g, Scope *orig_context, Buf *name, ScopeFnDef **crossed_fndef_scope); |
| 54 | 58 | Tld *find_decl(CodeGen *g, Scope *scope, Buf *name); |
| ... | ... | @@ -78,10 +82,10 @@ bool is_array_ref(ZigType *type_entry); |
| 78 | 82 | bool is_container_ref(ZigType *type_entry); |
| 79 | 83 | bool is_valid_vector_elem_type(ZigType *elem_type); |
| 80 | 84 | void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node); |
| 81 | void scan_import(CodeGen *g, ZigType *import); | |
| 82 | 85 | void preview_use_decl(CodeGen *g, AstNode *node); |
| 83 | 86 | void resolve_use_decl(CodeGen *g, AstNode *node); |
| 84 | 87 | ZigFn *scope_fn_entry(Scope *scope); |
| 88 | ZigPackage *scope_package(Scope *scope); | |
| 85 | 89 | ZigType *get_scope_import(Scope *scope); |
| 86 | 90 | void init_tld(Tld *tld, TldId id, Buf *name, VisibMod visib_mod, AstNode *source_node, Scope *parent_scope); |
| 87 | 91 | ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf *name, |
src/buffer.hpp+3-3| ... | ... | @@ -59,7 +59,7 @@ static inline void buf_deinit(Buf *buf) { |
| 59 | 59 | static inline void buf_init_from_mem(Buf *buf, const char *ptr, size_t len) { |
| 60 | 60 | assert(len != SIZE_MAX); |
| 61 | 61 | buf->list.resize(len + 1); |
| 62 | safe_memcpy(buf_ptr(buf), ptr, len); | |
| 62 | memcpy(buf_ptr(buf), ptr, len); | |
| 63 | 63 | buf->list.at(buf_len(buf)) = 0; |
| 64 | 64 | } |
| 65 | 65 | |
| ... | ... | @@ -98,7 +98,7 @@ static inline Buf *buf_slice(Buf *in_buf, size_t start, size_t end) { |
| 98 | 98 | assert(end <= buf_len(in_buf)); |
| 99 | 99 | Buf *out_buf = allocate<Buf>(1); |
| 100 | 100 | out_buf->list.resize(end - start + 1); |
| 101 | safe_memcpy(buf_ptr(out_buf), buf_ptr(in_buf) + start, end - start); | |
| 101 | memcpy(buf_ptr(out_buf), buf_ptr(in_buf) + start, end - start); | |
| 102 | 102 | out_buf->list.at(buf_len(out_buf)) = 0; |
| 103 | 103 | return out_buf; |
| 104 | 104 | } |
| ... | ... | @@ -108,7 +108,7 @@ static inline void buf_append_mem(Buf *buf, const char *mem, size_t mem_len) { |
| 108 | 108 | assert(mem_len != SIZE_MAX); |
| 109 | 109 | size_t old_len = buf_len(buf); |
| 110 | 110 | buf_resize(buf, old_len + mem_len); |
| 111 | safe_memcpy(buf_ptr(buf) + old_len, mem, mem_len); | |
| 111 | memcpy(buf_ptr(buf) + old_len, mem, mem_len); | |
| 112 | 112 | buf->list.at(buf_len(buf)) = 0; |
| 113 | 113 | } |
| 114 | 114 |
src/codegen.cpp+20-17| ... | ... | @@ -48,16 +48,17 @@ static void init_darwin_native(CodeGen *g) { |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | static ZigPackage *new_package(const char *root_src_dir, const char *root_src_path) { | |
| 51 | static ZigPackage *new_package(const char *root_src_dir, const char *root_src_path, const char *pkg_path) { | |
| 52 | 52 | ZigPackage *entry = allocate<ZigPackage>(1); |
| 53 | 53 | entry->package_table.init(4); |
| 54 | 54 | buf_init_from_str(&entry->root_src_dir, root_src_dir); |
| 55 | 55 | buf_init_from_str(&entry->root_src_path, root_src_path); |
| 56 | buf_init_from_str(&entry->pkg_path, pkg_path); | |
| 56 | 57 | return entry; |
| 57 | 58 | } |
| 58 | 59 | |
| 59 | ZigPackage *new_anonymous_package(void) { | |
| 60 | return new_package("", ""); | |
| 60 | ZigPackage *new_anonymous_package() { | |
| 61 | return new_package("", "", ""); | |
| 61 | 62 | } |
| 62 | 63 | |
| 63 | 64 | static const char *symbols_that_llvm_depends_on[] = { |
| ... | ... | @@ -141,11 +142,11 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out |
| 141 | 142 | exit(1); |
| 142 | 143 | } |
| 143 | 144 | |
| 144 | g->root_package = new_package(buf_ptr(src_dir), buf_ptr(src_basename)); | |
| 145 | g->std_package = new_package(buf_ptr(g->zig_std_dir), "index.zig"); | |
| 145 | g->root_package = new_package(buf_ptr(src_dir), buf_ptr(src_basename), ""); | |
| 146 | g->std_package = new_package(buf_ptr(g->zig_std_dir), "index.zig", "std"); | |
| 146 | 147 | g->root_package->package_table.put(buf_create_from_str("std"), g->std_package); |
| 147 | 148 | } else { |
| 148 | g->root_package = new_package(".", ""); | |
| 149 | g->root_package = new_package(".", "", ""); | |
| 149 | 150 | } |
| 150 | 151 | |
| 151 | 152 | g->zig_std_special_dir = buf_alloc(); |
| ... | ... | @@ -7742,12 +7743,12 @@ static Error define_builtin_compile_vars(CodeGen *g) { |
| 7742 | 7743 | |
| 7743 | 7744 | assert(g->root_package); |
| 7744 | 7745 | assert(g->std_package); |
| 7745 | g->compile_var_package = new_package(buf_ptr(this_dir), builtin_zig_basename); | |
| 7746 | g->compile_var_package = new_package(buf_ptr(this_dir), builtin_zig_basename, "builtin"); | |
| 7746 | 7747 | g->root_package->package_table.put(buf_create_from_str("builtin"), g->compile_var_package); |
| 7747 | 7748 | g->std_package->package_table.put(buf_create_from_str("builtin"), g->compile_var_package); |
| 7748 | 7749 | g->std_package->package_table.put(buf_create_from_str("std"), g->std_package); |
| 7749 | g->compile_var_import = add_source_file(g, g->compile_var_package, builtin_zig_path, contents); | |
| 7750 | scan_import(g, g->compile_var_import); | |
| 7750 | g->compile_var_import = add_source_file(g, g->compile_var_package, builtin_zig_path, contents, | |
| 7751 | SourceKindNonRoot); | |
| 7751 | 7752 | |
| 7752 | 7753 | return ErrorNone; |
| 7753 | 7754 | } |
| ... | ... | @@ -7986,21 +7987,21 @@ static ZigType *add_special_code(CodeGen *g, ZigPackage *package, const char *ba |
| 7986 | 7987 | zig_panic("unable to open '%s': %s\n", buf_ptr(&path_to_code_src), err_str(err)); |
| 7987 | 7988 | } |
| 7988 | 7989 | |
| 7989 | return add_source_file(g, package, resolved_path, import_code); | |
| 7990 | return add_source_file(g, package, resolved_path, import_code, SourceKindNonRoot); | |
| 7990 | 7991 | } |
| 7991 | 7992 | |
| 7992 | 7993 | static ZigPackage *create_bootstrap_pkg(CodeGen *g, ZigPackage *pkg_with_main) { |
| 7993 | ZigPackage *package = codegen_create_package(g, buf_ptr(g->zig_std_special_dir), "bootstrap.zig"); | |
| 7994 | ZigPackage *package = codegen_create_package(g, buf_ptr(g->zig_std_special_dir), "bootstrap.zig", "std.special"); | |
| 7994 | 7995 | package->package_table.put(buf_create_from_str("@root"), pkg_with_main); |
| 7995 | 7996 | return package; |
| 7996 | 7997 | } |
| 7997 | 7998 | |
| 7998 | 7999 | static ZigPackage *create_test_runner_pkg(CodeGen *g) { |
| 7999 | return codegen_create_package(g, buf_ptr(g->zig_std_special_dir), "test_runner.zig"); | |
| 8000 | return codegen_create_package(g, buf_ptr(g->zig_std_special_dir), "test_runner.zig", "std.special"); | |
| 8000 | 8001 | } |
| 8001 | 8002 | |
| 8002 | 8003 | static ZigPackage *create_panic_pkg(CodeGen *g) { |
| 8003 | return codegen_create_package(g, buf_ptr(g->zig_std_special_dir), "panic.zig"); | |
| 8004 | return codegen_create_package(g, buf_ptr(g->zig_std_special_dir), "panic.zig", "std.special"); | |
| 8004 | 8005 | } |
| 8005 | 8006 | |
| 8006 | 8007 | static void create_test_compile_var_and_add_test_runner(CodeGen *g) { |
| ... | ... | @@ -8084,7 +8085,8 @@ static void gen_root_source(CodeGen *g) { |
| 8084 | 8085 | exit(1); |
| 8085 | 8086 | } |
| 8086 | 8087 | |
| 8087 | g->root_import = add_source_file(g, g->root_package, resolved_path, source_code); | |
| 8088 | ZigType *root_import_alias = add_source_file(g, g->root_package, resolved_path, source_code, SourceKindRoot); | |
| 8089 | assert(root_import_alias == g->root_import); | |
| 8088 | 8090 | |
| 8089 | 8091 | assert(g->root_out_name); |
| 8090 | 8092 | assert(g->out_type != OutTypeUnknown); |
| ... | ... | @@ -8098,7 +8100,6 @@ static void gen_root_source(CodeGen *g) { |
| 8098 | 8100 | g->panic_package = create_panic_pkg(g); |
| 8099 | 8101 | import_with_panic = add_special_code(g, g->panic_package, "panic.zig"); |
| 8100 | 8102 | } |
| 8101 | scan_import(g, import_with_panic); | |
| 8102 | 8103 | Tld *panic_tld = find_decl(g, &get_container_scope(import_with_panic)->base, buf_create_from_str("panic")); |
| 8103 | 8104 | assert(panic_tld != nullptr); |
| 8104 | 8105 | resolve_top_level_decl(g, panic_tld, nullptr); |
| ... | ... | @@ -9021,9 +9022,11 @@ void codegen_build_and_link(CodeGen *g) { |
| 9021 | 9022 | codegen_add_time_event(g, "Done"); |
| 9022 | 9023 | } |
| 9023 | 9024 | |
| 9024 | ZigPackage *codegen_create_package(CodeGen *g, const char *root_src_dir, const char *root_src_path) { | |
| 9025 | ZigPackage *codegen_create_package(CodeGen *g, const char *root_src_dir, const char *root_src_path, | |
| 9026 | const char *pkg_path) | |
| 9027 | { | |
| 9025 | 9028 | init(g); |
| 9026 | ZigPackage *pkg = new_package(root_src_dir, root_src_path); | |
| 9029 | ZigPackage *pkg = new_package(root_src_dir, root_src_path, pkg_path); | |
| 9027 | 9030 | if (g->std_package != nullptr) { |
| 9028 | 9031 | assert(g->compile_var_package != nullptr); |
| 9029 | 9032 | pkg->package_table.put(buf_create_from_str("std"), g->std_package); |
src/codegen.hpp+2-1| ... | ... | @@ -48,7 +48,8 @@ void codegen_print_timing_report(CodeGen *g, FILE *f); |
| 48 | 48 | void codegen_link(CodeGen *g); |
| 49 | 49 | void codegen_build_and_link(CodeGen *g); |
| 50 | 50 | |
| 51 | ZigPackage *codegen_create_package(CodeGen *g, const char *root_src_dir, const char *root_src_path); | |
| 51 | ZigPackage *codegen_create_package(CodeGen *g, const char *root_src_dir, const char *root_src_path, | |
| 52 | const char *pkg_path); | |
| 52 | 53 | void codegen_add_assembly(CodeGen *g, Buf *path); |
| 53 | 54 | void codegen_add_object(CodeGen *g, Buf *object_path); |
| 54 | 55 |
src/ir.cpp+49-22| ... | ... | @@ -6608,9 +6608,15 @@ static bool render_instance_name_recursive(CodeGen *codegen, Buf *name, Scope *o |
| 6608 | 6608 | return true; |
| 6609 | 6609 | } |
| 6610 | 6610 | |
| 6611 | static Buf *get_anon_type_name(CodeGen *codegen, IrExecutable *exec, const char *kind_name, AstNode *source_node) { | |
| 6611 | static Buf *get_anon_type_name(CodeGen *codegen, IrExecutable *exec, const char *kind_name, | |
| 6612 | Scope *scope, AstNode *source_node) | |
| 6613 | { | |
| 6612 | 6614 | if (exec->name) { |
| 6613 | return exec->name; | |
| 6615 | ZigPackage *cur_scope_pkg = scope_package(scope); | |
| 6616 | Buf *namespace_name = buf_create_from_buf(&cur_scope_pkg->pkg_path); | |
| 6617 | if (buf_len(namespace_name) != 0) buf_append_char(namespace_name, NAMESPACE_SEP_CHAR); | |
| 6618 | buf_append_buf(namespace_name, exec->name); | |
| 6619 | return namespace_name; | |
| 6614 | 6620 | } else if (exec->name_fn != nullptr) { |
| 6615 | 6621 | Buf *name = buf_alloc(); |
| 6616 | 6622 | buf_append_buf(name, &exec->name_fn->symbol_name); |
| ... | ... | @@ -6619,37 +6625,52 @@ static Buf *get_anon_type_name(CodeGen *codegen, IrExecutable *exec, const char |
| 6619 | 6625 | buf_appendf(name, ")"); |
| 6620 | 6626 | return name; |
| 6621 | 6627 | } else { |
| 6622 | // Note: C-imports do not have valid location information | |
| 6623 | // TODO this will get fixed by https://github.com/ziglang/zig/issues/2015 | |
| 6624 | return buf_sprintf("(anonymous %s at %s:%" ZIG_PRI_usize ":%" ZIG_PRI_usize ")", kind_name, | |
| 6625 | (source_node->owner->data.structure.root_struct->path != nullptr) ? | |
| 6626 | buf_ptr(source_node->owner->data.structure.root_struct->path) : | |
| 6627 | "(null)", source_node->line + 1, source_node->column + 1); | |
| 6628 | ZigPackage *cur_scope_pkg = scope_package(scope); | |
| 6629 | Buf *namespace_name = buf_create_from_buf(&cur_scope_pkg->pkg_path); | |
| 6630 | if (buf_len(namespace_name) != 0) buf_append_char(namespace_name, NAMESPACE_SEP_CHAR); | |
| 6631 | buf_appendf(namespace_name, "%s:%" ZIG_PRI_usize ":%" ZIG_PRI_usize, kind_name, | |
| 6632 | source_node->line + 1, source_node->column + 1); | |
| 6633 | return namespace_name; | |
| 6628 | 6634 | } |
| 6629 | 6635 | } |
| 6630 | 6636 | |
| 6637 | static void get_namespace_name(Buf *buf, Scope *scope, uint8_t sep) { | |
| 6638 | if (!scope) | |
| 6639 | return; | |
| 6640 | ||
| 6641 | if (scope->id == ScopeIdDecls) { | |
| 6642 | get_namespace_name(buf, scope->parent, sep); | |
| 6643 | ||
| 6644 | ScopeDecls *scope_decls = (ScopeDecls *)scope; | |
| 6645 | if (scope_decls->container_type) { | |
| 6646 | buf_append_buf(buf, &scope_decls->container_type->name); | |
| 6647 | buf_append_char(buf, sep); | |
| 6648 | } | |
| 6649 | return; | |
| 6650 | } | |
| 6651 | ||
| 6652 | get_namespace_name(buf, scope->parent, sep); | |
| 6653 | } | |
| 6631 | 6654 | static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope, AstNode *node) { |
| 6632 | 6655 | assert(node->type == NodeTypeContainerDecl); |
| 6633 | 6656 | |
| 6634 | 6657 | ContainerKind kind = node->data.container_decl.kind; |
| 6635 | Buf *name = get_anon_type_name(irb->codegen, irb->exec, container_string(kind), node); | |
| 6636 | ||
| 6637 | VisibMod visib_mod = VisibModPub; | |
| 6638 | TldContainer *tld_container = allocate<TldContainer>(1); | |
| 6639 | init_tld(&tld_container->base, TldIdContainer, name, visib_mod, node, parent_scope); | |
| 6658 | Buf *name = get_anon_type_name(irb->codegen, irb->exec, container_string(kind), parent_scope, node); | |
| 6640 | 6659 | |
| 6641 | 6660 | ContainerLayout layout = node->data.container_decl.layout; |
| 6642 | 6661 | ZigType *container_type = get_partial_container_type(irb->codegen, parent_scope, |
| 6643 | 6662 | kind, node, buf_ptr(name), layout); |
| 6644 | 6663 | ScopeDecls *child_scope = get_container_scope(container_type); |
| 6645 | 6664 | |
| 6646 | tld_container->type_entry = container_type; | |
| 6647 | tld_container->decls_scope = child_scope; | |
| 6648 | ||
| 6649 | 6665 | for (size_t i = 0; i < node->data.container_decl.decls.length; i += 1) { |
| 6650 | 6666 | AstNode *child_node = node->data.container_decl.decls.at(i); |
| 6651 | 6667 | scan_decls(irb->codegen, child_scope, child_node); |
| 6652 | 6668 | } |
| 6669 | ||
| 6670 | TldContainer *tld_container = allocate<TldContainer>(1); | |
| 6671 | init_tld(&tld_container->base, TldIdContainer, name, VisibModPub, node, parent_scope); | |
| 6672 | tld_container->type_entry = container_type; | |
| 6673 | tld_container->decls_scope = child_scope; | |
| 6653 | 6674 | irb->codegen->resolve_queue.append(&tld_container->base); |
| 6654 | 6675 | |
| 6655 | 6676 | // Add this to the list to mark as invalid if analyzing this exec fails. |
| ... | ... | @@ -6734,7 +6755,7 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A |
| 6734 | 6755 | |
| 6735 | 6756 | uint32_t err_count = node->data.err_set_decl.decls.length; |
| 6736 | 6757 | |
| 6737 | Buf *type_name = get_anon_type_name(irb->codegen, irb->exec, "error set", node); | |
| 6758 | Buf *type_name = get_anon_type_name(irb->codegen, irb->exec, "error", parent_scope, node); | |
| 6738 | 6759 | ZigType *err_set_type = new_type_table_entry(ZigTypeIdErrorSet); |
| 6739 | 6760 | buf_init_from_buf(&err_set_type->name, type_name); |
| 6740 | 6761 | err_set_type->data.error_set.err_count = err_count; |
| ... | ... | @@ -17018,9 +17039,8 @@ static IrInstruction *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructio |
| 17018 | 17039 | } |
| 17019 | 17040 | } |
| 17020 | 17041 | |
| 17021 | ZigType *target_import = add_source_file(ira->codegen, target_package, resolved_path, import_code); | |
| 17022 | ||
| 17023 | scan_import(ira->codegen, target_import); | |
| 17042 | ZigType *target_import = add_source_file(ira->codegen, target_package, resolved_path, import_code, | |
| 17043 | SourceKindNonRoot); | |
| 17024 | 17044 | |
| 17025 | 17045 | return ir_const_type(ira, &import_instruction->base, target_import); |
| 17026 | 17046 | } |
| ... | ... | @@ -18658,14 +18678,20 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 18658 | 18678 | if (type_is_invalid(cimport_result->type)) |
| 18659 | 18679 | return ira->codegen->invalid_instruction; |
| 18660 | 18680 | |
| 18681 | ZigPackage *cur_scope_pkg = scope_package(instruction->base.scope); | |
| 18682 | Buf *namespace_name = buf_sprintf("%s.cimport:%" ZIG_PRI_usize ":%" ZIG_PRI_usize, | |
| 18683 | buf_ptr(&cur_scope_pkg->pkg_path), node->line + 1, node->column + 1); | |
| 18684 | ||
| 18661 | 18685 | RootStruct *root_struct = allocate<RootStruct>(1); |
| 18662 | 18686 | root_struct->package = new_anonymous_package(); |
| 18663 | 18687 | root_struct->package->package_table.put(buf_create_from_str("builtin"), ira->codegen->compile_var_package); |
| 18664 | 18688 | root_struct->package->package_table.put(buf_create_from_str("std"), ira->codegen->std_package); |
| 18665 | 18689 | root_struct->c_import_node = node; |
| 18690 | // TODO create namespace_name file in zig-cache instead of /tmp and use it | |
| 18691 | // for this DIFile | |
| 18666 | 18692 | root_struct->di_file = ZigLLVMCreateFile(ira->codegen->dbuilder, |
| 18667 | 18693 | buf_ptr(buf_create_from_str("cimport.h")), buf_ptr(buf_create_from_str("."))); |
| 18668 | ZigType *child_import = get_root_container_type(ira->codegen, "cimport", root_struct); | |
| 18694 | ZigType *child_import = get_root_container_type(ira->codegen, buf_ptr(namespace_name), root_struct); | |
| 18669 | 18695 | |
| 18670 | 18696 | ZigList<ErrorMsg *> errors = {0}; |
| 18671 | 18697 | |
| ... | ... | @@ -21614,7 +21640,8 @@ static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstru |
| 21614 | 21640 | } |
| 21615 | 21641 | |
| 21616 | 21642 | static IrInstruction *ir_analyze_instruction_opaque_type(IrAnalyze *ira, IrInstructionOpaqueType *instruction) { |
| 21617 | Buf *name = get_anon_type_name(ira->codegen, ira->new_irb.exec, "opaque", instruction->base.source_node); | |
| 21643 | Buf *name = get_anon_type_name(ira->codegen, ira->new_irb.exec, "opaque", | |
| 21644 | instruction->base.scope, instruction->base.source_node); | |
| 21618 | 21645 | ZigType *result_type = get_opaque_type(ira->codegen, instruction->base.scope, instruction->base.source_node, |
| 21619 | 21646 | buf_ptr(name)); |
| 21620 | 21647 | return ir_const_type(ira, &instruction->base, result_type); |
src/main.cpp+3-2| ... | ... | @@ -223,7 +223,8 @@ static void add_package(CodeGen *g, CliPkg *cli_pkg, ZigPackage *pkg) { |
| 223 | 223 | Buf *basename = buf_alloc(); |
| 224 | 224 | os_path_split(buf_create_from_str(child_cli_pkg->path), dirname, basename); |
| 225 | 225 | |
| 226 | ZigPackage *child_pkg = codegen_create_package(g, buf_ptr(dirname), buf_ptr(basename)); | |
| 226 | ZigPackage *child_pkg = codegen_create_package(g, buf_ptr(dirname), buf_ptr(basename), | |
| 227 | buf_ptr(buf_sprintf("%s.%s", buf_ptr(&pkg->pkg_path), child_cli_pkg->name))); | |
| 227 | 228 | auto entry = pkg->package_table.put_unique(buf_create_from_str(child_cli_pkg->name), child_pkg); |
| 228 | 229 | if (entry) { |
| 229 | 230 | ZigPackage *existing_pkg = entry->value; |
| ... | ... | @@ -544,7 +545,7 @@ int main(int argc, char **argv) { |
| 544 | 545 | } |
| 545 | 546 | |
| 546 | 547 | ZigPackage *build_pkg = codegen_create_package(g, buf_ptr(&build_file_dirname), |
| 547 | buf_ptr(&build_file_basename)); | |
| 548 | buf_ptr(&build_file_basename), "std.special"); | |
| 548 | 549 | g->root_package->package_table.put(buf_create_from_str("@build"), build_pkg); |
| 549 | 550 | g->enable_cache = get_cache_opt(enable_cache, true); |
| 550 | 551 | codegen_build_and_link(g); |
src/os.cpp+1-1| ... | ... | @@ -264,7 +264,7 @@ void os_path_join(Buf *dirname, Buf *basename, Buf *out_full_path) { |
| 264 | 264 | buf_append_buf(out_full_path, basename); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | int os_path_real(Buf *rel_path, Buf *out_abs_path) { | |
| 267 | Error os_path_real(Buf *rel_path, Buf *out_abs_path) { | |
| 268 | 268 | #if defined(ZIG_OS_WINDOWS) |
| 269 | 269 | buf_resize(out_abs_path, 4096); |
| 270 | 270 | if (_fullpath(buf_ptr(out_abs_path), buf_ptr(rel_path), buf_len(out_abs_path)) == nullptr) { |
src/os.hpp+1-1| ... | ... | @@ -96,7 +96,7 @@ void os_path_dirname(Buf *full_path, Buf *out_dirname); |
| 96 | 96 | void os_path_split(Buf *full_path, Buf *out_dirname, Buf *out_basename); |
| 97 | 97 | void os_path_extname(Buf *full_path, Buf *out_basename, Buf *out_extname); |
| 98 | 98 | void os_path_join(Buf *dirname, Buf *basename, Buf *out_full_path); |
| 99 | int os_path_real(Buf *rel_path, Buf *out_abs_path); | |
| 99 | Error os_path_real(Buf *rel_path, Buf *out_abs_path); | |
| 100 | 100 | Buf os_path_resolve(Buf **paths_ptr, size_t paths_len); |
| 101 | 101 | bool os_path_is_absolute(Buf *path); |
| 102 | 102 |
src/util.hpp-12| ... | ... | @@ -93,18 +93,6 @@ ATTRIBUTE_RETURNS_NOALIAS static inline T *allocate(size_t count) { |
| 93 | 93 | return ptr; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | template<typename T> | |
| 97 | static inline void safe_memcpy(T *dest, const T *src, size_t count) { | |
| 98 | #ifdef NDEBUG | |
| 99 | memcpy(dest, src, count * sizeof(T)); | |
| 100 | #else | |
| 101 | // manually assign every elment to trigger compile error for non-copyable structs | |
| 102 | for (size_t i = 0; i < count; i += 1) { | |
| 103 | dest[i] = src[i]; | |
| 104 | } | |
| 105 | #endif | |
| 106 | } | |
| 107 | ||
| 108 | 96 | template<typename T> |
| 109 | 97 | static inline T *reallocate(T *old, size_t old_count, size_t new_count) { |
| 110 | 98 | T *ptr = reallocate_nonzero(old, old_count, new_count); |
test/stage1/behavior/asm.zig+5-5| ... | ... | @@ -4,16 +4,16 @@ const expect = @import("std").testing.expect; |
| 4 | 4 | comptime { |
| 5 | 5 | if (config.arch == config.Arch.x86_64 and config.os == config.Os.linux) { |
| 6 | 6 | asm volatile ( |
| 7 | \\.globl aoeu; | |
| 8 | \\.type aoeu, @function; | |
| 9 | \\.set aoeu, derp; | |
| 7 | \\.globl this_is_my_alias; | |
| 8 | \\.type this_is_my_alias, @function; | |
| 9 | \\.set this_is_my_alias, derp; | |
| 10 | 10 | ); |
| 11 | 11 | } |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | test "module level assembly" { |
| 15 | 15 | if (config.arch == config.Arch.x86_64 and config.os == config.Os.linux) { |
| 16 | expect(aoeu() == 1234); | |
| 16 | expect(this_is_my_alias() == 1234); | |
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | 19 | |
| ... | ... | @@ -85,7 +85,7 @@ test "sized integer/float in asm input" { |
| 85 | 85 | ); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | extern fn aoeu() i32; | |
| 88 | extern fn this_is_my_alias() i32; | |
| 89 | 89 | |
| 90 | 90 | export fn derp() i32 { |
| 91 | 91 | return 1234; |
test/stage1/behavior/misc.zig+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const expect = std.testing.expect; |
| 3 | const expectEqualSlices = std.testing.expectEqualSlices; | |
| 3 | 4 | const mem = std.mem; |
| 4 | 5 | const cstr = std.cstr; |
| 5 | 6 | const builtin = @import("builtin"); |
| ... | ... | @@ -488,7 +489,7 @@ test "@typeName" { |
| 488 | 489 | expect(mem.eql(u8, @typeName(i64), "i64")); |
| 489 | 490 | expect(mem.eql(u8, @typeName(*usize), "*usize")); |
| 490 | 491 | // https://github.com/ziglang/zig/issues/675 |
| 491 | expect(mem.eql(u8, @typeName(TypeFromFn(u8)), "TypeFromFn(u8)")); | |
| 492 | expectEqualSlices(u8, "behavior.misc.TypeFromFn(u8)", @typeName(TypeFromFn(u8))); | |
| 492 | 493 | expect(mem.eql(u8, @typeName(Struct), "Struct")); |
| 493 | 494 | expect(mem.eql(u8, @typeName(Union), "Union")); |
| 494 | 495 | expect(mem.eql(u8, @typeName(Enum), "Enum")); |