forked from swiftwasm/JavaScriptKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.mjs
More file actions
122 lines (105 loc) · 3.22 KB
/
types.mjs
File metadata and controls
122 lines (105 loc) · 3.22 KB
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
// @ts-check
/**
* Shared data types for the BridgeJS fuzz testing infrastructure.
*
* BridgeType represents the type space we generate across.
* Operations represent the composable steps in a test function body.
* TestCase is the complete output of the smith, consumed by emitters.
*/
// ============================================================
// BridgeType — mirrors BridgeType in BridgeJSSkeleton.swift
// ============================================================
/**
* @typedef {(
* | { kind: "int" }
* | { kind: "float" }
* | { kind: "double" }
* | { kind: "string" }
* | { kind: "bool" }
* | { kind: "jsObject" }
* | { kind: "void" }
* | { kind: "nullable", wrapped: BridgeType }
* | { kind: "array", element: BridgeType }
* | { kind: "dictionary", value: BridgeType }
* | { kind: "importedClass", name: string }
* )} BridgeType
*/
// ============================================================
// Declarations — generated by DeclSmith
// ============================================================
/**
* @typedef {{ label: string|null, name: string, type: BridgeType }} Param
*/
/**
* An imported free function: @JSFunction func name(...) throws(JSException) -> ReturnType
* @typedef {{
* name: string,
* params: Param[],
* returnType: BridgeType
* }} ImportedFunc
*/
/**
* An imported class (constructor-only for v1): @JSClass struct Name { @JSFunction init(...) }
* @typedef {{
* name: string,
* constructorParams: Param[]
* }} ImportedClass
*/
/**
* The declaration environment — all available imported types and functions.
* @typedef {{
* importedFuncs: ImportedFunc[],
* importedClasses: ImportedClass[]
* }} DeclEnv
*/
// ============================================================
// Variables and Operations — generated by OpSmith
// ============================================================
/**
* A variable in scope during code generation.
* @typedef {{ name: string, type: BridgeType }} Var
*/
/**
* @typedef {(
* | { kind: "literal", var: Var, jsValue: string }
* | { kind: "callImport", var: Var, func: ImportedFunc, args: Var[] }
* | { kind: "construct", var: Var, class: ImportedClass, args: Var[] }
* | { kind: "return", value: Var }
* )} Operation
*/
// ============================================================
// TestFunc and TestCase — the complete smith output
// ============================================================
/**
* A generated test function: @JS func name(params...) -> returnType { ops... }
* @typedef {{
* name: string,
* params: Param[],
* returnType: BridgeType,
* ops: Operation[]
* }} TestFunc
*/
/**
* A complete test case — everything needed to emit Swift + JS for one iteration.
* @typedef {{
* seed: number,
* env: DeclEnv,
* testFuncs: TestFunc[],
* jsExpected: Array<{ funcName: string, args: string[], expected: string }>
* }} TestCase
*/
/**
* @typedef {"compile-error"|"link-error"|"runtime-trap"|"runtime-error"|"wrong-result"} FailurePhase
*/
/**
* @typedef {{
* id: string,
* phase: FailurePhase,
* fingerprint: string,
* timestamp: string,
* seed: number,
* typesInvolved: string[],
* error: string
* }} FailureMetadata
*/
export {};