profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/andrewrk/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
Andrew Kelley andrewrk @ziglang Portland, Oregon https://andrewkelley.me/ Lead developer & president of Zig Software Foundation

AndreaOrru/zen 206

Experimental operating system written in Zig

andrewrk/chem 170

2d canvas-based rapid prototyping game engine

andrewrk/clashos 151

multiplayer arcade game for bare metal Raspberry Pi 3 B+

andrewrk/connect-sse 28

connect middleware for server sent events (EventSource)

andrewrk/connect-static 19

static file server middleware for connect. loads files once at startup and saves gzipped versions in memory

andrewrk/dotfiles 16

linux yo

andrewrk/browserify-lite 13

browserify, minus some of the advanced features and heavy dependencies

andrewrk/connect-nocache 11

connect middleware to insert no cache headers

andrewrk/evo 10

specification, reference implementation, and examples of Evo, the programming language made for being the DNA of genetic algorithms

andrewrk/andrewkelley.me 7

my personal site

pull request commentziglang/zig

Linux/sparc64 bits: Add missing C type definitions

Thank you

koachan

comment created time in an hour

push eventziglang/zig

Koakuma

commit sha bdbd060cc7a150ff2dfe367f3eb08eff6ab319fd

Linux/sparc64 bits: Add missing C type definitions

view details

push time in an hour

PR merged ziglang/zig

Linux/sparc64 bits: Add missing C type definitions

This makes stage1 Zig buildable again on SPARC.

+4 -0

0 comment

1 changed file

koachan

pr closed time in an hour

Pull request review commentziglang/zig

Merge call zir instructions to make space for field_call

 fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: Ast.Node.Index) Inner         // in the above while loop.         const zir_tags = gz.astgen.instructions.items(.tag);         switch (zir_tags[inst]) {-            // For some instructions, swap in a slightly different ZIR tag+            // For some instructions, modify the zir data             // so we can avoid a separate ensure_result_used instruction.-            .call_chkused => unreachable,             .call => {-                zir_tags[inst] = .call_chkused;+                const extra_index = gz.astgen.instructions.items(.data)[inst].pl_node.payload_index;+                const extra = @ptrCast(*Zir.Inst.Call, &gz.astgen.extra.items[extra_index]);

I'm OK with this but Zir.Inst.Call needs to become an extern struct to make it sound.

SpexGuy

comment created time in an hour

PullRequestReviewEvent

delete branch SpexGuy/zig

delete branch : fix-windows-tests

delete time in 2 hours

push eventziglang/zig

Martin Wickham

commit sha ef6fbbdab623f8eb6615eb3fb3e42141e5711331

Fix the failing "bad import" test on Windows

view details

push time in 2 hours

PR merged ziglang/zig

Fix the failing "bad import" test on Windows

The path was being formatted with string escapes, turning backslashes into double backslashes.

+4 -8

0 comment

1 changed file

SpexGuy

pr closed time in 2 hours

push eventziglang/zig

Robin Voetter

commit sha f5c27dd11aeac3bb4647396a0e420c649b30f468

big ints: 2s complement signed or

view details

Robin Voetter

commit sha 351e4f07cebc8299c107bd3de760efe17d184af7

big ints: 2s complement signed and + or fixes

view details

Robin Voetter

commit sha cd3dcc225b52be981b52b71dcdb34ba176f4081b

big ints: only write xor overflow if required

view details

Andrew Kelley

commit sha dd81a2147da7b8a216012be2c483c71c4a65cf8b

Merge pull request #9825 from Snektron/big-int-signed-and-or big ints: 2s complement signed and/or

view details

push time in 2 hours

PR merged ziglang/zig

big ints: 2s complement signed and/or

Similar to xor, but these require a lot more written out cases. Comments are again in the source. I also made sure again that the required memory allocations remain the same for positive cases, but note that if an argument of bitXor, bitAnd and bitOr are negative extra caution is required for the amount of memory that the operation needs. Especially bitAnd with two negative numbers is a bit unexpected.

I also noticed a small edge case where llsignedxor would write the overflow value even if the result is positive.

+409 -29

0 comment

2 changed files

Snektron

pr closed time in 2 hours

delete branch SpexGuy/zig

delete branch : comptime-closures

delete time in 2 hours

push eventziglang/zig

Martin Wickham

commit sha a0a847f2e40046387e2e2b8a0b8dae9cb27ca22a

Stage2: Implement comptime closures and the This builtin (#9823)

view details

push time in 2 hours

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentziglang/zig

Stage2: Implement comptime closures and the This builtin

 pub const DeclPlusEmitH = struct {     emit_h: EmitH, }; +pub const CaptureScope = struct {+    parent: ?*CaptureScope,++    /// Values from this decl's evaluation that will be closed over in+    /// child decls. Values stored in the value_arena of the linked decl.+    /// During sema, this map is backed by the gpa.  Once sema completes,+    /// it is reallocated using the value_arena.+    captures: std.AutoArrayHashMapUnmanaged(Zir.Inst.Ref, TypedValue) = .{},

I don't think it's overkill - plenty of ZIR instructions have their own form. closure_get doesn't want a un_node, it wants a node and a zir index, right? Let's give it the type-correct thing that it wants.

SpexGuy

comment created time in 14 hours

PullRequestReviewEvent

pull request commentziglang/zig

stage2: enhance `zig init-lib` and `zig init-exe`

Thanks @hdorio

hdorio

comment created time in 14 hours

push eventziglang/zig

Hadrien Dorio

commit sha f615648d7bdcb5c7ed38ad15169a8fa90bd86ca0

stage2: enhance `zig init-lib` and `zig init-exe` Stop `src/main.zig` from being overwritten.

view details

push time in 14 hours

PR merged ziglang/zig

stage2: enhance `zig init-lib` and `zig init-exe`

Stop src/main.zig from being overwritten.

See #9820

+6 -0

2 comments

1 changed file

hdorio

pr closed time in 14 hours

pull request commentziglang/zig

stage2: enhance `zig init-lib` and `zig init-exe`

@zigazeljko that is generally true but in this case the idea is to check if any files would be overwritten, before attempting to write any files. File system APIs do not provide any way to avoid races for this use case.

hdorio

comment created time in 14 hours

push eventziglang/zig

Andrew Kelley

commit sha 736d14fd5fa5feea83a6efce8b606b62bf165033

stage2: fix AstGen for some struct syntaxes * AstGen: fix not emitting `struct_init_empty` when an explicit type is present in struct initialization syntax. * AstGen: these two syntaxes now lower to identical ZIR: - `var a = A{ .b = c };` - `var a = @as(A, .{ .b = c });` * Zir: clarify `auto_enum_tag` in the doc comments. * LLVM Backend: fix lowering of function return types when the type has 0 bits.

view details

push time in 15 hours

Pull request review commentziglang/zig

Stage2: Implement comptime closures and the This builtin

 pub const ExtraIndex = enum(u32) { };  pub fn getMainStruct(zir: Zir) Inst.Index {-    return zir.extra[@enumToInt(ExtraIndex.main_struct)] --        @intCast(u32, Inst.Ref.typed_value_map.len);+    _ = zir;+    return 0; }

hmm I suggest this:

pub const main_struct_index = 0;

this is simpler than a function call with an unnecessary argument but if things change to work a different way in the future we will still get a compile error at the usage sites.

SpexGuy

comment created time in 15 hours

Pull request review commentziglang/zig

Stage2: Implement comptime closures and the This builtin

+const expect = @import("std").testing.expect;

All the tests in this file are passing in stage2; you can delete this file. The fact that you simplified the test case to not exercise struct initialization is fine; that's not what that test was testing. There's plenty of test coverage of struct initialization syntax in the struct.zig test cases.

SpexGuy

comment created time in 15 hours

Pull request review commentziglang/zig

Stage2: Implement comptime closures and the This builtin

 pub const DeclPlusEmitH = struct {     emit_h: EmitH, }; +pub const CaptureScope = struct {+    parent: ?*CaptureScope,++    /// Values from this decl's evaluation that will be closed over in+    /// child decls. Values stored in the value_arena of the linked decl.+    /// During sema, this map is backed by the gpa.  Once sema completes,+    /// it is reallocated using the value_arena.+    captures: std.AutoArrayHashMapUnmanaged(Zir.Inst.Ref, TypedValue) = .{},

As far as I can tell, whenever a key is added here it is always an Index, not a Ref, and then indexToRef is used on the way in, and refToIndex on the way out. Simpler would be to make the key an Index right? And then those functions don't need to be moved from AstGen.

SpexGuy

comment created time in 16 hours

Pull request review commentziglang/zig

Stage2: Implement comptime closures and the This builtin

 pub fn semaFile(mod: *Module, file: *Scope.File) SemaError!void {             .owner_func = null,         };         defer sema.deinit();++        var wip_captures = try WipCaptureScope.init(gpa, &new_decl_arena.allocator, null);+        defer wip_captures.deinit();+         var block_scope: Scope.Block = .{             .parent = null,             .sema = &sema,             .src_decl = new_decl,+            .wip_capture_scope = wip_captures.scope,             .instructions = .{},             .inlining = null,             .is_comptime = true,         };         defer block_scope.instructions.deinit(gpa);          if (sema.analyzeStructDecl(new_decl, main_struct_inst, struct_obj)) |_| {+            try wip_captures.finalize();             new_decl.analysis = .complete;++            // If an error happens resolving the fields of a struct, it will be marked+            // invalid and a proper compile error set up. But we should still look at the+            // other types pending resolution.+            //const src: LazySrcLoc = .{ .node_offset = 0 };+            //sema.resolveDeclFields(block, src, ty) catch continue;

is this code supposed to be uncommented?

This looks like it was cut+pasted from resolvePendingTypes and I'm a bit confused about what it's doing here.

SpexGuy

comment created time in 16 hours

Pull request review commentziglang/zig

Stage2: Implement comptime closures and the This builtin

 fn analyzeCall(             try namespace.anon_decls.ensureUnusedCapacity(gpa, 1);              // Create a Decl for the new function.-            const new_decl = try mod.allocateNewDecl(namespace, module_fn.owner_decl.src_node);+            const src_decl = namespace.getDecl();+            // TODO CLOSURE verify that depth+1 is correct here

is this comment still meaningful?

SpexGuy

comment created time in 15 hours

Pull request review commentziglang/zig

Stage2: Implement comptime closures and the This builtin

 fn zirThis(     block: *Scope.Block,     extended: Zir.Inst.Extended.InstData, ) CompileError!Air.Inst.Ref {+    const this_decl = block.base.namespace().getDecl();     const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };-    return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirThis", .{});+    return sema.analyzeDeclVal(block, src, this_decl);+}++fn zirClosureCapture(+    sema: *Sema,+    block: *Scope.Block,+    inst: Zir.Inst.Index,+) CompileError!void {+    // TODO: Compile error when closed over values are modified+    const inst_data = sema.code.instructions.items(.data)[inst].un_tok;+    const tv = try sema.resolveInstConst(block, inst_data.src(), inst_data.operand);+    //const arena = sema.perm_arena;
SpexGuy

comment created time in 15 hours

Pull request review commentziglang/zig

Stage2: Implement comptime closures and the This builtin

 mod: *Module, /// Alias to `mod.gpa`. gpa: *Allocator,-/// Points to the arena allocator of the Decl.+/// Points to the temporary arena allocator of the Sema.+/// This arena will be cleared when the sema is destroyed. arena: *Allocator,+/// Points to the arena allocator for the Decl.  This arena

Which one? owner_decl?

SpexGuy

comment created time in 16 hours

Pull request review commentziglang/zig

Stage2: Implement comptime closures and the This builtin

 pub const DeclPlusEmitH = struct {     emit_h: EmitH, }; +pub const CaptureScope = struct {+    parent: ?*CaptureScope,++    /// Values from this decl's evaluation that will be closed over in+    /// child decls. Values stored in the value_arena of the linked decl.+    /// During sema, this map is backed by the gpa.  Once sema completes,+    /// it is reallocated using the value_arena.+    captures: std.AutoArrayHashMapUnmanaged(Zir.Inst.Ref, TypedValue) = .{},+};++pub const WipCaptureScope = struct {+    scope: *CaptureScope,+    finalized: bool,+    gpa: *Allocator,+    perm_arena: *Allocator,++    pub fn init(gpa: *Allocator, perm_arena: *Allocator, parent: ?*CaptureScope) !@This() {+        const scope = try perm_arena.create(CaptureScope);+        scope.* = .{ .parent = parent };+        return @This(){+            .scope = scope,+            .finalized = false,+            .gpa = gpa,+            .perm_arena = perm_arena,+        };+    }++    pub fn finalize(noalias self: *@This()) !void {+        assert(!self.finalized);+        // use a temp to avoid unintentional aliasing due to RLS+        const tmp = try self.scope.captures.clone(self.perm_arena);+        self.scope.captures = tmp;

sound like we need to have a big language design discussion

SpexGuy

comment created time in 16 hours