Skip to documentation
SLOP

tiny.chant.ast.types.shape

Reference tiny.chant ast types shape

Defined in ast.types.

API (2)

Actions

Public operations.

No direct callersNo direct callsast.typesshape
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Called byCallsNo direct callstest sourcelib.chant.src.ast.type.shapetest: pointer-like types expose their...ast.types.shapeelement
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.chant.src.ast.type.shapetest: pointer-like types expose their...ast.types.shapeisPointerLike
Static calls · unresolved targets: 0 · external targets: 0.

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

Definitions3
Public names5
Members0
Version26.7.0
Revisiondaab053ee433