-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
abi.dart
178 lines (146 loc) · 6.08 KB
/
abi.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
part of dart.ffi;
/// An application binary interface (ABI).
///
/// An ABI defines the memory layout of data
/// and the function call protocol for native code.
/// It is usually defined by the an operating system for each
/// architecture that operating system runs on.
///
/// The Dart VM can run on a variety of operating systems and architectures.
/// Supported ABIs are represented by `Abi` objects.
/// See [values] for all the supported ABIs.
@Since('2.16')
class Abi {
/// The application binary interface for Android on the Arm architecture.
static const androidArm = _androidArm;
/// The application binary interface for Android on the Arm64 architecture.
static const androidArm64 = _androidArm64;
/// The application binary interface for Android on the IA32 architecture.
static const androidIA32 = _androidIA32;
/// The application binary interface for Android on the X64 architecture.
static const androidX64 = _androidX64;
/// The application binary interface for Android on 64-bit RISC-V.
static const androidRiscv64 = _androidRiscv64;
/// The application binary interface for Fuchsia on the Arm64 architecture.
static const fuchsiaArm64 = _fuchsiaArm64;
/// The application binary interface for Fuchsia on the X64 architecture.
static const fuchsiaX64 = _fuchsiaX64;
/// The application binary interface for Fuchsia on the Riscv64 architecture.
static const fuchsiaRiscv64 = _fuchsiaRiscv64;
/// The application binary interface for iOS on the Arm architecture.
static const iosArm = _iosArm;
/// The application binary interface for iOS on the Arm64 architecture.
static const iosArm64 = _iosArm64;
/// The application binary interface for iOS on the X64 architecture.
static const iosX64 = _iosX64;
/// The application binary interface for Linux on the Arm architecture.
///
/// Does not distinguish between hard and soft fp. Currently, no uses of Abi
/// require this distinction.
static const linuxArm = _linuxArm;
/// The application binary interface for linux on the Arm64 architecture.
static const linuxArm64 = _linuxArm64;
/// The application binary interface for linux on the IA32 architecture.
static const linuxIA32 = _linuxIA32;
/// The application binary interface for linux on the X64 architecture.
static const linuxX64 = _linuxX64;
/// The application binary interface for linux on 32-bit RISC-V.
static const linuxRiscv32 = _linuxRiscv32;
/// The application binary interface for linux on 64-bit RISC-V.
static const linuxRiscv64 = _linuxRiscv64;
/// The application binary interface for MacOS on the Arm64 architecture.
static const macosArm64 = _macosArm64;
/// The application binary interface for MacOS on the X64 architecture.
static const macosX64 = _macosX64;
/// The application binary interface for Windows on the Arm64 architecture.
static const windowsArm64 = _windowsArm64;
/// The application binary interface for Windows on the IA32 architecture.
static const windowsIA32 = _windowsIA32;
/// The application binary interface for Windows on the X64 architecture.
static const windowsX64 = _windowsX64;
/// The ABIs that the DartVM can run on.
///
/// Does not contain a `macosIA32`. We have stopped supporting 32-bit MacOS.
static const values = [
androidArm,
androidArm64,
androidIA32,
androidX64,
androidRiscv64,
fuchsiaArm64,
fuchsiaX64,
fuchsiaRiscv64,
iosArm,
iosArm64,
iosX64,
linuxArm,
linuxArm64,
linuxIA32,
linuxX64,
linuxRiscv32,
linuxRiscv64,
macosArm64,
macosX64,
windowsArm64,
windowsIA32,
windowsX64,
];
/// The ABI the Dart VM is currently running on.
external factory Abi.current();
/// A string representation of this ABI.
///
/// The string is equal to the 'on' part from `Platform.version` and
/// `dart --version`.
@override
String toString() => '${_os.name}_${_architecture.name}';
/// The operating system of this [Abi].
final _OS _os;
/// The architecture of this [Abi].
final _Architecture _architecture;
/// The constructor is private so that we can use [Abi.values] as opaque
/// tokens.
const Abi._(this._architecture, this._os);
static const _androidArm = Abi._(_Architecture.arm, _OS.android);
static const _androidArm64 = Abi._(_Architecture.arm64, _OS.android);
static const _androidIA32 = Abi._(_Architecture.ia32, _OS.android);
static const _androidX64 = Abi._(_Architecture.x64, _OS.android);
static const _androidRiscv64 = Abi._(_Architecture.riscv64, _OS.android);
static const _fuchsiaArm64 = Abi._(_Architecture.arm64, _OS.fuchsia);
static const _fuchsiaX64 = Abi._(_Architecture.x64, _OS.fuchsia);
static const _fuchsiaRiscv64 = Abi._(_Architecture.riscv64, _OS.fuchsia);
static const _iosArm = Abi._(_Architecture.arm, _OS.ios);
static const _iosArm64 = Abi._(_Architecture.arm64, _OS.ios);
static const _iosX64 = Abi._(_Architecture.x64, _OS.ios);
static const _linuxArm = Abi._(_Architecture.arm, _OS.linux);
static const _linuxArm64 = Abi._(_Architecture.arm64, _OS.linux);
static const _linuxIA32 = Abi._(_Architecture.ia32, _OS.linux);
static const _linuxX64 = Abi._(_Architecture.x64, _OS.linux);
static const _linuxRiscv32 = Abi._(_Architecture.riscv32, _OS.linux);
static const _linuxRiscv64 = Abi._(_Architecture.riscv64, _OS.linux);
static const _macosArm64 = Abi._(_Architecture.arm64, _OS.macos);
static const _macosX64 = Abi._(_Architecture.x64, _OS.macos);
static const _windowsArm64 = Abi._(_Architecture.arm64, _OS.windows);
static const _windowsIA32 = Abi._(_Architecture.ia32, _OS.windows);
static const _windowsX64 = Abi._(_Architecture.x64, _OS.windows);
}
/// The hardware architectures the Dart VM runs on.
enum _Architecture {
arm,
arm64,
ia32,
x64,
riscv32,
riscv64,
}
/// The operating systems the Dart VM runs on.
enum _OS {
android,
fuchsia,
ios,
linux,
macos,
windows,
}