Skip to content

Commit

Permalink
Fix docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
fubark committed Jul 10, 2024
1 parent 7bc9639 commit 54ae7b9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/gen-docs.cy
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ func genDecl(decl Map) String:
gen += "### `type $(decl['name'])`\n\n"
for decl['funcs'] -> fdecl:
gen += genFuncDecl(fdecl)
case 'trait_decl':
gen += "### `type $(decl['name']) trait`\n\n"
for decl['funcs'] -> fdecl:
gen += genFuncDecl(fdecl)
case 'template':
gen += genDecl(decl['child'])
case 'specialization':
Expand Down
3 changes: 3 additions & 0 deletions src/ast.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,9 @@ pub const Encoder = struct {
try w.writeAll("*");
try self.write(w, node.cast(.expand_ptr).elem);
},
.comptimeExpr => {
try self.write(w, node.cast(.comptimeExpr).child);
},
else => {
try w.writeByte('<');
try w.writeAll(@tagName(node.type()));
Expand Down
9 changes: 9 additions & 0 deletions src/builtins/cy.zig
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,15 @@ fn genDeclEntry(vm: *cy.VM, view: ast.AstView, decl: *ast.Node, state: *ParseCyb
}
try vm.mapSet(entry, try vm.retainOrAllocAstring("funcs"), funcs_);
},
.trait_decl => {
const trait_decl = decl.cast(.trait_decl);
const funcs_ = try vm.allocEmptyListDyn();
for (trait_decl.funcs) |func_decl| {
const f = try genImplicitFuncDeclEntry(vm, view, func_decl, state);
try funcs_.asHeapObject().list.append(vm.alloc, f);
}
try vm.mapSet(entry, try vm.retainOrAllocAstring("funcs"), funcs_);
},
else => {
log.tracev("{}", .{decl.type()});
return error.Unsupported;
Expand Down

0 comments on commit 54ae7b9

Please sign in to comment.