tiny.chant.ast.types.shape
Defined in ast.types.
API (2)
Actions
Public operations.
Source
Source: lib/chant/src/ast/type/root.zig:8
zig
pub const shape = shape_mod;Source: lib/chant/src/ast/type/shape.zig
zig
const std = @import("std");const types = @import("types.zig");const Kind = types.Kind;const Type = types.Type;pub fn isPointerLike(c_type: *const Type) bool { return c_type.kind == .pointer or c_type.kind == .array;}pub fn element(c_type: *const Type) ?*const Type { return switch (c_type.kind) { .pointer, .array => c_type.child, else => null, };}test "pointer-like types expose their element" { const pointer = Type{ .kind = .pointer, .child = &types.double_type }; const array = Type{ .kind = .array, .child = &types.int_type, .array_len = 4 }; try std.testing.expect(isPointerLike(&pointer)); try std.testing.expect(isPointerLike(&array)); try std.testing.expectEqual(Kind.double_type, element(&pointer).?.kind); try std.testing.expectEqual(Kind.int_type, element(&array).?.kind); try std.testing.expect(element(&types.int_type) == null);}Audit
| Definitions | 3 |
|---|---|
| Public names | 5 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |