@zigc/lib 0.17.0-dev.228 → 0.17.0-dev.248
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/build_runner.zig +1 -1
- package/compiler/reduce/Walk.zig +1 -6
- package/compiler/resinator/cvtres.zig +4 -4
- package/compiler/resinator/ico.zig +4 -4
- package/compiler/resinator/parse.zig +2 -2
- package/compiler/resinator/res.zig +1 -1
- package/compiler/std-docs.zig +1 -1
- package/compiler/translate-c/ast.zig +11 -21
- package/compiler_rt/atomics.zig +1 -1
- package/compiler_rt/ssp.zig +2 -2
- package/docs/wasm/Walk.zig +1 -3
- package/docs/wasm/html_render.zig +1 -2
- package/package.json +1 -1
- package/std/Io/Reader.zig +0 -5
- package/std/Io/Threaded.zig +4 -4
- package/std/Io/Writer.zig +1 -2
- package/std/Io/net/HostName.zig +11 -6
- package/std/Random/ChaCha.zig +2 -2
- package/std/Random/benchmark.zig +2 -2
- package/std/Thread.zig +2 -2
- package/std/base64.zig +5 -5
- package/std/bit_set.zig +7 -7
- package/std/c.zig +17 -17
- package/std/compress/flate/Decompress.zig +1 -1
- package/std/crypto/25519/curve25519.zig +2 -2
- package/std/crypto/25519/edwards25519.zig +3 -3
- package/std/crypto/25519/ristretto255.zig +2 -2
- package/std/crypto/25519/scalar.zig +6 -6
- package/std/crypto/25519/x25519.zig +1 -1
- package/std/crypto/Certificate.zig +1 -1
- package/std/crypto/Sha1.zig +1 -1
- package/std/crypto/aegis.zig +45 -39
- package/std/crypto/aes_ccm.zig +20 -20
- package/std/crypto/aes_gcm.zig +10 -12
- package/std/crypto/aes_ocb.zig +9 -9
- package/std/crypto/argon2.zig +15 -15
- package/std/crypto/bcrypt.zig +20 -10
- package/std/crypto/benchmark.zig +7 -7
- package/std/crypto/blake2.zig +100 -64
- package/std/crypto/cbc_mac.zig +1 -1
- package/std/crypto/chacha20.zig +10 -10
- package/std/crypto/cmac.zig +2 -2
- package/std/crypto/codecs/asn1.zig +1 -1
- package/std/crypto/ecdsa.zig +9 -9
- package/std/crypto/ff.zig +2 -2
- package/std/crypto/ghash_polyval.zig +4 -4
- package/std/crypto/hkdf.zig +1 -1
- package/std/crypto/isap.zig +3 -3
- package/std/crypto/kangarootwelve.zig +1 -1
- package/std/crypto/keccak_p.zig +7 -7
- package/std/crypto/md5.zig +1 -1
- package/std/crypto/ml_dsa.zig +33 -33
- package/std/crypto/ml_kem.zig +4 -4
- package/std/crypto/modes.zig +1 -1
- package/std/crypto/pbkdf2.zig +1 -1
- package/std/crypto/pcurves/p256/scalar.zig +3 -3
- package/std/crypto/pcurves/p384/scalar.zig +2 -2
- package/std/crypto/pcurves/secp256k1/scalar.zig +3 -3
- package/std/crypto/pcurves/tests/p256.zig +5 -5
- package/std/crypto/pcurves/tests/p384.zig +5 -5
- package/std/crypto/pcurves/tests/secp256k1.zig +3 -3
- package/std/crypto/salsa20.zig +8 -8
- package/std/crypto/sha2.zig +2 -2
- package/std/crypto/sha3.zig +2 -2
- package/std/crypto/siphash.zig +1 -1
- package/std/crypto/timing_safe.zig +5 -4
- package/std/crypto/tls/Client.zig +10 -9
- package/std/crypto.zig +3 -3
- package/std/debug/Dwarf.zig +1 -1
- package/std/debug.zig +6 -4
- package/std/elf.zig +1 -1
- package/std/enums.zig +1 -1
- package/std/fmt/parse_float/decimal.zig +1 -1
- package/std/fmt.zig +5 -1
- package/std/hash/Adler32.zig +3 -3
- package/std/hash/benchmark.zig +2 -2
- package/std/hash/wyhash.zig +1 -1
- package/std/heap/debug_allocator.zig +1 -1
- package/std/heap/memory_pool.zig +34 -197
- package/std/heap.zig +0 -7
- package/std/http.zig +1 -1
- package/std/json/static.zig +2 -2
- package/std/math/big/int.zig +3 -3
- package/std/math/nextafter.zig +1 -2
- package/std/math/powi.zig +2 -3
- package/std/math/signbit.zig +0 -1
- package/std/math.zig +12 -18
- package/std/mem.zig +9 -8
- package/std/meta.zig +1 -1
- package/std/multi_array_list.zig +24 -0
- package/std/os/emscripten.zig +2 -2
- package/std/os/linux.zig +4 -4
- package/std/os/uefi/hii.zig +1 -1
- package/std/tar/Writer.zig +39 -33
- package/std/tar.zig +8 -4
- package/std/unicode.zig +13 -8
- package/std/zig/Ast/Render.zig +1 -25
- package/std/zig/Ast.zig +5 -28
- package/std/zig/AstGen.zig +75 -184
- package/std/zig/AstRlAnnotate.zig +1 -11
- package/std/zig/AstSmith.zig +5 -11
- package/std/zig/LibCInstallation.zig +1 -1
- package/std/zig/Parse.zig +4 -69
- package/std/zig/TokenSmith.zig +0 -6
- package/std/zig/WindowsSdk.zig +1 -1
- package/std/zig/Zir.zig +0 -54
- package/std/zig/ZonGen.zig +0 -1
- package/std/zig/llvm/Builder.zig +5 -9
- package/std/zig/tokenizer.zig +4 -43
- package/std/zig.zig +0 -2
package/std/zig/AstGen.zig
CHANGED
|
@@ -507,7 +507,6 @@ fn lvalExpr(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Ins
|
|
|
507
507
|
.less_than,
|
|
508
508
|
.less_or_equal,
|
|
509
509
|
.array_cat,
|
|
510
|
-
.array_mult,
|
|
511
510
|
.bool_and,
|
|
512
511
|
.bool_or,
|
|
513
512
|
.@"asm",
|
|
@@ -777,19 +776,6 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE
|
|
|
777
776
|
.less_or_equal => return simpleBinOp(gz, scope, ri, node, .cmp_lte),
|
|
778
777
|
.array_cat => return simpleBinOp(gz, scope, ri, node, .array_cat),
|
|
779
778
|
|
|
780
|
-
.array_mult => {
|
|
781
|
-
// This syntax form does not currently use the result type in the language specification.
|
|
782
|
-
// However, the result type can be used to emit more optimal code for large multiplications by
|
|
783
|
-
// having Sema perform a coercion before the multiplication operation.
|
|
784
|
-
const lhs_node, const rhs_node = tree.nodeData(node).node_and_node;
|
|
785
|
-
const result = try gz.addPlNode(.array_mul, node, Zir.Inst.ArrayMul{
|
|
786
|
-
.res_ty = if (try ri.rl.resultType(gz, node)) |t| t else .none,
|
|
787
|
-
.lhs = try expr(gz, scope, .{ .rl = .none }, lhs_node),
|
|
788
|
-
.rhs = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .usize_type } }, rhs_node, .array_mul_factor),
|
|
789
|
-
});
|
|
790
|
-
return rvalue(gz, ri, result, node);
|
|
791
|
-
},
|
|
792
|
-
|
|
793
779
|
.error_union, .merge_error_sets => |tag| {
|
|
794
780
|
const inst_tag: Zir.Inst.Tag = switch (tag) {
|
|
795
781
|
.error_union => .error_union_type,
|
|
@@ -2713,7 +2699,6 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As
|
|
|
2713
2699
|
.alloc_inferred_comptime_mut,
|
|
2714
2700
|
.make_ptr_const,
|
|
2715
2701
|
.array_cat,
|
|
2716
|
-
.array_mul,
|
|
2717
2702
|
.array_type,
|
|
2718
2703
|
.array_type_sentinel,
|
|
2719
2704
|
.elem_type,
|
|
@@ -2875,7 +2860,6 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As
|
|
|
2875
2860
|
.max,
|
|
2876
2861
|
.min,
|
|
2877
2862
|
.@"resume",
|
|
2878
|
-
.ret_err_value_code,
|
|
2879
2863
|
.ret_ptr,
|
|
2880
2864
|
.ret_type,
|
|
2881
2865
|
.for_len,
|
|
@@ -2964,7 +2948,6 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As
|
|
|
2964
2948
|
=> break :b true,
|
|
2965
2949
|
|
|
2966
2950
|
.@"defer" => unreachable,
|
|
2967
|
-
.defer_err_code => unreachable,
|
|
2968
2951
|
}
|
|
2969
2952
|
} else switch (maybe_unused_result) {
|
|
2970
2953
|
.none => unreachable,
|
|
@@ -2984,60 +2967,28 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As
|
|
|
2984
2967
|
return noreturn_src_node;
|
|
2985
2968
|
}
|
|
2986
2969
|
|
|
2987
|
-
fn
|
|
2988
|
-
have_any: bool,
|
|
2989
|
-
have_normal: bool,
|
|
2990
|
-
have_err: bool,
|
|
2991
|
-
need_err_code: bool,
|
|
2992
|
-
} {
|
|
2993
|
-
var have_normal = false;
|
|
2994
|
-
var have_err = false;
|
|
2995
|
-
var need_err_code = false;
|
|
2970
|
+
fn anyErrdefers(outer_scope: *Scope, inner_scope: *Scope) bool {
|
|
2996
2971
|
var scope = inner_scope;
|
|
2997
2972
|
while (scope != outer_scope) {
|
|
2998
2973
|
switch (scope.unwrap()) {
|
|
2999
2974
|
.gen_zir => |gen_zir| scope = gen_zir.parent,
|
|
3000
2975
|
.local_val => |local_val| scope = local_val.parent,
|
|
3001
2976
|
.local_ptr => |local_ptr| scope = local_ptr.parent,
|
|
3002
|
-
.defer_normal => |
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
have_normal = true;
|
|
3006
|
-
},
|
|
3007
|
-
.defer_error => |defer_scope| {
|
|
3008
|
-
scope = defer_scope.parent;
|
|
3009
|
-
|
|
3010
|
-
have_err = true;
|
|
3011
|
-
|
|
3012
|
-
const have_err_payload = defer_scope.remapped_err_code != .none;
|
|
3013
|
-
need_err_code = need_err_code or have_err_payload;
|
|
3014
|
-
},
|
|
2977
|
+
.defer_normal => |defer_normal| scope = defer_normal.parent,
|
|
2978
|
+
.defer_error => return true,
|
|
3015
2979
|
.namespace => unreachable,
|
|
3016
2980
|
.top => unreachable,
|
|
3017
2981
|
}
|
|
3018
2982
|
}
|
|
3019
|
-
return
|
|
3020
|
-
.have_any = have_normal or have_err,
|
|
3021
|
-
.have_normal = have_normal,
|
|
3022
|
-
.have_err = have_err,
|
|
3023
|
-
.need_err_code = need_err_code,
|
|
3024
|
-
};
|
|
2983
|
+
return false;
|
|
3025
2984
|
}
|
|
3026
2985
|
|
|
3027
|
-
const DefersToEmit = union(enum) {
|
|
3028
|
-
both: Zir.Inst.Ref, // err code
|
|
3029
|
-
both_sans_err,
|
|
3030
|
-
normal_only,
|
|
3031
|
-
};
|
|
3032
|
-
|
|
3033
2986
|
fn genDefers(
|
|
3034
2987
|
gz: *GenZir,
|
|
3035
2988
|
outer_scope: *Scope,
|
|
3036
2989
|
inner_scope: *Scope,
|
|
3037
|
-
which_ones:
|
|
2990
|
+
which_ones: enum { normal_only, normal_and_error },
|
|
3038
2991
|
) InnerError!void {
|
|
3039
|
-
const gpa = gz.astgen.gpa;
|
|
3040
|
-
|
|
3041
2992
|
var scope = inner_scope;
|
|
3042
2993
|
while (scope != outer_scope) {
|
|
3043
2994
|
switch (scope.unwrap()) {
|
|
@@ -3051,33 +3002,10 @@ fn genDefers(
|
|
|
3051
3002
|
.defer_error => |defer_scope| {
|
|
3052
3003
|
scope = defer_scope.parent;
|
|
3053
3004
|
switch (which_ones) {
|
|
3054
|
-
.
|
|
3005
|
+
.normal_only => continue,
|
|
3006
|
+
.normal_and_error => {
|
|
3055
3007
|
try gz.addDefer(defer_scope.index, defer_scope.len);
|
|
3056
3008
|
},
|
|
3057
|
-
.both => |err_code| {
|
|
3058
|
-
if (defer_scope.remapped_err_code.unwrap()) |remapped_err_code| {
|
|
3059
|
-
try gz.instructions.ensureUnusedCapacity(gpa, 1);
|
|
3060
|
-
try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);
|
|
3061
|
-
|
|
3062
|
-
const payload_index = try gz.astgen.addExtra(Zir.Inst.DeferErrCode{
|
|
3063
|
-
.remapped_err_code = remapped_err_code,
|
|
3064
|
-
.index = defer_scope.index,
|
|
3065
|
-
.len = defer_scope.len,
|
|
3066
|
-
});
|
|
3067
|
-
const new_index: Zir.Inst.Index = @enumFromInt(gz.astgen.instructions.len);
|
|
3068
|
-
gz.astgen.instructions.appendAssumeCapacity(.{
|
|
3069
|
-
.tag = .defer_err_code,
|
|
3070
|
-
.data = .{ .defer_err_code = .{
|
|
3071
|
-
.err_code = err_code,
|
|
3072
|
-
.payload_index = payload_index,
|
|
3073
|
-
} },
|
|
3074
|
-
});
|
|
3075
|
-
gz.instructions.appendAssumeCapacity(new_index);
|
|
3076
|
-
} else {
|
|
3077
|
-
try gz.addDefer(defer_scope.index, defer_scope.len);
|
|
3078
|
-
}
|
|
3079
|
-
},
|
|
3080
|
-
.normal_only => continue,
|
|
3081
3009
|
}
|
|
3082
3010
|
},
|
|
3083
3011
|
.namespace => unreachable,
|
|
@@ -3140,46 +3068,17 @@ fn deferStmt(
|
|
|
3140
3068
|
defer defer_gen.unstack();
|
|
3141
3069
|
|
|
3142
3070
|
const tree = gz.astgen.tree;
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
const payload_token = tree.nodeData(node).opt_token_and_node[0].unwrap() orelse break :blk &defer_gen.base;
|
|
3147
|
-
const ident_name = try gz.astgen.identAsString(payload_token);
|
|
3148
|
-
if (std.mem.eql(u8, tree.tokenSlice(payload_token), "_")) {
|
|
3149
|
-
try gz.astgen.appendErrorTok(payload_token, "discard of error capture; omit it instead", .{});
|
|
3150
|
-
break :blk &defer_gen.base;
|
|
3151
|
-
}
|
|
3152
|
-
const remapped_err_code: Zir.Inst.Index = @enumFromInt(gz.astgen.instructions.len);
|
|
3153
|
-
opt_remapped_err_code = remapped_err_code.toOptional();
|
|
3154
|
-
_ = try gz.astgen.appendPlaceholder();
|
|
3155
|
-
const remapped_err_code_ref = remapped_err_code.toRef();
|
|
3156
|
-
local_val_scope = .{
|
|
3157
|
-
.parent = &defer_gen.base,
|
|
3158
|
-
.gen_zir = gz,
|
|
3159
|
-
.name = ident_name,
|
|
3160
|
-
.inst = remapped_err_code_ref,
|
|
3161
|
-
.token_src = payload_token,
|
|
3162
|
-
.id_cat = .capture,
|
|
3163
|
-
};
|
|
3164
|
-
try gz.addDbgVar(.dbg_var_val, ident_name, remapped_err_code_ref);
|
|
3165
|
-
break :blk &local_val_scope.base;
|
|
3166
|
-
};
|
|
3167
|
-
const expr_node = switch (scope_tag) {
|
|
3168
|
-
.defer_normal => tree.nodeData(node).node,
|
|
3169
|
-
.defer_error => tree.nodeData(node).opt_token_and_node[1],
|
|
3170
|
-
else => unreachable,
|
|
3171
|
-
};
|
|
3172
|
-
_ = try unusedResultExpr(&defer_gen, sub_scope, expr_node);
|
|
3173
|
-
try checkUsed(gz, scope, sub_scope);
|
|
3071
|
+
const expr_node = tree.nodeData(node).node;
|
|
3072
|
+
_ = try unusedResultExpr(&defer_gen, &defer_gen.base, expr_node);
|
|
3073
|
+
try checkUsed(gz, scope, &defer_gen.base);
|
|
3174
3074
|
_ = try defer_gen.addBreak(.break_inline, @enumFromInt(0), .void_value);
|
|
3175
3075
|
|
|
3176
3076
|
const body = defer_gen.instructionsSlice();
|
|
3177
|
-
const
|
|
3178
|
-
const body_len = gz.astgen.countBodyLenAfterFixupsExtraRefs(body, extra_insts);
|
|
3077
|
+
const body_len = gz.astgen.countBodyLenAfterFixupsExtraRefs(body, &.{});
|
|
3179
3078
|
|
|
3180
3079
|
const index: u32 = @intCast(gz.astgen.extra.items.len);
|
|
3181
3080
|
try gz.astgen.extra.ensureUnusedCapacity(gz.astgen.gpa, body_len);
|
|
3182
|
-
gz.astgen.appendBodyWithFixupsExtraRefsArrayList(&gz.astgen.extra, body,
|
|
3081
|
+
gz.astgen.appendBodyWithFixupsExtraRefsArrayList(&gz.astgen.extra, body, &.{});
|
|
3183
3082
|
|
|
3184
3083
|
const defer_scope = try block_arena.create(Scope.Defer);
|
|
3185
3084
|
|
|
@@ -3188,7 +3087,6 @@ fn deferStmt(
|
|
|
3188
3087
|
.parent = scope,
|
|
3189
3088
|
.index = index,
|
|
3190
3089
|
.len = body_len,
|
|
3191
|
-
.remapped_err_code = opt_remapped_err_code,
|
|
3192
3090
|
};
|
|
3193
3091
|
return &defer_scope.base;
|
|
3194
3092
|
}
|
|
@@ -4882,7 +4780,7 @@ fn testDecl(
|
|
|
4882
4780
|
.noalias_bits = 0,
|
|
4883
4781
|
|
|
4884
4782
|
// Tests don't have a prototype that needs hashing
|
|
4885
|
-
.proto_hash =
|
|
4783
|
+
.proto_hash = @splat(0),
|
|
4886
4784
|
});
|
|
4887
4785
|
|
|
4888
4786
|
_ = try decl_block.addBreak(.break_inline, decl_inst, func_inst);
|
|
@@ -5882,7 +5780,7 @@ fn tryExpr(
|
|
|
5882
5780
|
else => Zir.Inst.Tag.err_union_code,
|
|
5883
5781
|
};
|
|
5884
5782
|
const err_code = try else_scope.addUnNode(err_tag, operand, node);
|
|
5885
|
-
try genDefers(&else_scope, &fn_block.base, scope, .
|
|
5783
|
+
try genDefers(&else_scope, &fn_block.base, scope, .normal_and_error);
|
|
5886
5784
|
try emitDbgStmt(&else_scope, try_lc);
|
|
5887
5785
|
_ = try else_scope.addUnNode(.ret_node, err_code, node);
|
|
5888
5786
|
|
|
@@ -8033,18 +7931,10 @@ fn ret(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Inst.Ref
|
|
|
8033
7931
|
// for detecting whether to add something to the function's inferred error set.
|
|
8034
7932
|
const ident_token = tree.nodeMainToken(operand_node) + 2;
|
|
8035
7933
|
const err_name_str_index = try astgen.identAsString(ident_token);
|
|
8036
|
-
|
|
8037
|
-
if (!defer_counts.need_err_code) {
|
|
8038
|
-
try genDefers(gz, defer_outer, scope, .both_sans_err);
|
|
8039
|
-
try emitDbgStmt(gz, ret_lc);
|
|
8040
|
-
_ = try gz.addStrTok(.ret_err_value, err_name_str_index, ident_token);
|
|
8041
|
-
return Zir.Inst.Ref.unreachable_value;
|
|
8042
|
-
}
|
|
8043
|
-
const err_code = try gz.addStrTok(.ret_err_value_code, err_name_str_index, ident_token);
|
|
8044
|
-
try genDefers(gz, defer_outer, scope, .{ .both = err_code });
|
|
7934
|
+
try genDefers(gz, defer_outer, scope, .normal_and_error);
|
|
8045
7935
|
try emitDbgStmt(gz, ret_lc);
|
|
8046
|
-
_ = try gz.
|
|
8047
|
-
return
|
|
7936
|
+
_ = try gz.addStrTok(.ret_err_value, err_name_str_index, ident_token);
|
|
7937
|
+
return .unreachable_value;
|
|
8048
7938
|
}
|
|
8049
7939
|
|
|
8050
7940
|
const ri: ResultInfo = if (astgen.nodes_need_rl.contains(node)) .{
|
|
@@ -8071,15 +7961,13 @@ fn ret(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Inst.Ref
|
|
|
8071
7961
|
},
|
|
8072
7962
|
.always => {
|
|
8073
7963
|
// Value is always an error. Emit both error defers and regular defers.
|
|
8074
|
-
|
|
8075
|
-
try genDefers(gz, defer_outer, scope, .{ .both = err_code });
|
|
7964
|
+
try genDefers(gz, defer_outer, scope, .normal_and_error);
|
|
8076
7965
|
try emitDbgStmt(gz, ret_lc);
|
|
8077
7966
|
try gz.addRet(ri, operand, node);
|
|
8078
7967
|
return Zir.Inst.Ref.unreachable_value;
|
|
8079
7968
|
},
|
|
8080
7969
|
.maybe => {
|
|
8081
|
-
|
|
8082
|
-
if (!defer_counts.have_err) {
|
|
7970
|
+
if (!anyErrdefers(defer_outer, scope)) {
|
|
8083
7971
|
// Only regular defers; no branch needed.
|
|
8084
7972
|
try genDefers(gz, defer_outer, scope, .normal_only);
|
|
8085
7973
|
try emitDbgStmt(gz, ret_lc);
|
|
@@ -8111,10 +7999,7 @@ fn ret(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Inst.Ref
|
|
|
8111
7999
|
var else_scope = gz.makeSubBlock(scope);
|
|
8112
8000
|
defer else_scope.unstack();
|
|
8113
8001
|
|
|
8114
|
-
|
|
8115
|
-
.both = try else_scope.addUnNode(.err_union_code, result, node),
|
|
8116
|
-
};
|
|
8117
|
-
try genDefers(&else_scope, defer_outer, scope, which_ones);
|
|
8002
|
+
try genDefers(&else_scope, defer_outer, scope, .normal_and_error);
|
|
8118
8003
|
try emitDbgStmt(&else_scope, ret_lc);
|
|
8119
8004
|
try else_scope.addRet(ri, operand, node);
|
|
8120
8005
|
|
|
@@ -8173,39 +8058,42 @@ fn identifier(
|
|
|
8173
8058
|
return rvalue(gz, ri, zir_const_ref, ident);
|
|
8174
8059
|
}
|
|
8175
8060
|
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
const
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
"primitive integer type '{s}' exceeds maximum bit width of 65535",
|
|
8195
|
-
.{ident_name_raw},
|
|
8196
|
-
),
|
|
8197
|
-
error.InvalidCharacter => break :integer,
|
|
8198
|
-
};
|
|
8199
|
-
const result = try gz.add(.{
|
|
8200
|
-
.tag = .int_type,
|
|
8201
|
-
.data = .{ .int_type = .{
|
|
8202
|
-
.src_node = gz.nodeIndexToRelative(ident),
|
|
8203
|
-
.signedness = signedness,
|
|
8204
|
-
.bit_count = bit_count,
|
|
8205
|
-
} },
|
|
8206
|
-
});
|
|
8207
|
-
return rvalue(gz, ri, result, ident);
|
|
8061
|
+
int_type: {
|
|
8062
|
+
if (ident_name_raw.len < 2) break :int_type;
|
|
8063
|
+
const signedness: std.builtin.Signedness = switch (ident_name_raw[0]) {
|
|
8064
|
+
'u' => .unsigned,
|
|
8065
|
+
'i' => .signed,
|
|
8066
|
+
else => break :int_type,
|
|
8067
|
+
};
|
|
8068
|
+
// `u0` already handled by `primitive_instrs`
|
|
8069
|
+
if (std.mem.eql(u8, ident_name_raw, "i0")) {
|
|
8070
|
+
return astgen.failNode(ident, "signed integer cannot have bit width 0", .{});
|
|
8071
|
+
}
|
|
8072
|
+
if (ident_name_raw[1] == '0') {
|
|
8073
|
+
assert(ident_name_raw.len >= 3); // `u0` and `i0` handled
|
|
8074
|
+
return astgen.failNode(
|
|
8075
|
+
ident,
|
|
8076
|
+
"primitive integer type '{s}' has leading zero",
|
|
8077
|
+
.{ident_name_raw},
|
|
8078
|
+
);
|
|
8208
8079
|
}
|
|
8080
|
+
const bit_count = parseBitCount(ident_name_raw[1..]) catch |err| switch (err) {
|
|
8081
|
+
error.Overflow => return astgen.failNode(
|
|
8082
|
+
ident,
|
|
8083
|
+
"primitive integer type '{s}' exceeds maximum bit width of 65535",
|
|
8084
|
+
.{ident_name_raw},
|
|
8085
|
+
),
|
|
8086
|
+
error.InvalidCharacter => break :int_type,
|
|
8087
|
+
};
|
|
8088
|
+
const result = try gz.add(.{
|
|
8089
|
+
.tag = .int_type,
|
|
8090
|
+
.data = .{ .int_type = .{
|
|
8091
|
+
.src_node = gz.nodeIndexToRelative(ident),
|
|
8092
|
+
.signedness = signedness,
|
|
8093
|
+
.bit_count = bit_count,
|
|
8094
|
+
} },
|
|
8095
|
+
});
|
|
8096
|
+
return rvalue(gz, ri, result, ident);
|
|
8209
8097
|
}
|
|
8210
8098
|
}
|
|
8211
8099
|
|
|
@@ -10222,32 +10110,37 @@ const primitive_instrs = std.StaticStringMap(Zir.Inst.Ref).initComptime(.{
|
|
|
10222
10110
|
.{ "c_ushort", .c_ushort_type },
|
|
10223
10111
|
.{ "comptime_float", .comptime_float_type },
|
|
10224
10112
|
.{ "comptime_int", .comptime_int_type },
|
|
10225
|
-
.{ "f128", .f128_type },
|
|
10226
|
-
.{ "f16", .f16_type },
|
|
10227
|
-
.{ "f32", .f32_type },
|
|
10228
|
-
.{ "f64", .f64_type },
|
|
10229
|
-
.{ "f80", .f80_type },
|
|
10230
10113
|
.{ "false", .bool_false },
|
|
10231
|
-
.{ "i16", .i16_type },
|
|
10232
|
-
.{ "i32", .i32_type },
|
|
10233
|
-
.{ "i64", .i64_type },
|
|
10234
|
-
.{ "i128", .i128_type },
|
|
10235
|
-
.{ "i8", .i8_type },
|
|
10236
|
-
.{ "isize", .isize_type },
|
|
10237
10114
|
.{ "noreturn", .noreturn_type },
|
|
10238
10115
|
.{ "null", .null_value },
|
|
10239
10116
|
.{ "true", .bool_true },
|
|
10240
10117
|
.{ "type", .type_type },
|
|
10118
|
+
.{ "undefined", .undef },
|
|
10119
|
+
.{ "void", .void_type },
|
|
10120
|
+
|
|
10121
|
+
.{ "f16", .f16_type },
|
|
10122
|
+
.{ "f32", .f32_type },
|
|
10123
|
+
.{ "f64", .f64_type },
|
|
10124
|
+
.{ "f80", .f80_type },
|
|
10125
|
+
.{ "f128", .f128_type },
|
|
10126
|
+
|
|
10127
|
+
.{ "u0", .u0_type },
|
|
10128
|
+
.{ "u1", .u1_type },
|
|
10129
|
+
.{ "u8", .u8_type },
|
|
10130
|
+
.{ "i8", .i8_type },
|
|
10241
10131
|
.{ "u16", .u16_type },
|
|
10132
|
+
.{ "i16", .i16_type },
|
|
10242
10133
|
.{ "u29", .u29_type },
|
|
10243
10134
|
.{ "u32", .u32_type },
|
|
10135
|
+
.{ "i32", .i32_type },
|
|
10244
10136
|
.{ "u64", .u64_type },
|
|
10137
|
+
.{ "i64", .i64_type },
|
|
10138
|
+
.{ "u80", .u80_type },
|
|
10245
10139
|
.{ "u128", .u128_type },
|
|
10246
|
-
.{ "
|
|
10247
|
-
.{ "
|
|
10248
|
-
.{ "undefined", .undef },
|
|
10140
|
+
.{ "i128", .i128_type },
|
|
10141
|
+
.{ "u256", .u256_type },
|
|
10249
10142
|
.{ "usize", .usize_type },
|
|
10250
|
-
.{ "
|
|
10143
|
+
.{ "isize", .isize_type },
|
|
10251
10144
|
});
|
|
10252
10145
|
|
|
10253
10146
|
comptime {
|
|
@@ -10399,7 +10292,6 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) BuiltinFn.Ev
|
|
|
10399
10292
|
.add_wrap,
|
|
10400
10293
|
.add_sat,
|
|
10401
10294
|
.array_cat,
|
|
10402
|
-
.array_mult,
|
|
10403
10295
|
.assign,
|
|
10404
10296
|
.assign_destructure,
|
|
10405
10297
|
.assign_bit_and,
|
|
@@ -11239,7 +11131,6 @@ const Scope = struct {
|
|
|
11239
11131
|
parent: *Scope,
|
|
11240
11132
|
index: u32,
|
|
11241
11133
|
len: u32,
|
|
11242
|
-
remapped_err_code: Zir.Inst.OptionalIndex = .none,
|
|
11243
11134
|
};
|
|
11244
11135
|
|
|
11245
11136
|
/// Represents a global scope that has any number of declarations in it.
|
|
@@ -141,11 +141,7 @@ fn expr(astrl: *AstRlAnnotate, node: Ast.Node.Index, block: ?*Block, ri: ResultI
|
|
|
141
141
|
.asm_input,
|
|
142
142
|
=> unreachable,
|
|
143
143
|
|
|
144
|
-
.@"errdefer" => {
|
|
145
|
-
_ = try astrl.expr(tree.nodeData(node).opt_token_and_node[1], block, ResultInfo.none);
|
|
146
|
-
return false;
|
|
147
|
-
},
|
|
148
|
-
.@"defer" => {
|
|
144
|
+
.@"defer", .@"errdefer" => {
|
|
149
145
|
_ = try astrl.expr(tree.nodeData(node).node, block, ResultInfo.none);
|
|
150
146
|
return false;
|
|
151
147
|
},
|
|
@@ -273,12 +269,6 @@ fn expr(astrl: *AstRlAnnotate, node: Ast.Node.Index, block: ?*Block, ri: ResultI
|
|
|
273
269
|
return false;
|
|
274
270
|
},
|
|
275
271
|
|
|
276
|
-
.array_mult => {
|
|
277
|
-
const lhs, const rhs = tree.nodeData(node).node_and_node;
|
|
278
|
-
_ = try astrl.expr(lhs, block, ResultInfo.none);
|
|
279
|
-
_ = try astrl.expr(rhs, block, ResultInfo.type_only);
|
|
280
|
-
return false;
|
|
281
|
-
},
|
|
282
272
|
.error_union, .merge_error_sets => {
|
|
283
273
|
const lhs, const rhs = tree.nodeData(node).node_and_node;
|
|
284
274
|
_ = try astrl.expr(lhs, block, ResultInfo.none);
|
package/std/zig/AstSmith.zig
CHANGED
|
@@ -18,7 +18,6 @@ token_tag_buf: [2048]Token.Tag,
|
|
|
18
18
|
token_start_buf: [2048]std.zig.Ast.ByteOffset,
|
|
19
19
|
tokens_len: usize,
|
|
20
20
|
|
|
21
|
-
/// For `.asterisk`, this also includes `.asterisk2`
|
|
22
21
|
not_token: ?Token.Tag,
|
|
23
22
|
not_token_comptime: bool,
|
|
24
23
|
/// ExprSuffix
|
|
@@ -196,7 +195,6 @@ fn preservePegEndOfWord(a: *AstSmith) SourceError!void {
|
|
|
196
195
|
/// Assumes the token has not been written yet
|
|
197
196
|
fn addTokenTag(a: *AstSmith, tag: Token.Tag) SourceError!void {
|
|
198
197
|
assert(tag != a.not_token);
|
|
199
|
-
if (a.not_token == .asterisk) assert(tag != .asterisk_asterisk);
|
|
200
198
|
a.not_token = null;
|
|
201
199
|
|
|
202
200
|
if (a.not_token_comptime) assert(tag != .keyword_comptime);
|
|
@@ -240,9 +238,7 @@ fn pegToken(a: *AstSmith, tag: Token.Tag) SourceError!void {
|
|
|
240
238
|
|
|
241
239
|
switch (lexeme[0]) {
|
|
242
240
|
'_', 'a'...'z', 'A'...'Z', '0'...'9' => try a.preservePegEndOfWord(),
|
|
243
|
-
'*' => if (a.tokens_len > 0 and a.source_buf[a.source_len - 1] == '*'
|
|
244
|
-
a.token_tag_buf[a.tokens_len - 1] != .asterisk_asterisk)
|
|
245
|
-
{
|
|
241
|
+
'*' => if (a.tokens_len > 0 and a.source_buf[a.source_len - 1] == '*') {
|
|
246
242
|
try a.addSourceByte(' ');
|
|
247
243
|
},
|
|
248
244
|
'.' => if (a.tokens_len > 0 and switch (a.source_buf[a.source_len - 1]) {
|
|
@@ -486,7 +482,7 @@ fn pegContainerField(a: *AstSmith) SourceError!void {
|
|
|
486
482
|
/// BlockStatement
|
|
487
483
|
/// <- Statement
|
|
488
484
|
/// / KEYWORD_defer BlockExprStatement
|
|
489
|
-
/// / KEYWORD_errdefer
|
|
485
|
+
/// / KEYWORD_errdefer BlockExprStatement
|
|
490
486
|
/// / !ExprStatement (KEYWORD_comptime !BlockExpr)? VarAssignStatement
|
|
491
487
|
fn pegBlockStatement(a: *AstSmith) SourceError!void {
|
|
492
488
|
const Kind = enum {
|
|
@@ -1723,13 +1719,11 @@ fn pegAdditionOp(a: *AstSmith) SourceError!void {
|
|
|
1723
1719
|
/// / ASTERISK
|
|
1724
1720
|
/// / SLASH
|
|
1725
1721
|
/// / PERCENT
|
|
1726
|
-
/// / ASTERISK2
|
|
1727
1722
|
/// / ASTERISKPERCENT
|
|
1728
1723
|
/// / ASTERISKPIPE
|
|
1729
1724
|
fn pegMultiplyOp(a: *AstSmith) SourceError!void {
|
|
1730
1725
|
const tags = [_]Token.Tag{
|
|
1731
1726
|
.asterisk,
|
|
1732
|
-
.asterisk_asterisk,
|
|
1733
1727
|
.pipe_pipe,
|
|
1734
1728
|
.slash,
|
|
1735
1729
|
.percent,
|
|
@@ -1865,9 +1859,9 @@ fn pegSliceTypeStart(a: *AstSmith) SourceError!void {
|
|
|
1865
1859
|
try a.pegToken(.r_bracket);
|
|
1866
1860
|
}
|
|
1867
1861
|
|
|
1868
|
-
/// SinglePtrTypeStart <- ASTERISK
|
|
1862
|
+
/// SinglePtrTypeStart <- ASTERISK
|
|
1869
1863
|
fn pegSinglePtrTypeStart(a: *AstSmith) SourceError!void {
|
|
1870
|
-
try a.pegToken(
|
|
1864
|
+
try a.pegToken(.asterisk);
|
|
1871
1865
|
}
|
|
1872
1866
|
|
|
1873
1867
|
/// ManyPtrTypeStart <- LBRACKET ASTERISK (LETTERC / COLON Expr)? RBRACKET
|
|
@@ -1889,7 +1883,7 @@ fn pegManyPtrTypeStart(a: *AstSmith) SourceError!void {
|
|
|
1889
1883
|
try a.pegToken(.r_bracket);
|
|
1890
1884
|
}
|
|
1891
1885
|
|
|
1892
|
-
/// ArrayTypeStart <- LBRACKET !
|
|
1886
|
+
/// ArrayTypeStart <- LBRACKET !ASTERISK Expr (COLON Expr)? RBRACKET
|
|
1893
1887
|
fn pegArrayTypeStart(a: *AstSmith) SourceError!void {
|
|
1894
1888
|
try a.pegToken(.l_bracket);
|
|
1895
1889
|
a.not_token = .asterisk;
|
|
@@ -46,7 +46,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const
|
|
|
46
46
|
found: bool,
|
|
47
47
|
allocated: ?[:0]u8,
|
|
48
48
|
};
|
|
49
|
-
var found_keys
|
|
49
|
+
var found_keys: [fields.len]FoundKey = @splat(.{ .found = false, .allocated = null });
|
|
50
50
|
errdefer {
|
|
51
51
|
self = .{};
|
|
52
52
|
for (found_keys) |found_key| {
|
package/std/zig/Parse.zig
CHANGED
|
@@ -909,7 +909,7 @@ fn expectContainerField(p: *Parse) !Node.Index {
|
|
|
909
909
|
/// BlockStatement
|
|
910
910
|
/// <- Statement
|
|
911
911
|
/// / KEYWORD_defer BlockExprStatement
|
|
912
|
-
/// / KEYWORD_errdefer
|
|
912
|
+
/// / KEYWORD_errdefer BlockExprStatement
|
|
913
913
|
/// / !ExprStatement (KEYWORD_comptime !BlockExpr)? VarAssignStatement
|
|
914
914
|
///
|
|
915
915
|
/// Statement
|
|
@@ -975,10 +975,7 @@ fn expectStatement(p: *Parse, is_block_level: bool) Error!Node.Index {
|
|
|
975
975
|
.keyword_errdefer => if (is_block_level) return p.addNode(.{
|
|
976
976
|
.tag = .@"errdefer",
|
|
977
977
|
.main_token = p.nextToken(),
|
|
978
|
-
.data = .{ .
|
|
979
|
-
try p.parsePayload(),
|
|
980
|
-
try p.expectBlockExprStatement(),
|
|
981
|
-
} },
|
|
978
|
+
.data = .{ .node = try p.expectBlockExprStatement() },
|
|
982
979
|
}),
|
|
983
980
|
.keyword_if => return p.expectIfStatement(),
|
|
984
981
|
.keyword_enum, .keyword_struct, .keyword_union => {
|
|
@@ -1612,7 +1609,6 @@ const operTable = std.enums.directEnumArrayDefault(Token.Tag, OperInfo, .{ .prec
|
|
|
1612
1609
|
.asterisk = .{ .prec = 70, .tag = .mul },
|
|
1613
1610
|
.slash = .{ .prec = 70, .tag = .div },
|
|
1614
1611
|
.percent = .{ .prec = 70, .tag = .mod },
|
|
1615
|
-
.asterisk_asterisk = .{ .prec = 70, .tag = .array_mult },
|
|
1616
1612
|
.asterisk_percent = .{ .prec = 70, .tag = .mul_wrap },
|
|
1617
1613
|
.asterisk_pipe = .{ .prec = 70, .tag = .mul_sat },
|
|
1618
1614
|
});
|
|
@@ -1712,11 +1708,11 @@ fn expectPrefixExpr(p: *Parse) Error!Node.Index {
|
|
|
1712
1708
|
///
|
|
1713
1709
|
/// SliceTypeStart <- LBRACKET (COLON Expr)? RBRACKET
|
|
1714
1710
|
///
|
|
1715
|
-
/// SinglePtrTypeStart <- ASTERISK
|
|
1711
|
+
/// SinglePtrTypeStart <- ASTERISK
|
|
1716
1712
|
///
|
|
1717
1713
|
/// ManyPtrTypeStart <- LBRACKET ASTERISK (LETTERC / COLON Expr)? RBRACKET
|
|
1718
1714
|
///
|
|
1719
|
-
/// ArrayTypeStart <- LBRACKET Expr !
|
|
1715
|
+
/// ArrayTypeStart <- LBRACKET Expr !ASTERISK (COLON Expr)? RBRACKET
|
|
1720
1716
|
///
|
|
1721
1717
|
/// BitAlign <- KEYWORD_align LPAREN Expr (COLON Expr COLON Expr)? RPAREN
|
|
1722
1718
|
fn parseTypeExpr(p: *Parse) Error!?Node.Index {
|
|
@@ -1780,59 +1776,6 @@ fn parseTypeExpr(p: *Parse) Error!?Node.Index {
|
|
|
1780
1776
|
});
|
|
1781
1777
|
}
|
|
1782
1778
|
},
|
|
1783
|
-
.asterisk_asterisk => {
|
|
1784
|
-
const asterisk = p.nextToken();
|
|
1785
|
-
const mods = try p.parsePtrModifiers();
|
|
1786
|
-
const elem_type = try p.expectTypeExpr();
|
|
1787
|
-
const inner: Node.Index = inner: {
|
|
1788
|
-
if (mods.bit_range_start != .none) {
|
|
1789
|
-
break :inner try p.addNode(.{
|
|
1790
|
-
.tag = .ptr_type_bit_range,
|
|
1791
|
-
.main_token = asterisk,
|
|
1792
|
-
.data = .{ .extra_and_node = .{
|
|
1793
|
-
try p.addExtra(Node.PtrTypeBitRange{
|
|
1794
|
-
.sentinel = .none,
|
|
1795
|
-
.align_node = mods.align_node.unwrap().?,
|
|
1796
|
-
.addrspace_node = mods.addrspace_node,
|
|
1797
|
-
.bit_range_start = mods.bit_range_start.unwrap().?,
|
|
1798
|
-
.bit_range_end = mods.bit_range_end.unwrap().?,
|
|
1799
|
-
}),
|
|
1800
|
-
elem_type,
|
|
1801
|
-
} },
|
|
1802
|
-
});
|
|
1803
|
-
} else if (mods.addrspace_node != .none) {
|
|
1804
|
-
break :inner try p.addNode(.{
|
|
1805
|
-
.tag = .ptr_type,
|
|
1806
|
-
.main_token = asterisk,
|
|
1807
|
-
.data = .{ .extra_and_node = .{
|
|
1808
|
-
try p.addExtra(Node.PtrType{
|
|
1809
|
-
.sentinel = .none,
|
|
1810
|
-
.align_node = mods.align_node,
|
|
1811
|
-
.addrspace_node = mods.addrspace_node,
|
|
1812
|
-
}),
|
|
1813
|
-
elem_type,
|
|
1814
|
-
} },
|
|
1815
|
-
});
|
|
1816
|
-
} else {
|
|
1817
|
-
break :inner try p.addNode(.{
|
|
1818
|
-
.tag = .ptr_type_aligned,
|
|
1819
|
-
.main_token = asterisk,
|
|
1820
|
-
.data = .{ .opt_node_and_node = .{
|
|
1821
|
-
mods.align_node,
|
|
1822
|
-
elem_type,
|
|
1823
|
-
} },
|
|
1824
|
-
});
|
|
1825
|
-
}
|
|
1826
|
-
};
|
|
1827
|
-
return try p.addNode(.{
|
|
1828
|
-
.tag = .ptr_type_aligned,
|
|
1829
|
-
.main_token = asterisk,
|
|
1830
|
-
.data = .{ .opt_node_and_node = .{
|
|
1831
|
-
.none,
|
|
1832
|
-
inner,
|
|
1833
|
-
} },
|
|
1834
|
-
});
|
|
1835
|
-
},
|
|
1836
1779
|
.l_bracket => switch (p.tokenTag(p.tok_i + 1)) {
|
|
1837
1780
|
.asterisk => {
|
|
1838
1781
|
const l_bracket = p.nextToken();
|
|
@@ -3260,14 +3203,6 @@ fn parseSuffixOp(p: *Parse, lhs: Node.Index) !?Node.Index {
|
|
|
3260
3203
|
.main_token = p.nextToken(),
|
|
3261
3204
|
.data = .{ .node = lhs },
|
|
3262
3205
|
}),
|
|
3263
|
-
.invalid_periodasterisks => {
|
|
3264
|
-
try p.warn(.asterisk_after_ptr_deref);
|
|
3265
|
-
return try p.addNode(.{
|
|
3266
|
-
.tag = .deref,
|
|
3267
|
-
.main_token = p.nextToken(),
|
|
3268
|
-
.data = .{ .node = lhs },
|
|
3269
|
-
});
|
|
3270
|
-
},
|
|
3271
3206
|
.period => switch (p.tokenTag(p.tok_i + 1)) {
|
|
3272
3207
|
.identifier => return try p.addNode(.{
|
|
3273
3208
|
.tag = .field_access,
|
package/std/zig/TokenSmith.zig
CHANGED
|
@@ -57,12 +57,6 @@ pub fn gen(smith: *Smith) TokenSmith {
|
|
|
57
57
|
@memcpy(t.source_buf[t.source_len..][0..lexeme.len], lexeme);
|
|
58
58
|
t.source_len += @intCast(lexeme.len);
|
|
59
59
|
|
|
60
|
-
if (tag == .invalid_periodasterisks) {
|
|
61
|
-
t.tag_buf[t.tags_len] = .asterisk;
|
|
62
|
-
t.start_buf[t.tags_len] = t.source_len - 1;
|
|
63
|
-
t.tags_len += 1;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
60
|
t.source_buf[t.source_len] = '\n';
|
|
67
61
|
t.source_len += 1;
|
|
68
62
|
} else sw: switch (tag) {
|
package/std/zig/WindowsSdk.zig
CHANGED