move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
pub usingnamespace @import ( " builtin " ) ;
2020-01-29 09:25:25 -08:00
/// Deprecated: use `std.Target`.
2020-01-19 22:42:31 -08:00
pub const Target = std . Target ;
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
/// Deprecated: use `std.Target.Os`.
pub const Os = std . Target . Os ;
2020-02-19 18:30:36 -08:00
/// Deprecated: use `std.Target.Cpu.Arch`.
pub const Arch = std . Target . Cpu . Arch ;
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
/// Deprecated: use `std.Target.Abi`.
pub const Abi = std . Target . Abi ;
/// Deprecated: use `std.Target.ObjectFormat`.
pub const ObjectFormat = std . Target . ObjectFormat ;
/// Deprecated: use `std.Target.SubSystem`.
pub const SubSystem = std . Target . SubSystem ;
2020-01-18 23:40:35 -08:00
/// Deprecated: use `std.Target.Cpu`.
pub const Cpu = std . Target . Cpu ;
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
/// `explicit_subsystem` is missing when the subsystem is automatically detected,
/// so Zig standard library has the subsystem detection logic here. This should generally be
/// used rather than `explicit_subsystem`.
/// On non-Windows targets, this is `null`.
pub const subsystem : ? SubSystem = blk : {
if ( @hasDecl ( @This ( ) , " explicit_subsystem " ) ) break : blk explicit_subsystem ;
2020-03-06 15:30:30 -08:00
switch ( os . tag ) {
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
. windows = > {
if ( is_test ) {
break : blk SubSystem . Console ;
}
2019-12-03 09:52:28 -08:00
if ( @hasDecl ( root , " main " ) or
@hasDecl ( root , " WinMain " ) or
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
@hasDecl ( root , " wWinMain " ) or
@hasDecl ( root , " WinMainCRTStartup " ) or
@hasDecl ( root , " wWinMainCRTStartup " ) )
{
break : blk SubSystem . Windows ;
} else {
break : blk SubSystem . Console ;
}
} ,
else = > break : blk null ,
}
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const StackTrace = struct {
index : usize ,
instruction_addresses : [ ] usize ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const GlobalLinkage = enum {
Internal ,
Strong ,
Weak ,
LinkOnce ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const AtomicOrder = enum {
Unordered ,
Monotonic ,
Acquire ,
Release ,
AcqRel ,
SeqCst ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const AtomicRmwOp = enum {
Xchg ,
Add ,
Sub ,
And ,
Nand ,
Or ,
Xor ,
Max ,
Min ,
} ;
2020-01-29 04:22:11 -08:00
/// The code model puts constraints on the location of symbols and the size of code and data.
/// The selection of a code model is a trade off on speed and restrictions that needs to be selected on a per application basis to meet its requirements.
/// A slightly more detailed explanation can be found in (for example) the [System V Application Binary Interface (x86_64)](https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf) 3.5.1.
///
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const CodeModel = enum {
default ,
tiny ,
small ,
kernel ,
medium ,
large ,
} ;
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Mode = enum {
Debug ,
ReleaseSafe ,
ReleaseFast ,
ReleaseSmall ,
} ;
2019-12-23 12:52:06 -08:00
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const CallingConvention = enum {
Unspecified ,
C ,
Cold ,
Naked ,
Async ,
Interrupt ,
Signal ,
Stdcall ,
Fastcall ,
Vectorcall ,
2019-12-29 10:34:54 -08:00
Thiscall ,
2019-12-23 12:52:06 -08:00
APCS ,
AAPCS ,
AAPCSVFP ,
} ;
2019-11-10 18:58:05 -08:00
pub const TypeId = @TagType ( TypeInfo ) ;
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
2019-11-10 18:58:05 -08:00
pub const TypeInfo = union ( enum ) {
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
Type : void ,
Void : void ,
Bool : void ,
NoReturn : void ,
Int : Int ,
Float : Float ,
Pointer : Pointer ,
Array : Array ,
Struct : Struct ,
ComptimeFloat : void ,
ComptimeInt : void ,
Undefined : void ,
Null : void ,
Optional : Optional ,
ErrorUnion : ErrorUnion ,
ErrorSet : ErrorSet ,
Enum : Enum ,
Union : Union ,
Fn : Fn ,
BoundFn : Fn ,
Opaque : void ,
Frame : void ,
AnyFrame : AnyFrame ,
Vector : Vector ,
EnumLiteral : void ,
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Int = struct {
is_signed : bool ,
bits : comptime_int ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Float = struct {
bits : comptime_int ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Pointer = struct {
size : Size ,
is_const : bool ,
is_volatile : bool ,
alignment : comptime_int ,
child : type ,
is_allowzero : bool ,
2019-11-25 10:51:09 -08:00
2020-03-01 10:07:55 -08:00
/// This field is an optional type.
2019-11-23 01:45:35 -08:00
/// The type of the sentinel is the element type of the pointer, which is
/// the value of the `child` field in this struct. However there is no way
2019-11-23 14:51:37 -08:00
/// to refer to that type here, so we use `var`.
sentinel : var ,
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Size = enum {
One ,
Many ,
Slice ,
C ,
} ;
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Array = struct {
len : comptime_int ,
child : type ,
2019-11-25 10:51:09 -08:00
2020-03-01 10:07:55 -08:00
/// This field is an optional type.
2019-11-23 01:45:35 -08:00
/// The type of the sentinel is the element type of the array, which is
/// the value of the `child` field in this struct. However there is no way
2019-11-23 14:51:37 -08:00
/// to refer to that type here, so we use `var`.
sentinel : var ,
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const ContainerLayout = enum {
Auto ,
Extern ,
Packed ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const StructField = struct {
name : [ ] const u8 ,
offset : ? comptime_int ,
field_type : type ,
2020-01-16 03:55:39 -08:00
default_value : var ,
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Struct = struct {
layout : ContainerLayout ,
fields : [ ] StructField ,
decls : [ ] Declaration ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Optional = struct {
child : type ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const ErrorUnion = struct {
error_set : type ,
payload : type ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Error = struct {
name : [ ] const u8 ,
value : comptime_int ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const ErrorSet = ? [ ] Error ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const EnumField = struct {
name : [ ] const u8 ,
value : comptime_int ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Enum = struct {
layout : ContainerLayout ,
tag_type : type ,
fields : [ ] EnumField ,
decls : [ ] Declaration ,
2020-01-15 11:50:12 -08:00
is_exhaustive : bool ,
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const UnionField = struct {
name : [ ] const u8 ,
enum_field : ? EnumField ,
field_type : type ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Union = struct {
layout : ContainerLayout ,
tag_type : ? type ,
fields : [ ] UnionField ,
decls : [ ] Declaration ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const FnArg = struct {
is_generic : bool ,
is_noalias : bool ,
arg_type : ? type ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Fn = struct {
calling_convention : CallingConvention ,
is_generic : bool ,
is_var_args : bool ,
return_type : ? type ,
args : [ ] FnArg ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const AnyFrame = struct {
child : ? type ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Vector = struct {
len : comptime_int ,
child : type ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Declaration = struct {
name : [ ] const u8 ,
is_pub : bool ,
data : Data ,
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Data = union ( enum ) {
Type : type ,
Var : type ,
Fn : FnDecl ,
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const FnDecl = struct {
fn_type : type ,
inline_type : Inline ,
is_var_args : bool ,
is_extern : bool ,
is_export : bool ,
lib_name : ? [ ] const u8 ,
return_type : type ,
arg_names : [ ] [ ] const u8 ,
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Inline = enum {
Auto ,
Always ,
Never ,
} ;
} ;
} ;
} ;
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const FloatMode = enum {
Strict ,
Optimized ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Endian = enum {
Big ,
Little ,
} ;
2019-11-30 05:39:11 -08:00
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
2019-12-03 09:29:55 -08:00
pub const OutputMode = enum {
2019-11-30 05:39:11 -08:00
Exe ,
Lib ,
Obj ,
} ;
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
2019-12-03 09:29:55 -08:00
pub const LinkMode = enum {
2019-11-30 05:39:11 -08:00
Static ,
Dynamic ,
} ;
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Version = struct {
major : u32 ,
minor : u32 ,
2020-02-23 22:38:21 -08:00
patch : u32 = 0 ,
pub const Range = struct {
min : Version ,
max : Version ,
2020-03-06 15:30:30 -08:00
pub fn includesVersion ( self : Range , ver : Version ) bool {
if ( self . min . order ( ver ) = = . gt ) return false ;
if ( self . max . order ( ver ) = = . lt ) return false ;
2020-02-23 22:38:21 -08:00
return true ;
}
} ;
2020-02-24 22:52:27 -08:00
pub fn order ( lhs : Version , rhs : Version ) std . math . Order {
2020-02-23 22:38:21 -08:00
if ( lhs . major < rhs . major ) return . lt ;
if ( lhs . major > rhs . major ) return . gt ;
if ( lhs . minor < rhs . minor ) return . lt ;
if ( lhs . minor > rhs . minor ) return . gt ;
if ( lhs . patch < rhs . patch ) return . lt ;
if ( lhs . patch > rhs . patch ) return . gt ;
return . eq ;
}
pub fn parse ( text : [ ] const u8 ) ! Version {
2020-04-04 10:15:08 -07:00
var it = std . mem . split ( text , " . " ) ;
2020-02-23 22:38:21 -08:00
return Version {
. major = try std . fmt . parseInt ( u32 , it . next ( ) orelse return error . InvalidVersion , 10 ) ,
. minor = try std . fmt . parseInt ( u32 , it . next ( ) orelse " 0 " , 10 ) ,
. patch = try std . fmt . parseInt ( u32 , it . next ( ) orelse " 0 " , 10 ) ,
} ;
}
2020-02-25 22:18:23 -08:00
pub fn format (
self : Version ,
comptime fmt : [ ] const u8 ,
options : std . fmt . FormatOptions ,
2020-03-06 06:59:21 -08:00
out_stream : var ,
) ! void {
2020-02-25 22:18:23 -08:00
if ( fmt . len = = 0 ) {
if ( self . patch = = 0 ) {
if ( self . minor = = 0 ) {
2020-03-06 14:59:21 -08:00
return std . fmt . format ( out_stream , " {} " , . { self . major } ) ;
2020-02-25 22:18:23 -08:00
} else {
2020-03-06 14:59:21 -08:00
return std . fmt . format ( out_stream , " {}.{} " , . { self . major , self . minor } ) ;
2020-02-25 22:18:23 -08:00
}
} else {
2020-03-06 14:59:21 -08:00
return std . fmt . format ( out_stream , " {}.{}.{} " , . { self . major , self . minor , self . patch } ) ;
2020-02-25 22:18:23 -08:00
}
} else {
@compileError ( " Unknown format string: ' " + + fmt + + " ' " ) ;
}
}
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
} ;
2019-12-05 13:55:32 -08:00
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const CallOptions = struct {
modifier : Modifier = . auto ,
2020-01-30 14:50:50 -08:00
/// Only valid when `Modifier` is `Modifier.async_kw`.
2019-12-05 13:55:32 -08:00
stack : ? [ ] align ( std . Target . stack_align ) u8 = null ,
pub const Modifier = enum {
2019-12-05 14:37:29 -08:00
/// Equivalent to function call syntax.
2019-12-05 13:55:32 -08:00
auto ,
2019-12-05 14:37:29 -08:00
2019-12-09 09:25:57 -08:00
/// Equivalent to async keyword used with function call syntax.
async_kw ,
2019-12-05 14:37:29 -08:00
/// Prevents tail call optimization. This guarantees that the return
/// address will point to the callsite, as opposed to the callsite's
/// callsite. If the call is otherwise required to be tail-called
/// or inlined, a compile error is emitted instead.
2019-12-05 13:55:32 -08:00
never_tail ,
2019-12-05 14:37:29 -08:00
/// Guarantees that the call will not be inlined. If the call is
/// otherwise required to be inlined, a compile error is emitted instead.
2019-12-05 13:55:32 -08:00
never_inline ,
2019-12-05 14:37:29 -08:00
2019-12-06 12:25:00 -08:00
/// Asserts that the function call will not suspend. This allows a
/// non-async function to call an async function.
no_async ,
2019-12-05 14:37:29 -08:00
/// Guarantees that the call will be generated with tail call optimization.
/// If this is not possible, a compile error is emitted instead.
2019-12-05 13:55:32 -08:00
always_tail ,
2019-12-05 14:37:29 -08:00
/// Guarantees that the call will inlined at the callsite.
/// If this is not possible, a compile error is emitted instead.
2019-12-05 13:55:32 -08:00
always_inline ,
2019-12-05 14:37:29 -08:00
/// Evaluates the call at compile-time. If the call cannot be completed at
/// compile-time, a compile error is emitted instead.
2019-12-05 13:55:32 -08:00
compile_time ,
} ;
} ;
2020-01-09 01:36:51 -08:00
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const ExportOptions = struct {
name : [ ] const u8 ,
linkage : GlobalLinkage = . Strong ,
section : ? [ ] const u8 = null ,
} ;
2019-12-12 15:27:17 -08:00
/// This function type is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const TestFn = struct {
name : [ ] const u8 ,
2020-01-05 17:30:28 -08:00
func : fn ( ) anyerror ! void ,
2020-02-06 14:56:40 -08:00
async_frame_size : ? usize ,
2019-12-12 15:27:17 -08:00
} ;
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
/// This function type is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const PanicFn = fn ( [ ] const u8 , ? * StackTrace ) noreturn ;
/// This function is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const panic : PanicFn = if ( @hasDecl ( root , " panic " ) ) root . panic else default_panic ;
/// This function is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub fn default_panic ( msg : [ ] const u8 , error_return_trace : ? * StackTrace ) noreturn {
@setCold ( true ) ;
2019-12-11 17:31:32 -08:00
if ( @hasDecl ( root , " os " ) and @hasDecl ( root . os , " panic " ) ) {
root . os . panic ( msg , error_return_trace ) ;
unreachable ;
}
2020-02-24 22:52:27 -08:00
switch ( os . tag ) {
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
. freestanding = > {
while ( true ) {
@breakpoint ( ) ;
}
} ,
. wasi = > {
2019-12-08 19:53:51 -08:00
std . debug . warn ( " {} " , . { msg } ) ;
2020-01-05 17:30:28 -08:00
std . os . abort ( ) ;
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
} ,
. uefi = > {
// TODO look into using the debug info and logging helpful messages
std . os . abort ( ) ;
} ,
else = > {
const first_trace_addr = @returnAddress ( ) ;
2019-12-08 19:53:51 -08:00
std . debug . panicExtra ( error_return_trace , first_trace_addr , " {} " , . { msg } ) ;
move types from builtin to std
* All the data types from `@import("builtin")` are moved to
`@import("std").builtin`. The target-related types are moved
to `std.Target`. This allows the data types to have methods, such as
`std.Target.current.isDarwin()`.
* `std.os.windows.subsystem` is moved to
`std.Target.current.subsystem`.
* Remove the concept of the panic package from the compiler
implementation. Instead, `std.builtin.panic` is always the panic
function. It checks for `@hasDecl(@import("root"), "panic")`,
or else provides a default implementation.
This is an important step for multibuilds (#3028). Without this change,
the types inside the builtin namespace look like different types, when
trying to merge builds with different target settings. With this change,
Zig can figure out that, e.g., `std.builtin.Os` (the enum type) from one
compilation and `std.builtin.Os` from another compilation are the same
type, even if the target OS value differs.
2019-10-23 15:43:24 -07:00
} ,
}
}
const std = @import ( " std.zig " ) ;
const root = @import ( " root " ) ;