forked from AssemblyScript/assemblyscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasc.d.ts
250 lines (220 loc) · 8.37 KB
/
asc.d.ts
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/**
* @fileoverview Definitions for asc.
* @license Apache-2.0
*/
import { OptionDescription } from "./util/options";
export { OptionDescription };
/** Ready promise resolved once/if the compiler is ready. */
export const ready: Promise<void>;
/** Whether this is a webpack bundle or not. */
export const isBundle: boolean;
/** Whether asc runs the sources directly or not. */
export const isDev: boolean;
/** AssemblyScript version. */
export const version: string;
/** Available CLI options. */
export const options: { [key: string]: OptionDescription };
/** Common root used in source maps. */
export var sourceMapRoot: string;
/** Prefix used for library files. */
export var libraryPrefix: string;
/** Default Binaryen optimization level. */
export var defaultOptimizeLevel: number;
/** Default Binaryen shrink level. */
export var defaultShrinkLevel: number;
/** Bundled library files. */
export const libraryFiles: { [key: string]: string };
/** Bundled definition files. */
export const definitionFiles: { assembly: string, portable: string };
/** A compatible output stream. */
export interface OutputStream {
/** Writes another chunk of data to the stream. */
write(chunk: Uint8Array | string): void;
}
/** An in-memory output stream. */
export interface MemoryStream extends OutputStream {
/** Resets the stream to offset zero. */
reset(): void;
/** Converts the output to a buffer. */
toBuffer(): Uint8Array;
/** Converts the output to a string. */
toString(): string;
}
/** Relevant subset of the Source class for diagnostic reporting. */
export interface Source {
/** Normalized path with file extension. */
normalizedPath: string;
}
/** Relevant subset of the Range class for diagnostic reporting. */
export interface Range {
/** Start offset within the source file. */
start: number;
/** End offset within the source file. */
end: number;
/** Respective source file. */
source: Source;
}
/** Relevant subset of the DiagnosticMessage class for diagnostic reporting. */
export interface DiagnosticMessage {
/** Message code. */
code: number;
/** Message category. */
category: number;
/** Message text. */
message: string;
/** Respective source range, if any. */
range: Range | null;
/** Related range, if any. */
relatedRange: Range | null;
}
/** A function handling diagnostic messages. */
type DiagnosticReporter = (diagnostic: DiagnosticMessage) => void;
/** Compiler options. */
export interface CompilerOptions {
/** Prints just the compiler's version and exits. */
version?: boolean;
/** Prints the help message and exits. */
help?: boolean;
/** Optimizes the module. */
optimize?: boolean;
/** How much to focus on optimizing code. */
optimizeLevel?: number;
/** How much to focus on shrinking code size. */
shrinkLevel?: number;
/** Re-optimizes until no further improvements can be made. */
converge?: boolean;
/** Specifies the base directory of input and output files. */
baseDir?: string;
/** Specifies the output file. File extension indicates format. */
outFile?: string;
/** Specifies the binary output file (.wasm). */
binaryFile?: string;
/** Specifies the text output file (.wat). */
textFile?: string;
/** Specifies the JavaScript (via wasm2js) output file (.js). */
jsFile?: string;
/** Specifies the WebIDL output file (.webidl). */
idlFile?: string;
/** Specifies the TypeScript definition output file (.d.ts). */
tsdFile?: string;
/** Enables source map generation. Optionally takes the URL. */
sourceMap?: boolean | string;
/** Specifies the runtime variant to include in the program. */
runtime?: string;
/** Disallows the use of unsafe features in user code. */
noUnsafe?: boolean;
/** Enables debug information in emitted binaries. */
debug?: boolean;
/** Replaces assertions with just their value without trapping. */
noAssert?: boolean;
/** Performs compilation as usual but does not emit code. */
noEmit?: boolean;
/** Imports the memory provided as 'env.memory'. */
importMemory?: boolean;
/** Does not export the memory as 'memory'. */
noExportMemory?: boolean;
/** Sets the initial memory size in pages. */
initialMemory?: number;
/** Sets the maximum memory size in pages. */
maximumMemory?: number;
/** Declare memory as shared. Requires maximumMemory. */
sharedMemory?: boolean;
/** Sets the start offset of compiler-generated static memory. */
memoryBase?: number;
/** Imports the function table provided as 'env.table'. */
importTable?: boolean;
/** Exports the function table as 'table'. */
exportTable?: boolean;
/** Exports an explicit start function to be called manually. */
explicitStart?: boolean;
/** "Adds one or multiple paths to custom library components. */
lib?: string | string[];
/** Adds one or multiple paths to package resolution. */
path?: string | string[];
/** Aliases a global object under another name. */
use?: string | string[];
/** Sets the trap mode to use. */
trapMode?: "allow" | "clamp" | "js";
/** Specifies additional Binaryen passes to run. */
runPasses?: string | string[];
/** Skips validating the module using Binaryen. */
noValidate?: boolean;
/** Enables WebAssembly features that are disabled by default. */
enable?: string | string[];
/** Disables WebAssembly features that are enabled by default. */
disable?: string | string[];
/** Specifies the path to a custom transform to 'require'. */
transform?: string | string[];
/** Make yourself sad for no good reason. */
pedantic?: boolean;
/** Enables tracing of package resolution. */
traceResolution?: boolean;
/** Lists files to be compiled and exits. */
listFiles?: boolean;
/** Prints measuring information on I/O and compile times. */
measure?: boolean;
/** Disables terminal colors. */
noColors?: boolean;
/** Specifies an alternative file extension. */
extension?: string;
}
/** Compiler API options. */
export interface APIOptions {
/** Standard output stream to use. */
stdout?: OutputStream;
/** Standard error stream to use. */
stderr?: OutputStream;
/** Reads a file from disk (or memory). */
readFile?: (filename: string, baseDir: string) => string | null;
/** Writes a file to disk (or memory). */
writeFile?: (filename: string, contents: Uint8Array, baseDir: string) => void;
/** Lists all files within a directory. */
listFiles?: (dirname: string, baseDir: string) => string[] | null;
/** Handler for diagnostic messages. */
reportDiagnostic?: DiagnosticReporter;
}
/** Convenience function that parses and compiles source strings directly. */
export function compileString(sources: { [key: string]: string } | string, options?: CompilerOptions): {
/** Standard output. */
stdout: OutputStream,
/** Standard error. */
stderr: OutputStream,
/** Emitted binary. */
binary: Uint8Array | null,
/** Emitted text format. */
text: string | null
}
/** Runs the command line utility using the specified arguments array. */
export function main(argv: string[], options: APIOptions, callback?: (err: Error | null) => number): number;
export function main(argv: string[], callback?: (err: Error | null) => number): number;
/** Checks diagnostics emitted so far for errors. */
export function checkDiagnostics(emitter: Record<string,unknown>, stderr?: OutputStream, reportDiagnostic?: DiagnosticReporter): boolean;
/** An object of stats for the current task. */
export interface Stats {
readTime: number,
readCount: number,
writeTime: number,
writeCount: number,
parseTime: number,
parseCount: number,
compileTime: number,
compileCount: number,
emitTime: number,
emitCount: number,
validateTime: number,
validateCount: number,
optimizeTime: number,
optimizeCount: number
}
/** Creates an empty set of stats. */
export function createStats(): Stats;
/** Measures the execution time of the specified function. */
export function measure(fn: () => void): number;
/** Formats a high resolution time to a human readable string. */
export function formatTime(time: number): string;
/** Formats and prints out the contents of a set of stats. */
export function printStats(stats: Stats, output: OutputStream): void;
/** Creates a memory stream that can be used in place of stdout/stderr. */
export function createMemoryStream(fn?: (chunk: Uint8Array | string) => void): MemoryStream;
/** Compatible TypeScript compiler options for syntax highlighting etc. */
export const tscOptions: Record<string,unknown>;