zigはプログラミング言語

Zigはプログラミング言語

- 組み込み関数の内容を見たい
- 標準ライブラリの内容を見たい
関数一覧
@addrSpaceCast
@addWithOverflow
@alignCast
@alignOf
@as
@atomicLoad
@atomicRmw
@atomicStore
@bitCast
@bitOffsetOf
@bitSizeOf
@breakpoint
@mulAdd
@byteSwap
@bitReverse
@offsetOf
@call
@cDefine
@cImport
@cInclude
@clz
@cmpxchgStrong
@cmpxchgWeak
@compileError
@compileLog
@constCast
@ctz
@cUndef
@cVaArg
@cVaCopy
@cVaEnd
@cVaStart
@divExact
@divFloor
@divTrunc
@embedFile
@enumFromInt
@errorFromInt
@errorName
@errorReturnTrace
@errorCast
@export
@extern
@fence
@field
@fieldParentPtr
@floatCast
@floatFromInt
@frameAddress
@hasDecl
@hasField
@import
@inComptime
@intCast
@intFromBool
@intFromEnum
@intFromError
@intFromFloat
@intFromPtr
@max
@memcpy
@memset
@min
@wasmMemorySize
@wasmMemoryGrow
@mod
@mulWithOverflow
@panic
@popCount
@prefetch
@ptrCast
@ptrFromInt
@rem
@returnAddress
@select
@setAlignStack
@setCold
@setEvalBranchQuota
@setFloatMode
@setRuntimeSafety
@shlExact
@shlWithOverflow
@shrExact
@shuffle
@sizeOf
@splat
@reduce
@src
@sqrt
@sin
@cos
@tan
@exp
@exp2
@log
@log2
@log10
@abs
@floor
@ceil
@trunc
@round
@subWithOverflow
@tagName
@This
@trap
@truncate
@Type
@typeInfo
@typeName
@TypeOf
@unionInit
@Vector
@volatileCast
@workGroupId
@workGroupSize
@workItemId

組み込み関数の内容

計算系の関数
@addWithOverflow(a: anytype, b: anytype) struct { @TypeOf(a, b), u1 }
@mulWithOverflow(a: anytype, b: anytype) struct { @TypeOf(a, b), u1 }
@subWithOverflow(a: anytype, b: anytype) struct { @TypeOf(a, b), u1 }
@shlWithOverflow(a: anytype, shift_amt: Log2T) struct { @TypeOf(a), u1 }
オーバーフローした時に1になるビットを返す関数たち

@divExact(numerator: T, denominator: T) T
@divFloor(numerator: T, denominator: T) T
@divTrunc(numerator: T, denominator: T) T
@mod(numerator: T, denominator: T) T
@rem(numerator: T, denominator: T) T
整数の割り算と余りの関数
numerator / denominator
の商と余りを計算する
-
@divExact
は余りが出たらエラー -
@divFloor
と@mod
は に近い方に切り捨て-\infty -
@divTrunc
と@rem
は0に近い方に切り捨て

@byteSwap(operand: anytype) T
@bitReverse(integer: anytype) T
@clz(operand: anytype) anytype
@ctz(operand: anytype) anytype
@popCount(operand: anytype) anytype
ビット操作の関数

@atomicStore(comptime T: type, ptr: *T, value: T, comptime ordering: AtomicOrder) void
@atomicLoad(comptime T: type, ptr: *const T, comptime ordering: AtomicOrder) T
@atomicRmw(comptime T: type, ptr: *T, comptime op: AtomicRmwOp, operand: T, comptime ordering: AtomicOrder) T
@fence(order: AtomicOrder) void
@cmpxchgWeak(comptime T: type, ptr: *T, expected_value: T, new_value: T, success_order: AtomicOrder, fail_order: AtomicOrder) ?T
@cmpxchgStrong(comptime T: type, ptr: *T, expected_value: T, new_value: T, success_order: AtomicOrder, fail_order: AtomicOrder) ?T
アトミックの関数

@max(a: T, b: T) T
@min(a: T, b: T) T
@sqrt(value: anytype) @TypeOf(value)
@sin(value: anytype) @TypeOf(value)
@cos(value: anytype) @TypeOf(value)
@tan(value: anytype) @TypeOf(value)
@exp(value: anytype) @TypeOf(value)
@exp2(value: anytype) @TypeOf(value)
@log(value: anytype) @TypeOf(value)
@log2(value: anytype) @TypeOf(value)
@log10(value: anytype) @TypeOf(value)
@abs(value: anytype) anytype
@floor(value: anytype) @TypeOf(value)
@ceil(value: anytype) @TypeOf(value)
@trunc(value: anytype) @TypeOf(value)
@round(value: anytype) @TypeOf(value)
@mulAdd(comptime T: type, a: T, b: T, c: T) T
数学の関数

@Vector(len: comptime_int, Element: type) type
@splat(scalar: anytype) anytype
@shuffle(comptime E: type, a: @Vector(a_len, E), b: @Vector(b_len, E), comptime mask: @Vector(mask_len, i32)) @Vector(mask_len, E)
@select(comptime T: type, pred: @Vector(len, bool), a: @Vector(len, T), b: @Vector(len, T)) @Vector(len, T)
@reduce(comptime op: std.builtin.ReduceOp, value: anytype) E
ベクトルの関数

@cImport(expression) type
@cInclude(comptime path: []const u8) void
@cDefine(comptime name: []const u8, value) void
@cUndef(comptime name: []const u8) void
@cVaArg(operand: *std.builtin.VaList, comptime T: type) T
@cVaCopy(src: *std.builtin.VaList) std.builtin.VaList
@cVaEnd(src: *std.builtin.VaList) void
@cVaStart() std.builtin.VaList
C言語の関数

@addrSpaceCast(ptr: anytype) anytype
@alignCast(ptr: anytype) anytype
@bitCast(value: anytype) anytype
@constCast(value: anytype) DestType
@errorCast(value: anytype) anytype
@floatCast(value: anytype) anytype
@intCast(int: anytype) anytype
@ptrCast(value: anytype) anytype
@volatileCast(value: anytype) DestType
型キャストの関数

@enumFromInt(integer: anytype) anytype
@errorFromInt(value: std.meta.Int(.unsigned, @bitSizeOf(anyerror))) anyerror
@floatFromInt(int: anytype) anytype
@intFromBool(value: bool) u1
@intFromEnum(enum_or_tagged_union: anytype) anytype
@intFromError(err: anytype) std.meta.Int(.unsigned, @bitSizeOf(anyerror))
@intFromFloat(float: anytype) anytype
@intFromPtr(value: anytype) usize
@ptrFromInt(address: usize) anytype
@as(comptime T: type, expression) T
@truncate(integer: anytype) anytype
型変換の関数

@alignOf(comptime T: type) comptime_int
@bitOffsetOf(comptime T: type, comptime field_name: []const u8) comptime_int
@bitSizeOf(comptime T: type) comptime_int
@offsetOf(comptime T: type, comptime field_name: []const u8) comptime_int
@field(lhs: anytype, comptime field_name: []const u8) (field)
@fieldParentPtr(comptime field_name: []const u8, field_ptr: *T) anytype
@hasDecl(comptime Container: type, comptime name: []const u8) bool
@hasField(comptime Container: type, comptime name: []const u8) bool
@sizeOf(comptime T: type) comptime_int
@Type(comptime info: std.builtin.Type) type
@typeInfo(comptime T: type) std.builtin.Type
@TypeOf(...) type
@unionInit(comptime Union: type, comptime active_field_name: []const u8, init_expr) Union
型の関数

@errorName(err: anyerror) [:0]const u8
@tagName(value: anytype) [:0]const u8
@typeName(T: type) *const [N:0]u8
名前に変換する関数

@compileError(comptime msg: []const u8) noreturn
@compileLog(args: ...) void
@embedFile(comptime path: []const u8) *const [N:0]u8
@export(declaration, comptime options: std.builtin.ExportOptions) void
@extern(T: type, comptime options: std.builtin.ExternOptions) T
@import(comptime path: []const u8) type
@inComptime() bool
@setAlignStack(comptime alignment: u29) void
@setCold(comptime is_cold: bool) void
@setEvalBranchQuota(comptime new_quota: u32) void
@setFloatMode(comptime mode: FloatMode) void
@setRuntimeSafety(comptime safety_on: bool) void
@src() std.builtin.SourceLocation
@This() type
コンパイル時の関数

@wasmMemorySize(index: u32) usize
@wasmMemoryGrow(index: u32, delta: usize) isize
WASMの関数

@workGroupId(comptime dimension: u32) u32
@workGroupSize(comptime dimension: u32) u32
@workItemId(comptime dimension: u32) u32
ワークグループ?の関数

@shlExact(value: T, shift_amt: Log2T) T
@shrExact(value: T, shift_amt: Log2T) T
シフトの関数
1のビットをシフトで外に出すとエラーになる

@memcpy(noalias dest, noalias source) void
@memset(dest, elem) void
メモリ操作の関数

@breakpoint() void
@call(modifier: std.builtin.CallModifier, function: anytype, args: anytype) anytype
@errorReturnTrace() ?*builtin.StackTrace
@frameAddress() usize
@panic(message: []const u8) noreturn
@prefetch(ptr: anytype, comptime options: PrefetchOptions) void
@returnAddress() usize
@trap() noreturn
その他の特殊な関数

標準ライブラリ
名前空間
- array_hash_map
- ascii
- atomic
- base64
- bit_set
- builtin
- c
- coff
- compress
- crypto
- debug
- dwarf
- elf
- enums
- fifo
- fmt
- fs
- gpu
- hash
- hash_map
- heap
- http
- io
- json
- leb
- log
- macho
- math
- mem
- meta
- net
- os
- pdb
- posix
- process
- simd
- sort
- start
- static_string_map
- tar
- testing
- time
- tz
- unicode
- valgrind
- wasm
- zig
- zip

std.array_hash_map
入れた順番を保持するハッシュマップ構造
主な関数
- ArrayHashMap
- AutoArrayHashMap ハッシュ関数を自動でやってくれる
- StringArrayHashMap キーが文字列の場合

std.ascii
7ビットASCIIコードの文字列についての操作
主な関数
- isAlphabetic
- isWhitespace
- toUpper
- startsWithIgnoreCase

std.atomic
主な関数
- Value

std.base64
Base64のエンコードとデコード
主な関数
- standard.Encoder.encode
- standard.Decoder.decode
- url_safe

std.bit_set
ビット集合
主な関数
- StaticBitSet
- DynamicBitSet

std.builtin
Zigの組み込み関数やコンパイルで使用する構造体など
主な関数
- Type
- Mode

std.c
C言語の標準ライブラリの参照?

std.coff
COFFファイルフォーマットの操作?

std.compress
圧縮アルゴリズムがある
compressとdecompress関数、compressorとdecompressor関数がある
- flate
- gzip
- lzma
- lzma2
- xz
- zlib