authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-12-28 16:41:51-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-15 15:11:36-08:00
log78987081ce84a49230073e8211dadc0dea7351c3
treef1b38cc2a51186bccd249c06e7036700292b381d
parenta72e7384aae81d012f017c837df8c16048bdea4e

can't use source location until return from this function


1 files changed, 11 insertions(+), 11 deletions(-)

src/link/Wasm/Object.zig+11-11
...@@ -696,10 +696,10 @@ pub fn parse(...@@ -696,10 +696,10 @@ pub fn parse(
696 exp.* = .{696 exp.* = .{
697 .name = try wasm.internString(name),697 .name = try wasm.internString(name),
698 .pointee = switch (kind) {698 .pointee = switch (kind) {
699 .function => .{ .function = @enumFromInt(functions_start + index) },699 .function => .{ .function = @enumFromInt(functions_start + (index - ss.func_imports.items.len)) },
700 .table => .{ .table = @enumFromInt(tables_start + index) },700 .table => .{ .table = @enumFromInt(tables_start + index) },
701 .memory => .{ .memory = @enumFromInt(memories_start + index) },701 .memory => .{ .memory = @enumFromInt(memories_start + index) },
702 .global => .{ .global = @enumFromInt(globals_start + index) },702 .global => .{ .global = @enumFromInt(globals_start + (index - ss.global_imports.items.len)) },
703 },703 },
704 };704 };
705 }705 }
...@@ -827,7 +827,7 @@ pub fn parse(...@@ -827,7 +827,7 @@ pub fn parse(
827 gop.value_ptr.source_location.addNote(wasm, &err, "imported as {} here", .{827 gop.value_ptr.source_location.addNote(wasm, &err, "imported as {} here", .{
828 gop.value_ptr.type.fmt(wasm),828 gop.value_ptr.type.fmt(wasm),
829 });829 });
830 source_location.addNote(wasm, &err, "imported as {} here", .{fn_ty_index.fmt(wasm)});830 err.addNote("{}: imported as {} here", .{ path, fn_ty_index.fmt(wasm) });
831 continue;831 continue;
832 }832 }
833 if (gop.value_ptr.module_name != ptr.module_name.toOptional()) {833 if (gop.value_ptr.module_name != ptr.module_name.toOptional()) {
...@@ -838,7 +838,7 @@ pub fn parse(...@@ -838,7 +838,7 @@ pub fn parse(
838 } else {838 } else {
839 gop.value_ptr.source_location.addNote(wasm, &err, "no module here", .{});839 gop.value_ptr.source_location.addNote(wasm, &err, "no module here", .{});
840 }840 }
841 source_location.addNote(wasm, &err, "module '{s}' here", .{ptr.module_name.slice(wasm)});841 err.addNote("{}: module '{s}' here", .{ path, ptr.module_name.slice(wasm) });
842 continue;842 continue;
843 }843 }
844 if (symbol.flags.binding == .strong) gop.value_ptr.flags.binding = .strong;844 if (symbol.flags.binding == .strong) gop.value_ptr.flags.binding = .strong;
...@@ -868,7 +868,7 @@ pub fn parse(...@@ -868,7 +868,7 @@ pub fn parse(
868 var err = try diags.addErrorWithNotes(2);868 var err = try diags.addErrorWithNotes(2);
869 try err.addMsg("symbol '{s}' mismatching global types", .{name.slice(wasm)});869 try err.addMsg("symbol '{s}' mismatching global types", .{name.slice(wasm)});
870 gop.value_ptr.source_location.addNote(wasm, &err, "type {s} here", .{@tagName(existing_ty.valtype)});870 gop.value_ptr.source_location.addNote(wasm, &err, "type {s} here", .{@tagName(existing_ty.valtype)});
871 source_location.addNote(wasm, &err, "type {s} here", .{@tagName(ptr.valtype)});871 err.addNote("{}: type {s} here", .{ path, @tagName(ptr.valtype) });
872 continue;872 continue;
873 }873 }
874 if (ptr.mutable != existing_ty.mutable) {874 if (ptr.mutable != existing_ty.mutable) {
...@@ -877,8 +877,8 @@ pub fn parse(...@@ -877,8 +877,8 @@ pub fn parse(
877 gop.value_ptr.source_location.addNote(wasm, &err, "{s} here", .{877 gop.value_ptr.source_location.addNote(wasm, &err, "{s} here", .{
878 if (existing_ty.mutable) "mutable" else "not mutable",878 if (existing_ty.mutable) "mutable" else "not mutable",
879 });879 });
880 source_location.addNote(wasm, &err, "{s} here", .{880 err.addNote("{}: {s} here", .{
881 if (ptr.mutable) "mutable" else "not mutable",881 path, if (ptr.mutable) "mutable" else "not mutable",
882 });882 });
883 continue;883 continue;
884 }884 }
...@@ -890,7 +890,7 @@ pub fn parse(...@@ -890,7 +890,7 @@ pub fn parse(
890 } else {890 } else {
891 gop.value_ptr.source_location.addNote(wasm, &err, "no module here", .{});891 gop.value_ptr.source_location.addNote(wasm, &err, "no module here", .{});
892 }892 }
893 source_location.addNote(wasm, &err, "module '{s}' here", .{ptr.module_name.slice(wasm)});893 err.addNote("{}: module '{s}' here", .{ path, ptr.module_name.slice(wasm) });
894 continue;894 continue;
895 }895 }
896 if (symbol.flags.binding == .strong) gop.value_ptr.flags.binding = .strong;896 if (symbol.flags.binding == .strong) gop.value_ptr.flags.binding = .strong;
...@@ -925,7 +925,7 @@ pub fn parse(...@@ -925,7 +925,7 @@ pub fn parse(
925 ptr.type_index.fmt(wasm),925 ptr.type_index.fmt(wasm),
926 });926 });
927 const word = if (gop.value_ptr.resolution == .unresolved) "imported" else "exported";927 const word = if (gop.value_ptr.resolution == .unresolved) "imported" else "exported";
928 source_location.addNote(wasm, &err, "{s} as {} here", .{ word, gop.value_ptr.type.fmt(wasm) });928 err.addNote("{}: {s} as {} here", .{ path, word, gop.value_ptr.type.fmt(wasm) });
929 continue;929 continue;
930 }930 }
931 if (gop.value_ptr.resolution == .unresolved or gop.value_ptr.flags.binding == .weak) {931 if (gop.value_ptr.resolution == .unresolved or gop.value_ptr.flags.binding == .weak) {
...@@ -938,7 +938,7 @@ pub fn parse(...@@ -938,7 +938,7 @@ pub fn parse(
938 var err = try diags.addErrorWithNotes(2);938 var err = try diags.addErrorWithNotes(2);
939 try err.addMsg("symbol collision: {s}", .{name.slice(wasm)});939 try err.addMsg("symbol collision: {s}", .{name.slice(wasm)});
940 gop.value_ptr.source_location.addNote(wasm, &err, "exported as {} here", .{ptr.type_index.fmt(wasm)});940 gop.value_ptr.source_location.addNote(wasm, &err, "exported as {} here", .{ptr.type_index.fmt(wasm)});
941 source_location.addNote(wasm, &err, "exported as {} here", .{gop.value_ptr.type.fmt(wasm)});941 err.addNote("{}: exported as {} here", .{ path, gop.value_ptr.type.fmt(wasm) });
942 continue;942 continue;
943 } else {943 } else {
944 gop.value_ptr.* = .{944 gop.value_ptr.* = .{
...@@ -993,7 +993,7 @@ pub fn parse(...@@ -993,7 +993,7 @@ pub fn parse(
993 inline .function, .table, .memory, .global => |index| {993 inline .function, .table, .memory, .global => |index| {
994 const ptr = index.ptr(wasm);994 const ptr = index.ptr(wasm);
995 if (ptr.name == .none) {995 if (ptr.name == .none) {
996 // Missng symbol table entry; use defaults for exported things.996 // Missing symbol table entry; use defaults for exported things.
997 ptr.name = exp.name.toOptional();997 ptr.name = exp.name.toOptional();
998 ptr.flags.exported = true;998 ptr.flags.exported = true;
999 }999 }