@flock/wirespec 0.22.7 → 0.22.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,95 +1,82 @@
1
1
  import {
2
2
  KProperty1ca4yb4wlo496 as KProperty1,
3
3
  getPropertyCallableRef3hckxc0xueiaj as getPropertyCallableRef,
4
- split2bvyvnrlcifjv as split,
5
- collectionSizeOrDefault36dulx8yinfqm as collectionSizeOrDefault,
6
- ArrayList_init_$Create$2byt5m5yn22yy as ArrayList_init_$Create$,
7
- checkIndexOverflow3frtmheghr0th as checkIndexOverflow,
4
+ ArrayList_init_$Create$37gc04va6yfo2 as ArrayList_init_$Create$,
8
5
  Unit_instancev9v8hjid95df as Unit_instance,
9
- joinToString1cxrrlmo0chqs as joinToString,
10
- StringBuilder_init_$Create$3ds9zx2kx9u4d as StringBuilder_init_$Create$,
11
- charSequenceLength3278n89t01tmv as charSequenceLength,
12
- charSequenceGet1vxk1y5n17t1z as charSequenceGet,
13
- isLetterOrDigit2kuxd9e198haf as isLetterOrDigit,
14
- _Char___init__impl__6a9atx2gndcvjvc5pke as _Char___init__impl__6a9atx,
15
- firstOrNulltrxqttxfxqju as firstOrNull,
16
- isDigit3mimrri4wkzop as isDigit,
17
- Char19o2r8palgjof as Char,
18
- VOID3gxj6tk5isa35 as VOID,
19
- plus310ted5e4i90h as plus,
6
+ firstOrNull1982767dljvdy as firstOrNull,
7
+ ensureNotNull1e947j3ixpazm as ensureNotNull,
8
+ listOfvhqybd2zx248 as listOf,
20
9
  Collection1k04j3hzsbod0 as Collection,
21
10
  isInterface3d6p8outrmvmk as isInterface,
22
- equals2au1ep9vhcato as equals,
11
+ listOfNotNull2woi2boe01ub4 as listOfNotNull,
12
+ addAll1k27qatfgp3k5 as addAll,
13
+ plus310ted5e4i90h as plus,
14
+ VOID3gxj6tk5isa35 as VOID,
15
+ joinToString1cxrrlmo0chqs as joinToString,
16
+ collectionSizeOrDefault36dulx8yinfqm as collectionSizeOrDefault,
17
+ ArrayList_init_$Create$2byt5m5yn22yy as ArrayList_init_$Create$_0,
23
18
  to2cs3ny02qtbcb as to,
24
19
  protoOf180f3jzyo7rfj as protoOf,
25
20
  initMetadataForCompanion1wyw17z38v6ac as initMetadataForCompanion,
21
+ equals2au1ep9vhcato as equals,
26
22
  FunctionAdapter3lcrrz3moet5b as FunctionAdapter,
27
23
  Comparator2b3maoeh98xtg as Comparator,
28
24
  hashCodeq5arwsb9dgti as hashCode,
29
25
  initMetadataForClassbxx6q50dy2s7 as initMetadataForClass,
26
+ firstOrNulltrxqttxfxqju as firstOrNull_0,
27
+ isDigit3mimrri4wkzop as isDigit,
28
+ Char19o2r8palgjof as Char,
30
29
  toMap1vec9topfei08 as toMap,
31
30
  setOf45ia9pnfhe90 as setOf,
32
31
  minus165a8u1e0x1lu as minus,
33
- ArrayList_init_$Create$37gc04va6yfo2 as ArrayList_init_$Create$_0,
34
- first58ocm7j58k3q as first,
35
- listOfvhqybd2zx248 as listOf,
36
- THROW_CCE2g6jy02ryeudk as THROW_CCE,
37
- KtMap140uvy3s5zad8 as KtMap,
38
- ensureNotNull1e947j3ixpazm as ensureNotNull,
39
- addAll1k27qatfgp3k5 as addAll,
40
- plus20p0vtfmu0596 as plus_0,
41
- charArrayOf27f4r3dozbrk1 as charArrayOf,
42
- trimEndvvzjdhan75g as trimEnd,
43
32
  compareValues1n2ayl87ihzfk as compareValues,
33
+ endsWith3cq61xxngobwh as endsWith,
34
+ trimIndent1qytc1wvt8suh as trimIndent,
35
+ lazy2hsh8ze7j6ikd as lazy,
36
+ sortedWith2csnbbb21k0lg as sortedWith,
37
+ noWhenBranchMatchedException2a6r7ubxgky5j as noWhenBranchMatchedException,
38
+ LinkedHashSet_init_$Create$t7gzf3ihb6pk as LinkedHashSet_init_$Create$,
39
+ THROW_CCE2g6jy02ryeudk as THROW_CCE,
44
40
  startsWith26w8qjqapeeq6 as startsWith,
41
+ _Char___init__impl__6a9atx2gndcvjvc5pke as _Char___init__impl__6a9atx,
45
42
  substringBefore3n7kj60w69hju as substringBefore,
46
- endsWith3cq61xxngobwh as endsWith,
43
+ distinct10qe1scfdvu5k as distinct,
44
+ Paire9pteg33gng7 as Pair,
45
+ listOf1jh22dvmctj1r as listOf_0,
46
+ plus20p0vtfmu0596 as plus_0,
47
+ split2bvyvnrlcifjv as split,
48
+ checkIndexOverflow3frtmheghr0th as checkIndexOverflow,
49
+ StringBuilder_init_$Create$3ds9zx2kx9u4d as StringBuilder_init_$Create$,
50
+ charSequenceLength3278n89t01tmv as charSequenceLength,
51
+ charSequenceGet1vxk1y5n17t1z as charSequenceGet,
52
+ isLetterOrDigit2kuxd9e198haf as isLetterOrDigit,
53
+ HashSet_init_$Create$2w31ptb4ree5i as HashSet_init_$Create$,
47
54
  charCodeAt1yspne1d8erbm as charCodeAt,
48
55
  uppercaseChar6lahngw3wvwg as uppercaseChar,
49
56
  substring3saq8ornu0luv as substring,
50
57
  toString22rbkbhdb5cl2 as toString,
51
- lazy2hsh8ze7j6ikd as lazy,
52
- listOf1jh22dvmctj1r as listOf_0,
53
58
  mapOf1xd03cq9cnmy8 as mapOf,
54
- emptyList1g2z5xcrvp2zy as emptyList,
55
- lastOrNull1aq5oz189qoe1 as lastOrNull,
56
- firstOrNull1982767dljvdy as firstOrNull_0,
57
- mutableListOf6oorvk2mtdmp as mutableListOf,
58
- last1vo29oleiqj36 as last,
59
- sortedWith2csnbbb21k0lg as sortedWith,
60
- asSequence2phdjljfh9jhx as asSequence,
61
- filterNot56uwv8hfomaa as filterNot,
62
- mapsbvh18eqox7a as map,
63
- distinct17vua5ffe1cfv as distinct,
64
- toListx6x8nvfmvvht as toList,
65
- LinkedHashSet_init_$Create$t7gzf3ihb6pk as LinkedHashSet_init_$Create$,
66
- distinct10qe1scfdvu5k as distinct_0,
67
- HashSet_init_$Create$2w31ptb4ree5i as HashSet_init_$Create$,
68
- Regex_init_$Create$17zqsmfd15n8x as Regex_init_$Create$,
69
- trimIndent1qytc1wvt8suh as trimIndent,
70
- contains3ue2qo8xhmpf1 as contains,
71
- removePrefix279df90bhrqqg as removePrefix,
72
59
  mapCapacity1h45rc3eh9p2l as mapCapacity,
73
60
  LinkedHashMap_init_$Create$1gzy1x4a46gd4 as LinkedHashMap_init_$Create$,
74
- mapOf2zpbbmyqk8xpf as mapOf_0,
75
- noWhenBranchMatchedException2a6r7ubxgky5j as noWhenBranchMatchedException,
61
+ Regex_init_$Create$17zqsmfd15n8x as Regex_init_$Create$,
62
+ emptyList1g2z5xcrvp2zy as emptyList,
76
63
  getKClassFromExpression348iqjl4fnx2f as getKClassFromExpression,
77
64
  toString1pkumu07cwy4m as toString_0,
78
65
  IllegalStateException_init_$Create$1h4bcfod21ri0 as IllegalStateException_init_$Create$,
79
- initMetadataForObject1cxne3s9w65el as initMetadataForObject,
66
+ removePrefix279df90bhrqqg as removePrefix,
67
+ mapOf2zpbbmyqk8xpf as mapOf_0,
80
68
  } from './kotlin-kotlin-stdlib.mjs';
81
69
  import {
82
- Companion_instance27ueeez2qu1l as Companion_instance,
83
- FieldIdentifier34k7iphndcnl0 as FieldIdentifier,
70
+ Companion_instance21vwhhqsaytqt as Companion_instance,
71
+ convert37y165c07dvpq as convert,
72
+ Namespacex2gpe17ntoag as Namespace,
84
73
  Companion_getInstance34fvro4h6bumb as Companion_getInstance,
85
- Dict27tp4weviyg4b as Dict,
86
- Array2vay9bq78aua1 as Array_0,
87
- Nullable3he31tqc4yy1q as Nullable,
88
- Custom1ct1lu66hij6o as Custom,
89
- Wildcard_instance1x48vpete4k7w as Wildcard_instance,
90
- Function6mdi096lkwmv as Function,
91
- Reflect_instance2hvndzkpwulla as Reflect_instance,
92
- Any_instance2d4twy8sq7tlx as Any_instance,
74
+ Enumoqsp4e7al89r as Enum,
75
+ fieldList2mdp34yzu6ln6 as fieldList,
76
+ Structakfq94wrq695 as Struct,
77
+ Interface2g99rmjjt5ne as Interface,
78
+ File12q75sqvz964e as File,
79
+ RawElement3huqlgf21e29z as RawElement,
93
80
  requestParameters17h8t6jwwzr7s as requestParameters,
94
81
  RustGenerator_getInstancezg1a9dx9j7v4 as RustGenerator_getInstance,
95
82
  Name1ijtblv1phm3y as Name,
@@ -97,35 +84,19 @@ import {
97
84
  sanitizeFieldName333wgwu6tt90n as sanitizeFieldName,
98
85
  ConstructorStatement1edouznvc71xv as ConstructorStatement,
99
86
  SanitizationConfigunh0ok3qg1q3 as SanitizationConfig,
100
- Custom_init_$Create$kfegfgqdjj1p as Custom_init_$Create$,
101
- Namespacex2gpe17ntoag as Namespace,
102
- File12q75sqvz964e as File,
103
- transformChildren14suh59vxsgt as transformChildren_0,
104
- RawElement3huqlgf21e29z as RawElement,
105
- Enumoqsp4e7al89r as Enum,
106
- Interface2g99rmjjt5ne as Interface,
107
- TransformScope3fhztkr2eyk36 as TransformScope,
108
- TransformerBuilder26pbjl5nmg6wa as TransformerBuilder,
109
- transformhd96z3w1u5uc as transform,
110
- Element3p1xrn21d2w4b as Element,
111
- Function1wme41sk2huri as Function_0,
112
87
  sortKey2zu9zi2nc4wzk as sortKey,
113
88
  RawExpressionfqemfbo6j6cq as RawExpression,
114
- transformChildren21ucrga4lv4sn as transformChildren_1,
115
- Companion_instance21vwhhqsaytqt as Companion_instance_0,
116
- Companion_instance2oq66qbk0c5g8 as Companion_instance_1,
89
+ transformChildren21ucrga4lv4sn as transformChildren_0,
90
+ Companion_instance2oq66qbk0c5g8 as Companion_instance_0,
117
91
  FileExtension_Rust_getInstancelfr0mas05dph as FileExtension_Rust_getInstance,
118
- import3bym2b49e642p as import_0,
119
- interface44jdw6t56okg as interface_0,
120
- convert37y165c07dvpq as convert,
121
- Structakfq94wrq695 as Struct,
122
- fieldList2mdp34yzu6ln6 as fieldList,
123
- Import5xihcpubhtyd as Import,
124
92
  emit3e40nagyc4qho as emit,
125
93
  Endpoint1jsq06yr3xdhp as Endpoint,
126
94
  Model1nx3had6rojzt as Model,
127
- plus3lrm73de10b42 as plus_1,
128
95
  emit1w04jgbmswnni as emit_0,
96
+ plus3lrm73de10b42 as plus_1,
97
+ Channel2fhxi4a4pwb64 as Channel,
98
+ Part2m6fm5anwg79b as Part,
99
+ Rpc1w89psy5tk702 as Rpc,
129
100
  convertToGenerator115obo0n49kco as convertToGenerator,
130
101
  Unionccsavx6nrdr2 as Union,
131
102
  convertToGenerator1x32vg5qdleq8 as convertToGenerator_0,
@@ -135,9 +106,13 @@ import {
135
106
  convertToGenerator1arvbkvdv4bro as convertToGenerator_2,
136
107
  Type12n1gx16iqtcu as Type,
137
108
  sanitizeNames1v55mz1p84psg as sanitizeNames,
109
+ TransformScope3fhztkr2eyk36 as TransformScope,
110
+ Element3p1xrn21d2w4b as Element,
138
111
  collectCustomTypeNames2atsrip288ol4 as collectCustomTypeNames,
139
112
  plus14o24vdaiongg as plus_2,
113
+ import3bym2b49e642p as import_0,
140
114
  convert23o50n5glj7h5 as convert_0,
115
+ importReferencesy4xv7r53sjjs as importReferences,
141
116
  convert1ke01d6gmcvu7 as convert_1,
142
117
  sanitizeEnumEntries28cw6g8cmlq5s as sanitizeEnumEntries,
143
118
  convert29zpebhuxz599 as convert_2,
@@ -145,37 +120,50 @@ import {
145
120
  convert333pgxr2q05n as convert_4,
146
121
  convert86y6uioox2cl as convert_5,
147
122
  convert1o5h4ulxoqycg as convert_6,
148
- importReferencesy4xv7r53sjjs as importReferences,
149
123
  get_extensions1p1y8uybwv35q as get_extensions,
150
124
  emit2s9bv7yrx5jcs as emit_1,
151
125
  beforeGenerate2eu511tof5fa4 as beforeGenerate,
152
126
  get_supportsDefaults2j8lo8mbv0egf as get_supportsDefaults,
153
127
  IrEmitter2jy94gp21kviv as IrEmitter,
128
+ Function6mdi096lkwmv as Function,
129
+ Any_instance2d4twy8sq7tlx as Any_instance,
130
+ Number2bo3d41wdfzde as Number_0,
131
+ Integer3hago8kqppnkb as Integer,
132
+ String_instance2j5u8j0qc6lge as String_instance,
133
+ Boolean_instance2uah59h3vb1ch as Boolean_instance,
134
+ Bytes_instance1wj5048pbkky0 as Bytes_instance,
135
+ StringLiteral3ok9p8g9pwd8t as StringLiteral,
136
+ IntegerLiteral2ol3gjjph591c as IntegerLiteral,
137
+ Reflect_instance2hvndzkpwulla as Reflect_instance,
138
+ Unit_instance25jwel3twibm6 as Unit_instance_0,
139
+ Wildcard_instance1x48vpete4k7w as Wildcard_instance,
140
+ Dict27tp4weviyg4b as Dict,
141
+ Array2vay9bq78aua1 as Array_0,
142
+ Nullable3he31tqc4yy1q as Nullable,
143
+ Custom1ct1lu66hij6o as Custom,
144
+ Companion_instance27ueeez2qu1l as Companion_instance_1,
145
+ TransformerBuilder26pbjl5nmg6wa as TransformerBuilder,
146
+ Function1wme41sk2huri as Function_0,
147
+ transformhd96z3w1u5uc as transform,
154
148
  Uniontffpdks00nyc as Union_0,
155
- VariableReferencesji1q1tq3ygo as VariableReference,
149
+ Custom_init_$Create$kfegfgqdjj1p as Custom_init_$Create$,
150
+ String3gpv4dw3d0slq as String_0,
151
+ Literal1ddgfbf7tp4wt as Literal,
152
+ ArrayIndexCallza9minnmbuvj as ArrayIndexCall,
156
153
  FieldCall2nusnrnm7uuow as FieldCall,
157
- convertConstraint1tall9wrxeg5k as convertConstraint,
158
- function3tnfxyozkc8k as function_0,
159
- String1czvr8pxnm6on as String_0,
160
- Switch1xeta53lgnle5 as Switch,
154
+ VariableReferencesji1q1tq3ygo as VariableReference,
161
155
  Case35feeoz93frh9 as Case,
162
- transformChildrenfid5m1x7z1ur as transformChildren_2,
156
+ transformChildren2vo7pa38trabm as transformChildren_1,
157
+ function3tnfxyozkc8k as function_0,
158
+ transformChildren14suh59vxsgt as transformChildren_2,
163
159
  FunctionCall1a3g4e6bcljl6 as FunctionCall,
164
- Boolean_instance2uah59h3vb1ch as Boolean_instance,
165
- String_instance2j5u8j0qc6lge as String_instance,
160
+ Switch1xeta53lgnle5 as Switch,
161
+ transformChildrenfid5m1x7z1ur as transformChildren_3,
162
+ convertConstraint1tall9wrxeg5k as convertConstraint,
163
+ String1czvr8pxnm6on as String_1,
166
164
  Paramvfwnys2w6aj1 as Param,
167
- Literal331hu9r04vptz as Literal,
165
+ Literal331hu9r04vptz as Literal_0,
168
166
  Parameter37d5p43ul6u79 as Parameter,
169
- Number2bo3d41wdfzde as Number_0,
170
- Integer3hago8kqppnkb as Integer,
171
- Booleanz31i2i22ldw9 as Boolean_0,
172
- String3gpv4dw3d0slq as String_1,
173
- Literal1ddgfbf7tp4wt as Literal_0,
174
- ArrayIndexCallza9minnmbuvj as ArrayIndexCall,
175
- StringLiteral3ok9p8g9pwd8t as StringLiteral,
176
- IntegerLiteral2ol3gjjph591c as IntegerLiteral,
177
- Bytes_instance1wj5048pbkky0 as Bytes_instance,
178
- Unit_instance25jwel3twibm6 as Unit_instance_0,
179
167
  } from './wirespec-src-compiler-core.mjs';
180
168
  import {
181
169
  NonEmptyList3ak25ihy2gcvs as NonEmptyList,
@@ -188,8 +176,37 @@ import {
188
176
  initMetadataForCompanion(Companion);
189
177
  initMetadataForClass(sam$kotlin_Comparator$0, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
190
178
  initMetadataForClass(RustEmitter, 'RustEmitter', RustEmitter, VOID, [IrEmitter]);
191
- initMetadataForObject(RustTransform, 'RustTransform');
192
179
  //endregion
180
+ function get_wirespecImports() {
181
+ _init_properties_RustEmitter_kt__ix9brc();
182
+ return wirespecImports;
183
+ }
184
+ var wirespecImports;
185
+ function get_sharedImports() {
186
+ _init_properties_RustEmitter_kt__ix9brc();
187
+ return sharedImports;
188
+ }
189
+ var sharedImports;
190
+ function get_sharedDerive() {
191
+ _init_properties_RustEmitter_kt__ix9brc();
192
+ return sharedDerive;
193
+ }
194
+ var sharedDerive;
195
+ function get_sharedMethod() {
196
+ _init_properties_RustEmitter_kt__ix9brc();
197
+ return sharedMethod;
198
+ }
199
+ var sharedMethod;
200
+ function get_sharedTraits() {
201
+ _init_properties_RustEmitter_kt__ix9brc();
202
+ return sharedTraits;
203
+ }
204
+ var sharedTraits;
205
+ function get_sharedClientAndServer() {
206
+ _init_properties_RustEmitter_kt__ix9brc();
207
+ return sharedClientAndServer;
208
+ }
209
+ var sharedClientAndServer;
193
210
  function _get_sanitizationConfig__sns434($this) {
194
211
  var tmp0 = $this.q38_1;
195
212
  var tmp = KProperty1;
@@ -197,226 +214,117 @@ function _get_sanitizationConfig__sns434($this) {
197
214
  getPropertyCallableRef('sanitizationConfig', 1, tmp, RustEmitter$_get_sanitizationConfig_$ref_1dtj2x(), null);
198
215
  return tmp0.o1();
199
216
  }
200
- function sanitize($this, $receiver) {
201
- // Inline function 'kotlin.collections.mapIndexed' call
202
- var this_0 = split($receiver.o1(), ['.', ' ']);
203
- // Inline function 'kotlin.collections.mapIndexedTo' call
204
- var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
205
- var index = 0;
206
- var _iterator__ex2g4s = this_0.t();
217
+ function sharedFile($this) {
218
+ // Inline function 'community.flock.wirespec.compiler.core.ir.findElement' call
219
+ // Inline function 'kotlin.collections.filterIsInstance' call
220
+ var tmp0 = convert(Companion_instance.at('shared')).hv();
221
+ // Inline function 'kotlin.collections.filterIsInstanceTo' call
222
+ var destination = ArrayList_init_$Create$();
223
+ var _iterator__ex2g4s = tmp0.t();
207
224
  while (_iterator__ex2g4s.u()) {
208
- var item = _iterator__ex2g4s.v();
209
- var _unary__edvuaz = index;
210
- index = _unary__edvuaz + 1 | 0;
211
- var tmp$ret$2 = checkIndexOverflow(_unary__edvuaz) > 0 ? Companion_instance.zr(item) : item;
212
- destination.x(tmp$ret$2);
213
- }
214
- // Inline function 'kotlin.text.filter' call
215
- var tmp0 = joinToString(destination, '');
216
- // Inline function 'kotlin.text.filterTo' call
217
- var destination_0 = StringBuilder_init_$Create$();
218
- var inductionVariable = 0;
219
- var last = charSequenceLength(tmp0);
220
- if (inductionVariable < last)
221
- do {
222
- var index_0 = inductionVariable;
223
- inductionVariable = inductionVariable + 1 | 0;
224
- var element = charSequenceGet(tmp0, index_0);
225
- if (isLetterOrDigit(element) || element === _Char___init__impl__6a9atx(95)) {
226
- destination_0.s(element);
227
- }
225
+ var element = _iterator__ex2g4s.v();
226
+ if (element instanceof Namespace) {
227
+ destination.x(element);
228
228
  }
229
- while (inductionVariable < last);
230
- // Inline function 'kotlin.let' call
231
- var it = destination_0.toString();
232
- var tmp;
233
- var tmp0_safe_receiver = firstOrNull(it);
234
- var tmp_0;
235
- var tmp_1 = tmp0_safe_receiver;
236
- if ((tmp_1 == null ? null : new Char(tmp_1)) == null) {
237
- tmp_0 = null;
238
- } else {
239
- tmp_0 = isDigit(tmp0_safe_receiver);
240
- }
241
- if (tmp_0 === true) {
242
- tmp = '_' + it;
243
- } else {
244
- tmp = it;
245
- }
246
- // Inline function 'kotlin.let' call
247
- var it_0 = tmp;
248
- var tmp_2;
249
- if ($receiver instanceof FieldIdentifier) {
250
- tmp_2 = sanitizeKeywords($this, it_0);
251
- } else {
252
- tmp_2 = it_0;
253
- }
254
- var tmp$ret$8 = tmp_2;
255
- return toSnakeCase($this, tmp$ret$8);
256
- }
257
- function toSnakeCase($this, $receiver) {
258
- return Companion_getInstance().au($receiver).eu();
259
- }
260
- function toPascalCase($this, $receiver) {
261
- var tmp = split($receiver, ['_']);
262
- return joinToString(tmp, '', VOID, VOID, VOID, VOID, RustEmitter$toPascalCase$lambda);
263
- }
264
- function sanitizeKeywords($this, $receiver) {
265
- return Companion_getInstance_0().n37().i1($receiver) ? 'r#' + $receiver : $receiver;
266
- }
267
- function sanitizeEnum($this, $receiver) {
268
- // Inline function 'kotlin.let' call
269
- var it = toPascalCase($this, joinToString(split($receiver, ['-', ', ', '.', ' ', '//']), '_'));
270
- var tmp;
271
- var tmp0_safe_receiver = firstOrNull(it);
272
- var tmp_0;
273
- var tmp_1 = tmp0_safe_receiver;
274
- if ((tmp_1 == null ? null : new Char(tmp_1)) == null) {
275
- tmp_0 = null;
276
- } else {
277
- tmp_0 = isDigit(tmp0_safe_receiver);
278
- }
279
- if (tmp_0 === true) {
280
- tmp = '_' + it;
281
- } else {
282
- tmp = it;
283
- }
284
- return tmp;
285
- }
286
- function prependImports($this, $receiver, imports) {
287
- var tmp;
288
- // Inline function 'kotlin.collections.isNotEmpty' call
289
- if (!imports.r()) {
290
- tmp = $receiver.jv(VOID, plus(imports, $receiver.gv_1));
291
- } else {
292
- tmp = $receiver;
293
229
  }
294
- return tmp;
295
- }
296
- function containsWildcard($this, type) {
297
- var tmp;
298
- if (equals(type, Wildcard_instance)) {
299
- tmp = true;
300
- } else {
301
- if (type instanceof Custom) {
302
- var tmp0 = type.su_1;
303
- var tmp$ret$0;
304
- $l$block_0: {
305
- // Inline function 'kotlin.collections.any' call
306
- var tmp_0;
307
- if (isInterface(tmp0, Collection)) {
308
- tmp_0 = tmp0.r();
309
- } else {
310
- tmp_0 = false;
311
- }
312
- if (tmp_0) {
313
- tmp$ret$0 = false;
314
- break $l$block_0;
315
- }
316
- var _iterator__ex2g4s = tmp0.t();
317
- while (_iterator__ex2g4s.u()) {
318
- var element = _iterator__ex2g4s.v();
319
- if (containsWildcard($this, element)) {
320
- tmp$ret$0 = true;
321
- break $l$block_0;
322
- }
323
- }
324
- tmp$ret$0 = false;
325
- }
326
- tmp = tmp$ret$0;
230
+ var tmp$ret$0 = firstOrNull(destination);
231
+ // Inline function 'kotlin.collections.flatMap' call
232
+ var tmp0_0 = ensureNotNull(tmp$ret$0).mv_1;
233
+ // Inline function 'kotlin.collections.flatMapTo' call
234
+ var destination_0 = ArrayList_init_$Create$();
235
+ var _iterator__ex2g4s_0 = tmp0_0.t();
236
+ while (_iterator__ex2g4s_0.u()) {
237
+ var element_0 = _iterator__ex2g4s_0.v();
238
+ var tmp;
239
+ var tmp_0;
240
+ if (element_0 instanceof Enum) {
241
+ tmp_0 = element_0.ww_1.equals(Companion_getInstance().au('Method'));
327
242
  } else {
328
- if (type instanceof Nullable) {
329
- tmp = containsWildcard($this, type.vu_1);
330
- } else {
331
- if (type instanceof Array_0) {
332
- tmp = containsWildcard($this, type.mu_1);
333
- } else {
334
- if (type instanceof Dict) {
335
- tmp = containsWildcard($this, type.ou_1) || containsWildcard($this, type.pu_1);
336
- } else {
337
- tmp = false;
338
- }
339
- }
340
- }
243
+ tmp_0 = false;
341
244
  }
342
- }
343
- return tmp;
344
- }
345
- function containsUnderiveable($this, type) {
346
- var tmp;
347
- if (equals(type, Any_instance)) {
348
- tmp = true;
349
- } else {
350
- if (equals(type, Reflect_instance)) {
351
- tmp = true;
245
+ if (tmp_0) {
246
+ tmp = listOf(get_sharedMethod());
352
247
  } else {
353
- if (type instanceof Function) {
354
- tmp = true;
248
+ if (element_0 instanceof Interface) {
249
+ var tmp1_elvis_lhs = get_sharedTraits().t2(element_0.rv_1.du());
250
+ tmp = listOf(tmp1_elvis_lhs == null ? withSelfReceivers(element_0) : tmp1_elvis_lhs);
355
251
  } else {
356
- if (type instanceof Custom) {
357
- var tmp0 = type.su_1;
358
- var tmp$ret$0;
252
+ if (element_0 instanceof Struct) {
253
+ // Inline function 'kotlin.takeIf' call
254
+ var this_0 = get_sharedDerive();
255
+ var tmp_1;
256
+ var tmp0_1 = fieldList(element_0);
257
+ var tmp$ret$8;
359
258
  $l$block_0: {
360
- // Inline function 'kotlin.collections.any' call
361
- var tmp_0;
362
- if (isInterface(tmp0, Collection)) {
363
- tmp_0 = tmp0.r();
259
+ // Inline function 'kotlin.collections.all' call
260
+ var tmp_2;
261
+ if (isInterface(tmp0_1, Collection)) {
262
+ tmp_2 = tmp0_1.r();
364
263
  } else {
365
- tmp_0 = false;
264
+ tmp_2 = false;
366
265
  }
367
- if (tmp_0) {
368
- tmp$ret$0 = false;
266
+ if (tmp_2) {
267
+ tmp$ret$8 = true;
369
268
  break $l$block_0;
370
269
  }
371
- var _iterator__ex2g4s = tmp0.t();
372
- while (_iterator__ex2g4s.u()) {
373
- var element = _iterator__ex2g4s.v();
374
- if (containsUnderiveable($this, element)) {
375
- tmp$ret$0 = true;
270
+ var _iterator__ex2g4s_1 = tmp0_1.t();
271
+ while (_iterator__ex2g4s_1.u()) {
272
+ var element_1 = _iterator__ex2g4s_1.v();
273
+ if (!isDerivable(element_1.bw_1)) {
274
+ tmp$ret$8 = false;
376
275
  break $l$block_0;
377
276
  }
378
277
  }
379
- tmp$ret$0 = false;
278
+ tmp$ret$8 = true;
380
279
  }
381
- tmp = tmp$ret$0;
382
- } else {
383
- if (type instanceof Nullable) {
384
- tmp = containsUnderiveable($this, type.vu_1);
280
+ if (tmp$ret$8) {
281
+ tmp_1 = this_0;
385
282
  } else {
386
- if (type instanceof Array_0) {
387
- tmp = containsUnderiveable($this, type.mu_1);
388
- } else {
389
- if (type instanceof Dict) {
390
- tmp = containsUnderiveable($this, type.ou_1) || containsUnderiveable($this, type.pu_1);
391
- } else {
392
- tmp = false;
393
- }
394
- }
283
+ tmp_1 = null;
395
284
  }
285
+ var tmp$ret$6 = tmp_1;
286
+ tmp = listOfNotNull([tmp$ret$6, element_0]);
287
+ } else {
288
+ tmp = listOf(element_0);
396
289
  }
397
290
  }
398
291
  }
292
+ var list = tmp;
293
+ addAll(destination_0, list);
399
294
  }
400
- return tmp;
295
+ // Inline function 'kotlin.let' call
296
+ return new File(Companion_getInstance().au('Wirespec'), plus(plus(get_sharedImports(), destination_0), get_sharedClientAndServer()));
401
297
  }
402
- function buildClientParams($this, $receiver) {
403
- var params = requestParameters($receiver);
404
- var argsStr = joinToString(params, ', ', VOID, VOID, VOID, VOID, RustEmitter$buildClientParams$lambda($this));
405
- var tmp;
406
- if (params.r()) {
407
- tmp = '';
408
- } else {
409
- tmp = ', ' + joinToString(params, ', ', VOID, VOID, VOID, VOID, RustEmitter$buildClientParams$lambda_0($this));
298
+ function modFile($this, directory, definitions) {
299
+ var tmp = Companion_getInstance().au($this.m38_1.dt() + directory + 'mod');
300
+ return new File(tmp, listOf(new RawElement(joinToString(definitions, '\n', VOID, VOID, VOID, VOID, RustEmitter$modFile$lambda))));
301
+ }
302
+ function _get_clientName__yc59yj($this, $receiver) {
303
+ return $receiver.gr_1.o1() + 'Client';
304
+ }
305
+ function clientParameters($this, $receiver) {
306
+ // Inline function 'kotlin.collections.map' call
307
+ var this_0 = requestParameters($receiver);
308
+ // Inline function 'kotlin.collections.mapTo' call
309
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
310
+ var _iterator__ex2g4s = this_0.t();
311
+ while (_iterator__ex2g4s.u()) {
312
+ var item = _iterator__ex2g4s.v();
313
+ var name = item.af();
314
+ var type = item.bf();
315
+ var tmp$ret$2 = to(sanitizeKeywords(name.eu()), rustName(type));
316
+ destination.x(tmp$ret$2);
410
317
  }
411
- var paramsStr = tmp;
412
- return to(paramsStr, argsStr);
318
+ // Inline function 'kotlin.let' call
319
+ var tmp = joinToString(destination, '', VOID, VOID, VOID, VOID, RustEmitter$clientParameters$lambda);
320
+ return to(tmp, joinToString(destination, ', ', VOID, VOID, VOID, VOID, RustEmitter$clientParameters$lambda_0));
413
321
  }
414
322
  function Companion() {
415
323
  Companion_instance_2 = this;
416
- this.t38_1 = RustGenerator_getInstance();
324
+ this.r38_1 = RustGenerator_getInstance();
417
325
  }
418
326
  protoOf(Companion).n37 = function () {
419
- return this.t38_1.r1c_1;
327
+ return this.r38_1.r1c_1;
420
328
  };
421
329
  var Companion_instance_2;
422
330
  function Companion_getInstance_0() {
@@ -425,16 +333,16 @@ function Companion_getInstance_0() {
425
333
  return Companion_instance_2;
426
334
  }
427
335
  function sam$kotlin_Comparator$0(function_0) {
428
- this.u38_1 = function_0;
336
+ this.s38_1 = function_0;
429
337
  }
430
338
  protoOf(sam$kotlin_Comparator$0).zd = function (a, b) {
431
- return this.u38_1(a, b);
339
+ return this.s38_1(a, b);
432
340
  };
433
341
  protoOf(sam$kotlin_Comparator$0).compare = function (a, b) {
434
342
  return this.zd(a, b);
435
343
  };
436
344
  protoOf(sam$kotlin_Comparator$0).p3 = function () {
437
- return this.u38_1;
345
+ return this.s38_1;
438
346
  };
439
347
  protoOf(sam$kotlin_Comparator$0).equals = function (other) {
440
348
  var tmp;
@@ -472,7 +380,7 @@ function RustEmitter$sanitizationConfig$delegate$lambda$lambda_1(name) {
472
380
  }
473
381
  function RustEmitter$sanitizationConfig$delegate$lambda$lambda_2(it) {
474
382
  var tmp;
475
- var tmp0_safe_receiver = firstOrNull(it);
383
+ var tmp0_safe_receiver = firstOrNull_0(it);
476
384
  var tmp_0;
477
385
  var tmp_1 = tmp0_safe_receiver;
478
386
  if ((tmp_1 == null ? null : new Char(tmp_1)) == null) {
@@ -495,7 +403,7 @@ function RustEmitter$sanitizationConfig$delegate$lambda$lambda_3(this$0) {
495
403
  // Inline function 'kotlin.collections.map' call
496
404
  var this_0 = stmt.hu_1;
497
405
  // Inline function 'kotlin.collections.mapTo' call
498
- var destination = ArrayList_init_$Create$(this_0.c1());
406
+ var destination = ArrayList_init_$Create$_0(this_0.c1());
499
407
  // Inline function 'kotlin.collections.iterator' call
500
408
  var _iterator__ex2g4s = this_0.m1().t();
501
409
  while (_iterator__ex2g4s.u()) {
@@ -529,339 +437,66 @@ function RustEmitter$_get_sanitizationConfig_$ref_1dtj2x() {
529
437
  return _get_sanitizationConfig__sns434(p0);
530
438
  };
531
439
  }
532
- function RustEmitter$emitShared$lambda($this$interface) {
533
- $this$interface.o17(Custom_init_$Create$('Headers'));
534
- return Unit_instance;
535
- }
536
- function RustEmitter$emitShared$lambda_0($this$interface) {
537
- $this$interface.o17(Custom_init_$Create$('Headers'));
538
- return Unit_instance;
539
- }
540
- function RustEmitter$emitShared$lambda_1($this$interface) {
541
- $this$interface.o17(Custom_init_$Create$('Sized'));
542
- $this$interface.k16('label', VOID, VOID, RustEmitter$emitShared$lambda$lambda);
543
- $this$interface.k16('from_label', true, VOID, RustEmitter$emitShared$lambda$lambda_0);
544
- return Unit_instance;
545
- }
546
- function RustEmitter$emitShared$lambda$lambda($this$function) {
547
- $this$function.a14('&self', Custom_init_$Create$(''));
548
- $this$function.x13(Custom_init_$Create$('&str'));
549
- return Unit_instance;
550
- }
551
- function RustEmitter$emitShared$lambda$lambda_0($this$function) {
552
- $this$function.a14('s', Custom_init_$Create$('&str'));
553
- $this$function.x13(Custom_init_$Create$('Option<Self>'));
554
- return Unit_instance;
555
- }
556
- function RustEmitter$emitShared$lambda_2($this$interface) {
557
- $this$interface.w13($this$interface.e15('T', []), []);
558
- $this$interface.k16('value', VOID, VOID, RustEmitter$emitShared$lambda$lambda_1);
559
- $this$interface.k16('validate', VOID, VOID, RustEmitter$emitShared$lambda$lambda_2);
560
- return Unit_instance;
561
- }
562
- function RustEmitter$emitShared$lambda$lambda_1($this$function) {
563
- $this$function.a14('&self', Custom_init_$Create$(''));
564
- $this$function.x13(borrow($this$function.e15('T', [])));
565
- return Unit_instance;
566
- }
567
- function RustEmitter$emitShared$lambda$lambda_2($this$function) {
568
- $this$function.a14('&self', Custom_init_$Create$(''));
569
- $this$function.x13($this$function.y14());
570
- return Unit_instance;
571
- }
572
- function RustEmitter$emitShared$lambda_3($this$interface) {
573
- $this$interface.w13($this$interface.e15('T', []), []);
574
- $this$interface.p17('path', borrowDyn($this$interface.e15('Path', [])));
575
- $this$interface.p17('method', borrow($this$interface.e15('Method', [])));
576
- $this$interface.p17('queries', borrowDyn($this$interface.e15('Queries', [])));
577
- $this$interface.p17('headers', borrowDyn($this$interface.e15('RequestHeaders', [])));
578
- $this$interface.p17('body', borrow($this$interface.e15('T', [])));
579
- return Unit_instance;
580
- }
581
- function RustEmitter$emitShared$lambda_4($this$interface) {
582
- $this$interface.w13($this$interface.e15('T', []), []);
583
- $this$interface.p17('status', $this$interface.c17());
584
- $this$interface.p17('headers', borrowDyn($this$interface.e15('ResponseHeaders', [])));
585
- $this$interface.p17('body', borrow($this$interface.e15('T', [])));
586
- return Unit_instance;
587
- }
588
- function RustEmitter$emitShared$lambda_5($this$interface) {
589
- $this$interface.o16('transport', VOID, VOID, RustEmitter$emitShared$lambda$lambda_3);
590
- return Unit_instance;
591
- }
592
- function RustEmitter$emitShared$lambda$lambda_3($this$asyncFunction) {
593
- $this$asyncFunction.a14('&self', Custom_init_$Create$(''));
594
- $this$asyncFunction.a14('request', borrow($this$asyncFunction.e15('RawRequest', [])));
595
- $this$asyncFunction.x13($this$asyncFunction.e15('RawResponse', []));
596
- return Unit_instance;
597
- }
598
- function RustEmitter$emitShared$lambda_6($rustImports) {
599
- return function (element, transformer) {
600
- var tmp;
601
- if (element instanceof File) {
602
- // Inline function 'kotlin.collections.filterIsInstance' call
603
- var tmp0 = element.gv_1;
604
- // Inline function 'kotlin.collections.filterIsInstanceTo' call
605
- var destination = ArrayList_init_$Create$_0();
606
- var _iterator__ex2g4s = tmp0.t();
607
- while (_iterator__ex2g4s.u()) {
608
- var element_0 = _iterator__ex2g4s.v();
609
- if (element_0 instanceof Namespace) {
610
- destination.x(element_0);
611
- }
612
- }
613
- var namespace = first(destination);
614
- tmp = element.jv(VOID, plus($rustImports, namespace.mv_1));
615
- } else {
616
- tmp = element;
617
- }
618
- var transformed = tmp;
619
- return transformChildren_0(transformed, transformer);
620
- };
621
- }
622
- function RustEmitter$emitShared$lambda_7(element, transformer) {
623
- var tmp;
624
- if (element instanceof Enum) {
625
- var tmp_0;
626
- if (element.ww_1.equals(Companion_getInstance().au('Method'))) {
627
- tmp_0 = new RawElement('#[derive(Debug, Clone, Default, PartialEq)]\npub enum Method {\n #[default]\n GET,\n PUT,\n POST,\n DELETE,\n OPTIONS,\n HEAD,\n PATCH,\n TRACE,\n}');
628
- } else {
629
- tmp_0 = element;
630
- }
631
- tmp = tmp_0;
632
- } else {
633
- tmp = element;
634
- }
635
- var transformed = tmp;
636
- return transformChildren_0(transformed, transformer);
637
- }
638
- function RustEmitter$emitShared$lambda_8($dslTraits, $requestHeaders, $responseHeaders, $rawElementInterfaces, $client, $server) {
639
- return function (element, transformer) {
640
- var tmp;
641
- if (element instanceof File) {
642
- // Inline function 'kotlin.collections.flatMap' call
643
- var tmp0 = element.gv_1;
644
- // Inline function 'kotlin.collections.flatMapTo' call
645
- var destination = ArrayList_init_$Create$_0();
646
- var _iterator__ex2g4s = tmp0.t();
647
- while (_iterator__ex2g4s.u()) {
648
- var element_0 = _iterator__ex2g4s.v();
649
- var tmp$ret$3;
650
- $l$block: {
651
- if (!(element_0 instanceof Interface)) {
652
- tmp$ret$3 = listOf(element_0);
653
- break $l$block;
654
- }
655
- var name = element_0.rv_1.du();
656
- var tmp_0;
657
- // Inline function 'kotlin.collections.contains' call
658
- // Inline function 'kotlin.collections.containsKey' call
659
- var this_0 = $dslTraits;
660
- if ((isInterface(this_0, KtMap) ? this_0 : THROW_CCE()).r2(name)) {
661
- // Inline function 'kotlin.collections.buildList' call
662
- // Inline function 'kotlin.collections.buildListInternal' call
663
- // Inline function 'kotlin.apply' call
664
- var this_1 = ArrayList_init_$Create$_0();
665
- this_1.x(ensureNotNull($dslTraits.t2(name)));
666
- if (name === 'Request') {
667
- this_1.x($requestHeaders);
668
- }
669
- if (name === 'Response') {
670
- this_1.x($responseHeaders);
671
- }
672
- tmp_0 = this_1.r5();
673
- } else {
674
- // Inline function 'kotlin.collections.contains' call
675
- // Inline function 'kotlin.collections.containsKey' call
676
- var this_2 = $rawElementInterfaces;
677
- if ((isInterface(this_2, KtMap) ? this_2 : THROW_CCE()).r2(name)) {
678
- tmp_0 = listOf(ensureNotNull($rawElementInterfaces.t2(name)));
679
- } else {
680
- tmp_0 = listOf(element_0);
681
- }
682
- }
683
- tmp$ret$3 = tmp_0;
684
- }
685
- var list = tmp$ret$3;
686
- addAll(destination, list);
687
- }
688
- var newElements = plus_0(plus_0(destination, $client), $server);
689
- tmp = element.jv(VOID, newElements);
690
- } else {
691
- tmp = element;
692
- }
693
- var transformed = tmp;
694
- return transformChildren_0(transformed, transformer);
695
- };
696
- }
697
- function RustEmitter$emitShared$lambda_9(element, transformer) {
698
- var tmp;
699
- if (element instanceof Interface) {
700
- // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
701
- var scope = new TransformScope(element);
702
- // Inline function 'community.flock.wirespec.compiler.core.ir.TransformScope.matchingElements' call
703
- var tmp_0 = scope;
704
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformMatchingElements' call
705
- var this_0 = scope.e19_1;
706
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformer' call
707
- // Inline function 'kotlin.apply' call
708
- var this_1 = new TransformerBuilder();
709
- this_1.y19(RustEmitter$emitShared$lambda$lambda_4);
710
- var tmp$ret$5 = this_1.t19();
711
- tmp_0.e19_1 = transform(this_0, tmp$ret$5);
712
- var tmp_1 = scope.e19_1;
713
- tmp = isInterface(tmp_1, Element) ? tmp_1 : THROW_CCE();
714
- } else {
715
- tmp = element;
716
- }
717
- var transformed = tmp;
718
- return transformChildren_0(transformed, transformer);
719
- }
720
- function RustEmitter$emitShared$lambda$lambda_4(element, transformer) {
721
- var tmp;
722
- if (element instanceof Function_0) {
723
- var tmp0 = element.tx_1;
724
- var tmp$ret$1;
725
- $l$block_0: {
726
- // Inline function 'kotlin.collections.any' call
727
- var tmp_0;
728
- if (isInterface(tmp0, Collection)) {
729
- tmp_0 = tmp0.r();
730
- } else {
731
- tmp_0 = false;
732
- }
733
- if (tmp_0) {
734
- tmp$ret$1 = false;
735
- break $l$block_0;
736
- }
737
- var _iterator__ex2g4s = tmp0.t();
738
- while (_iterator__ex2g4s.u()) {
739
- var element_0 = _iterator__ex2g4s.v();
740
- if (element_0.oz_1.bu() === '&self' || element_0.oz_1.bu() === 'self') {
741
- tmp$ret$1 = true;
742
- break $l$block_0;
743
- }
744
- }
745
- tmp$ret$1 = false;
746
- }
747
- var hasSelf = tmp$ret$1;
748
- tmp = hasSelf || element.xx_1 ? element : element.dy(VOID, VOID, plus(listOf(get_rustSelfParam()), element.tx_1));
749
- } else {
750
- tmp = element;
751
- }
752
- var transformed = tmp;
753
- return transformChildren_0(transformed, transformer);
754
- }
755
- function RustEmitter$emitShared$lambda_10(group) {
756
- return trimEnd(joinToString(group, '', VOID, VOID, VOID, VOID, RustEmitter$emitShared$lambda$lambda_5), charArrayOf([_Char___init__impl__6a9atx(10)]));
757
- }
758
- function RustEmitter$emitShared$lambda$lambda_5(it) {
759
- return RustGenerator_getInstance().m1b(it);
760
- }
761
440
  function RustEmitter$emit$lambda(a, b) {
762
441
  // Inline function 'kotlin.comparisons.compareValuesBy' call
763
442
  var tmp = sortKey(a);
764
443
  var tmp$ret$2 = sortKey(b);
765
444
  return compareValues(tmp, tmp$ret$2);
766
445
  }
767
- function emit$emitMod(this$0, def) {
768
- return 'pub mod ' + sanitize(this$0, def.es()) + ';';
769
- }
770
- function RustEmitter$emit$lambda_0(this$0) {
771
- return function (it) {
772
- return emit$emitMod(this$0, it);
773
- };
774
- }
775
- function RustEmitter$emit$lambda_1(this$0) {
776
- return function (it) {
777
- return emit$emitMod(this$0, it);
778
- };
779
- }
780
- function RustEmitter$emitGenerator$lambda(it) {
781
- return startsWith(it, 'Wirespec.') || it === 'Wirespec';
446
+ function RustEmitter$modFile$lambda(it) {
447
+ return 'pub mod ' + moduleName(it.es()) + ';';
782
448
  }
783
- function RustEmitter$emitGenerator$lambda_0($generatorOwnName) {
784
- return function (it) {
785
- return it === $generatorOwnName;
786
- };
787
- }
788
- function RustEmitter$emitGenerator$lambda_1(it) {
789
- return substringBefore(it, _Char___init__impl__6a9atx(60));
790
- }
791
- function RustEmitter$emitGenerator$lambda_2($generatorOwnName, $generatorRefs) {
449
+ function RustEmitter$emitGenerator$lambda($$this$buildSet) {
792
450
  return function (expr, t) {
793
451
  var tmp;
794
452
  var tmp_0;
795
- var tmp_1;
796
453
  if (expr instanceof RawExpression) {
797
- tmp_1 = endsWith(expr.gy_1, 'Generator');
798
- } else {
799
- tmp_1 = false;
800
- }
801
- if (tmp_1) {
802
- tmp_0 = !(expr.gy_1 === $generatorOwnName);
454
+ tmp_0 = endsWith(expr.gy_1, 'Generator');
803
455
  } else {
804
456
  tmp_0 = false;
805
457
  }
806
458
  if (tmp_0) {
807
- $generatorRefs.x(expr.gy_1);
459
+ $$this$buildSet.x(expr.gy_1);
808
460
  tmp = Unit_instance;
809
461
  }
810
- return transformChildren_1(expr, t);
462
+ return transformChildren_0(expr, t);
811
463
  };
812
464
  }
813
- function RustEmitter$emit$lambda_2(this$0) {
465
+ function RustEmitter$emit$lambda_0(it) {
466
+ return sanitizeKeywords(sanitizeEnum(it));
467
+ }
468
+ function RustEmitter$emitClient$lambda(this$0) {
814
469
  return function (it) {
815
- return sanitizeKeywords(this$0, sanitizeEnum(this$0, it));
470
+ return 'pub mod ' + toSnakeCase(_get_clientName__yc59yj(this$0, it)) + ';';
816
471
  };
817
472
  }
818
- function RustEmitter$emitClient$lambda(this$0) {
473
+ function RustEmitter$emitClient$lambda_0(this$0) {
819
474
  return function (endpoint) {
820
- return 'pub mod ' + toSnakeCase(this$0, endpoint.gr_1.o1() + 'Client') + ';';
475
+ var module_0 = toSnakeCase(endpoint.gr_1.o1());
476
+ var _destruct__k2r9zo = clientParameters(this$0, endpoint);
477
+ var params = _destruct__k2r9zo.af();
478
+ var args = _destruct__k2r9zo.bf();
479
+ return trimIndent('\n impl<S: Serialization, T: Transportation> ' + module_0 + '::' + endpoint.gr_1.o1() + '::Call for Client<S, T> {\n async fn ' + module_0 + '(&self' + params + ') -> ' + module_0 + '::Response {\n ' + _get_clientName__yc59yj(this$0, endpoint) + ' { serialization: &self.serialization, transportation: &self.transportation }\n .' + module_0 + '(' + args + ').await\n }\n }\n ');
821
480
  };
822
481
  }
823
- function RustEmitter$toPascalCase$lambda(s) {
824
- // Inline function 'kotlin.text.replaceFirstChar' call
825
- var tmp;
826
- // Inline function 'kotlin.text.isNotEmpty' call
827
- if (charSequenceLength(s) > 0) {
828
- var it = charCodeAt(s, 0);
829
- var tmp0 = uppercaseChar(it);
830
- // Inline function 'kotlin.text.plus' call
831
- var other = substring(s, 1);
832
- tmp = toString(tmp0) + other;
833
- } else {
834
- tmp = s;
835
- }
836
- return tmp;
837
- }
838
- function RustEmitter$buildClientParams$lambda(this$0) {
839
- return function (_destruct__k2r9zo) {
840
- var name = _destruct__k2r9zo.af();
841
- return sanitizeKeywords(this$0, name.eu());
842
- };
482
+ function RustEmitter$clientParameters$lambda(_destruct__k2r9zo) {
483
+ var name = _destruct__k2r9zo.af();
484
+ var type = _destruct__k2r9zo.bf();
485
+ return ', ' + name + ': ' + type;
843
486
  }
844
- function RustEmitter$buildClientParams$lambda_0(this$0) {
845
- return function (_destruct__k2r9zo) {
846
- var name = _destruct__k2r9zo.af();
847
- var type = _destruct__k2r9zo.bf();
848
- var tmp = sanitizeKeywords(this$0, name.eu());
849
- // Inline function 'kotlin.with' call
850
- return tmp + ': ' + RustTransform_getInstance().a39(type);
851
- };
487
+ function RustEmitter$clientParameters$lambda_0(it) {
488
+ return it.gf_1;
852
489
  }
853
490
  function RustEmitter(packageName, emitShared) {
854
491
  Companion_getInstance_0();
855
- packageName = packageName === VOID ? Companion_instance_0.at('community.flock.wirespec.generated') : packageName;
856
- emitShared = emitShared === VOID ? Companion_instance_1.gq() : emitShared;
492
+ packageName = packageName === VOID ? Companion_instance.at('community.flock.wirespec.generated') : packageName;
493
+ emitShared = emitShared === VOID ? Companion_instance_0.gq() : emitShared;
857
494
  this.m38_1 = packageName;
858
495
  this.n38_1 = emitShared;
859
496
  this.o38_1 = RustGenerator_getInstance();
860
497
  this.p38_1 = FileExtension_Rust_getInstance();
861
498
  var tmp = this;
862
499
  tmp.q38_1 = lazy(RustEmitter$sanitizationConfig$delegate$lambda(this));
863
- this.r38_1 = listOf_0([import_0('super::super::wirespec', '*'), import_0('', 'regex')]);
864
- this.s38_1 = listOf_0([import_0('super::super::wirespec', '*'), import_0('', 'regex')]);
865
500
  }
866
501
  protoOf(RustEmitter).l1b = function () {
867
502
  return this.o38_1;
@@ -870,186 +505,13 @@ protoOf(RustEmitter).xp = function () {
870
505
  return this.p38_1;
871
506
  };
872
507
  protoOf(RustEmitter).g1b = function () {
873
- var rustImports = listOf_0([import_0('std::any', 'TypeId'), import_0('std::collections', 'HashMap')]);
874
- var requestHeaders = interface_0('RequestHeaders', VOID, RustEmitter$emitShared$lambda);
875
- var responseHeaders = interface_0('ResponseHeaders', VOID, RustEmitter$emitShared$lambda_0);
876
- var client = new RawElement('pub trait Client {\n type Transport: Transportation;\n type Ser: Serialization;\n fn transport(&self) -> &Self::Transport;\n fn serialization(&self) -> &Self::Ser;\n}');
877
- var server = new RawElement("pub trait Server {\n type Req;\n type Res;\n fn path_template(&self) -> &'static str;\n fn method(&self) -> Method;\n}");
878
- var enumTrait = interface_0('Enum', VOID, RustEmitter$emitShared$lambda_1);
879
- var refinedTrait = interface_0('Refined', VOID, RustEmitter$emitShared$lambda_2);
880
- var requestTrait = interface_0('Request', VOID, RustEmitter$emitShared$lambda_3);
881
- var responseTrait = interface_0('Response', VOID, RustEmitter$emitShared$lambda_4);
882
- var rawElementInterfaces = mapOf([to('BodySerializer', new RawElement("pub trait BodySerializer {\n fn serialize_body<T: 'static>(&self, t: &T, r#type: TypeId) -> Vec<u8>;\n}")), to('BodyDeserializer', new RawElement("pub trait BodyDeserializer {\n fn deserialize_body<T: 'static>(&self, raw: &[u8], r#type: TypeId) -> T;\n}")), to('PathSerializer', new RawElement('pub trait PathSerializer {\n fn serialize_path<T: std::fmt::Display>(&self, t: &T, r#type: TypeId) -> String;\n}')), to('PathDeserializer', new RawElement('pub trait PathDeserializer {\n fn deserialize_path<T: std::str::FromStr>(&self, raw: &str, r#type: TypeId) -> T where T::Err: std::fmt::Debug;\n}')), to('ParamSerializer', new RawElement("pub trait ParamSerializer {\n fn serialize_param<T: 'static>(&self, value: &T, r#type: TypeId) -> Vec<String>;\n}")), to('ParamDeserializer', new RawElement("pub trait ParamDeserializer {\n fn deserialize_param<T: 'static>(&self, values: &[String], r#type: TypeId) -> T;\n}"))]);
883
- var transportationTrait = interface_0('Transportation', VOID, RustEmitter$emitShared$lambda_5);
884
- var dslTraits = mapOf([to('Enum', enumTrait), to('Refined', refinedTrait), to('Request', requestTrait), to('Response', responseTrait), to('Transportation', transportationTrait)]);
885
- // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
886
- var this_0 = convert(Companion_instance_0.at('shared'));
887
- var scope = new TransformScope(this_0);
888
- // Inline function 'community.flock.wirespec.compiler.core.ir.TransformScope.matchingElements' call
889
- var tmp = scope;
890
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformMatchingElements' call
891
- var this_1 = scope.e19_1;
892
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformer' call
893
- // Inline function 'kotlin.apply' call
894
- var this_2 = new TransformerBuilder();
895
- this_2.y19(RustEmitter$emitShared$lambda_6(rustImports));
896
- var tmp$ret$4 = this_2.t19();
897
- tmp.e19_1 = transform(this_1, tmp$ret$4);
898
- // Inline function 'community.flock.wirespec.compiler.core.ir.TransformScope.matchingElements' call
899
- var tmp_0 = scope;
900
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformMatchingElements' call
901
- var this_3 = scope.e19_1;
902
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformer' call
903
- // Inline function 'kotlin.apply' call
904
- var this_4 = new TransformerBuilder();
905
- this_4.y19(RustEmitter$emitShared$lambda_7);
906
- var tmp$ret$9 = this_4.t19();
907
- tmp_0.e19_1 = transform(this_3, tmp$ret$9);
908
- // Inline function 'community.flock.wirespec.compiler.core.ir.TransformScope.matchingElements' call
909
- var tmp_1 = scope;
910
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformMatchingElements' call
911
- var this_5 = scope.e19_1;
912
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformer' call
913
- // Inline function 'kotlin.apply' call
914
- var this_6 = new TransformerBuilder();
915
- this_6.y19(RustEmitter$emitShared$lambda_8(dslTraits, requestHeaders, responseHeaders, rawElementInterfaces, client, server));
916
- var tmp$ret$14 = this_6.t19();
917
- tmp_1.e19_1 = transform(this_5, tmp$ret$14);
918
- var tmp_2 = scope.e19_1;
919
- // Inline function 'kotlin.let' call
920
- var file = isInterface(tmp_2, Element) ? tmp_2 : THROW_CCE();
921
- // Inline function 'kotlin.collections.flatMap' call
922
- var tmp0 = file.gv_1;
923
- // Inline function 'kotlin.collections.flatMapTo' call
924
- var destination = ArrayList_init_$Create$_0();
925
- var _iterator__ex2g4s = tmp0.t();
926
- while (_iterator__ex2g4s.u()) {
927
- var element = _iterator__ex2g4s.v();
928
- var tmp$ret$21;
929
- $l$block: {
930
- if (!(element instanceof Struct)) {
931
- tmp$ret$21 = listOf(element);
932
- break $l$block;
933
- }
934
- var structFields = fieldList(element);
935
- var tmp_3;
936
- var tmp$ret$22;
937
- $l$block_1: {
938
- // Inline function 'kotlin.collections.any' call
939
- var tmp_4;
940
- if (isInterface(structFields, Collection)) {
941
- tmp_4 = structFields.r();
942
- } else {
943
- tmp_4 = false;
944
- }
945
- if (tmp_4) {
946
- tmp$ret$22 = false;
947
- break $l$block_1;
948
- }
949
- var _iterator__ex2g4s_0 = structFields.t();
950
- while (_iterator__ex2g4s_0.u()) {
951
- var element_0 = _iterator__ex2g4s_0.v();
952
- if (containsUnderiveable(this, element_0.bw_1)) {
953
- tmp$ret$22 = true;
954
- break $l$block_1;
955
- }
956
- }
957
- tmp$ret$22 = false;
958
- }
959
- if (tmp$ret$22) {
960
- tmp_3 = '';
961
- } else {
962
- var tmp$ret$24;
963
- $l$block_3: {
964
- // Inline function 'kotlin.collections.any' call
965
- var tmp_5;
966
- if (isInterface(structFields, Collection)) {
967
- tmp_5 = structFields.r();
968
- } else {
969
- tmp_5 = false;
970
- }
971
- if (tmp_5) {
972
- tmp$ret$24 = false;
973
- break $l$block_3;
974
- }
975
- var _iterator__ex2g4s_1 = structFields.t();
976
- while (_iterator__ex2g4s_1.u()) {
977
- var element_1 = _iterator__ex2g4s_1.v();
978
- if (containsWildcard(this, element_1.bw_1)) {
979
- tmp$ret$24 = true;
980
- break $l$block_3;
981
- }
982
- }
983
- tmp$ret$24 = false;
984
- }
985
- if (tmp$ret$24) {
986
- tmp_3 = '#[derive(Debug, Default)]';
987
- } else {
988
- if (setOf(['RawRequest', 'RawResponse']).i1(element.fx_1.du())) {
989
- tmp_3 = '#[derive(Debug, Clone, PartialEq)]';
990
- } else {
991
- tmp_3 = '#[derive(Debug, Clone, Default, PartialEq)]';
992
- }
993
- }
994
- }
995
- var derive = tmp_3;
996
- var tmp_6;
997
- // Inline function 'kotlin.text.isEmpty' call
998
- if (charSequenceLength(derive) === 0) {
999
- tmp_6 = emptyList();
1000
- } else {
1001
- tmp_6 = listOf(new RawElement(derive));
1002
- }
1003
- var prefix = tmp_6;
1004
- tmp$ret$21 = listOf(new File(element.fx_1, plus_0(prefix, element)));
1005
- }
1006
- var list = tmp$ret$21;
1007
- addAll(destination, list);
1008
- }
1009
- var tmp0_0 = new File(file.fv_1, destination);
1010
- // Inline function 'kotlin.let' call
1011
- var wirespecFile = RustTransform_getInstance().b39(tmp0_0);
1012
- // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
1013
- var scope_0 = new TransformScope(wirespecFile);
1014
- // Inline function 'community.flock.wirespec.compiler.core.ir.TransformScope.matchingElements' call
1015
- var tmp_7 = scope_0;
1016
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformMatchingElements' call
1017
- var this_7 = scope_0.e19_1;
1018
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformer' call
1019
- // Inline function 'kotlin.apply' call
1020
- var this_8 = new TransformerBuilder();
1021
- this_8.y19(RustEmitter$emitShared$lambda_9);
1022
- var tmp$ret$33 = this_8.t19();
1023
- tmp_7.e19_1 = transform(this_7, tmp$ret$33);
1024
- var tmp_8 = scope_0.e19_1;
1025
- // Inline function 'kotlin.let' call
1026
- var tmp0_1 = (isInterface(tmp_8, Element) ? tmp_8 : THROW_CCE()).gv_1;
1027
- // Inline function 'kotlin.collections.mutableListOf' call
1028
- // Inline function 'kotlin.collections.fold' call
1029
- var accumulator = ArrayList_init_$Create$_0();
1030
- var _iterator__ex2g4s_2 = tmp0_1.t();
1031
- while (_iterator__ex2g4s_2.u()) {
1032
- var element_2 = _iterator__ex2g4s_2.v();
1033
- var acc = accumulator;
1034
- var isImport = element_2 instanceof Import;
1035
- var tmp0_safe_receiver = lastOrNull(acc);
1036
- var tmp_9 = tmp0_safe_receiver == null ? null : firstOrNull_0(tmp0_safe_receiver);
1037
- var lastGroupIsImports = tmp_9 instanceof Import;
1038
- if (isImport && lastGroupIsImports)
1039
- last(acc).x(element_2);
1040
- else
1041
- acc.x(mutableListOf([element_2]));
1042
- accumulator = acc;
1043
- }
1044
- var groups = accumulator;
1045
- var source = joinToString(groups, '\n\n', VOID, VOID, VOID, VOID, RustEmitter$emitShared$lambda_10) + '\n';
1046
- var tmp_10;
508
+ var tmp;
1047
509
  if (this.n38_1.hq_1) {
1048
- tmp_10 = new File(Companion_getInstance().au(this.m38_1.dt() + 'wirespec'), listOf(new RawElement(source)));
510
+ tmp = new File(Companion_getInstance().au(this.m38_1.dt() + 'wirespec'), listOf(new RawElement(this.l1b().m1b(sharedFile(this)))));
1049
511
  } else {
1050
- tmp_10 = null;
512
+ tmp = null;
1051
513
  }
1052
- return tmp_10;
514
+ return tmp;
1053
515
  };
1054
516
  protoOf(RustEmitter).f1b = function (module_0, logger) {
1055
517
  // Inline function 'kotlin.collections.sortedBy' call
@@ -1059,13 +521,11 @@ protoOf(RustEmitter).f1b = function (module_0, logger) {
1059
521
  var tmp$ret$1 = new sam$kotlin_Comparator$0(tmp);
1060
522
  var tmp$ret$0 = sortedWith(this_0, tmp$ret$1);
1061
523
  var tmp_0 = toNonEmptyListOrNull(tmp$ret$0);
1062
- var statements = ensureNotNull(tmp_0 == null ? null : new NonEmptyList(tmp_0)).en_1;
1063
- // Inline function 'kotlin.let' call
1064
- var files = emit.call(this, module_0.up(VOID, statements), logger);
524
+ var files = emit.call(this, module_0.up(VOID, ensureNotNull(tmp_0 == null ? null : new NonEmptyList(tmp_0)).en_1), logger);
1065
525
  // Inline function 'kotlin.collections.filterIsInstance' call
1066
526
  var tmp0 = new NonEmptyList(module_0.hp_1);
1067
527
  // Inline function 'kotlin.collections.filterIsInstanceTo' call
1068
- var destination = ArrayList_init_$Create$_0();
528
+ var destination = ArrayList_init_$Create$();
1069
529
  var _iterator__ex2g4s = tmp0.t();
1070
530
  while (_iterator__ex2g4s.u()) {
1071
531
  var element = _iterator__ex2g4s.v();
@@ -1074,7 +534,6 @@ protoOf(RustEmitter).f1b = function (module_0, logger) {
1074
534
  }
1075
535
  }
1076
536
  var endpoints = destination;
1077
- var endpointMods = joinToString(endpoints, '\n', VOID, VOID, VOID, VOID, RustEmitter$emit$lambda_0(this));
1078
537
  var tmp_1;
1079
538
  // Inline function 'kotlin.collections.isNotEmpty' call
1080
539
  if (!endpoints.r()) {
@@ -1084,53 +543,29 @@ protoOf(RustEmitter).f1b = function (module_0, logger) {
1084
543
  }
1085
544
  var clientMod = tmp_1;
1086
545
  var modRs = new File(Companion_getInstance().au(this.m38_1.dt() + 'mod'), listOf(new RawElement('#![allow(warnings)]\npub mod model;\npub mod endpoint;' + clientMod + '\npub mod wirespec;')));
1087
- var modEndpoint = new File(Companion_getInstance().au(this.m38_1.dt() + 'endpoint/' + 'mod'), listOf(new RawElement(endpointMods)));
1088
- var tmp_2 = Companion_getInstance().au(this.m38_1.dt() + 'model/' + 'mod');
1089
- // Inline function 'kotlin.collections.filterIsInstance' call
1090
- var tmp0_0 = new NonEmptyList(module_0.hp_1);
1091
- // Inline function 'kotlin.collections.filterIsInstanceTo' call
1092
- var destination_0 = ArrayList_init_$Create$_0();
1093
- var _iterator__ex2g4s_0 = tmp0_0.t();
1094
- while (_iterator__ex2g4s_0.u()) {
1095
- var element_0 = _iterator__ex2g4s_0.v();
1096
- if (!(element_0 == null) ? isInterface(element_0, Model) : false) {
1097
- destination_0.x(element_0);
546
+ var tmp_2;
547
+ if (this.n38_1.hq_1) {
548
+ var tmp_3 = NonEmptyList__plus_impl_xqmb9(NonEmptyList__plus_impl_xqmb9(files, modRs), modFile(this, 'endpoint/', endpoints));
549
+ // Inline function 'kotlin.collections.filterIsInstance' call
550
+ var tmp0_0 = new NonEmptyList(module_0.hp_1);
551
+ // Inline function 'kotlin.collections.filterIsInstanceTo' call
552
+ var destination_0 = ArrayList_init_$Create$();
553
+ var _iterator__ex2g4s_0 = tmp0_0.t();
554
+ while (_iterator__ex2g4s_0.u()) {
555
+ var element_0 = _iterator__ex2g4s_0.v();
556
+ if (!(element_0 == null) ? isInterface(element_0, Model) : false) {
557
+ destination_0.x(element_0);
558
+ }
1098
559
  }
560
+ tmp_2 = NonEmptyList__plus_impl_xqmb9(tmp_3, modFile(this, 'model/', destination_0));
561
+ } else {
562
+ tmp_2 = NonEmptyList__plus_impl_xqmb9(files, modRs);
1099
563
  }
1100
- var tmp_3 = destination_0;
1101
- var modModel = new File(tmp_2, listOf(new RawElement(joinToString(tmp_3, '\n', VOID, VOID, VOID, VOID, RustEmitter$emit$lambda_1(this)))));
1102
- return this.n38_1.hq_1 ? NonEmptyList__plus_impl_xqmb9(NonEmptyList__plus_impl_xqmb9(NonEmptyList__plus_impl_xqmb9(files, modRs), modEndpoint), modModel) : NonEmptyList__plus_impl_xqmb9(files, modRs);
564
+ return tmp_2;
1103
565
  };
1104
566
  protoOf(RustEmitter).ds = function (definition, module_0, logger) {
1105
- var subPackageName = plus_1(this.m38_1, definition);
1106
- var tmp;
1107
- if (definition instanceof Endpoint) {
1108
- tmp = this.s38_1;
1109
- } else {
1110
- tmp = this.r38_1;
1111
- }
1112
- var importHeader = tmp;
1113
- var tmp0 = emit_0.call(this, definition, module_0, logger);
1114
- // Inline function 'kotlin.let' call
1115
- var file = RustTransform_getInstance().b39(tmp0);
1116
- var tmp_0 = Companion_getInstance().au(subPackageName.dt() + toSnakeCase(this, file.fv_1.du()));
1117
- // Inline function 'kotlin.collections.flatMap' call
1118
- var tmp0_0 = file.gv_1;
1119
- // Inline function 'kotlin.collections.flatMapTo' call
1120
- var destination = ArrayList_init_$Create$_0();
1121
- var _iterator__ex2g4s = tmp0_0.t();
1122
- while (_iterator__ex2g4s.u()) {
1123
- var element = _iterator__ex2g4s.v();
1124
- var tmp_1;
1125
- if (element instanceof Struct) {
1126
- tmp_1 = listOf_0([new RawElement('#[derive(Debug, Clone, Default, PartialEq)]'), element]);
1127
- } else {
1128
- tmp_1 = listOf(element);
1129
- }
1130
- var list = tmp_1;
1131
- addAll(destination, list);
1132
- }
1133
- return new File(tmp_0, plus(importHeader, destination));
567
+ var file = applyBorrowRules(emit_0.call(this, definition, module_0, logger));
568
+ return new File(Companion_getInstance().au(plus_1(this.m38_1, definition).dt() + toSnakeCase(file.fv_1.du())), plus(get_wirespecImports(), withStructDerives(file.gv_1)));
1134
569
  };
1135
570
  protoOf(RustEmitter).o1b = function (definition, module_0) {
1136
571
  var tmp;
@@ -1146,74 +581,127 @@ protoOf(RustEmitter).o1b = function (definition, module_0) {
1146
581
  if (definition instanceof Union) {
1147
582
  tmp = convertToGenerator(definition);
1148
583
  } else {
1149
- return null;
584
+ var tmp_0;
585
+ var tmp_1;
586
+ if (definition instanceof Endpoint) {
587
+ tmp_1 = true;
588
+ } else {
589
+ tmp_1 = definition instanceof Channel;
590
+ }
591
+ if (tmp_1) {
592
+ tmp_0 = true;
593
+ } else {
594
+ var tmp_2;
595
+ if (definition instanceof Rpc) {
596
+ tmp_2 = true;
597
+ } else {
598
+ tmp_2 = definition instanceof Part;
599
+ }
600
+ tmp_0 = tmp_2;
601
+ }
602
+ if (tmp_0) {
603
+ tmp = null;
604
+ } else {
605
+ noWhenBranchMatchedException();
606
+ }
1150
607
  }
1151
608
  }
1152
609
  }
1153
610
  }
1154
- var generatorFile = sanitizeNames(tmp, _get_sanitizationConfig__sns434(this));
1155
- var generatorOwnName = definition.es().o1() + 'Generator';
1156
- var tmp_0 = asSequence(collectCustomTypeNames(generatorFile));
1157
- var tmp_1 = filterNot(tmp_0, RustEmitter$emitGenerator$lambda);
1158
- var tmp_2 = filterNot(tmp_1, RustEmitter$emitGenerator$lambda_0(generatorOwnName));
1159
- var customNames = toList(distinct(map(tmp_2, RustEmitter$emitGenerator$lambda_1)));
1160
- // Inline function 'kotlin.collections.mutableSetOf' call
1161
- var generatorRefs = LinkedHashSet_init_$Create$();
1162
- // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
1163
- var scope = new TransformScope(generatorFile);
1164
- scope.v19(RustEmitter$emitGenerator$lambda_2(generatorOwnName, generatorRefs));
1165
- var tmp_3 = scope.e19_1;
1166
- isInterface(tmp_3, Element) || THROW_CCE();
1167
- // Inline function 'kotlin.collections.filter' call
1168
- // Inline function 'kotlin.collections.filterTo' call
1169
- var destination = ArrayList_init_$Create$_0();
1170
- var _iterator__ex2g4s = customNames.t();
1171
- while (_iterator__ex2g4s.u()) {
1172
- var element = _iterator__ex2g4s.v();
1173
- if (endsWith(element, 'Generator')) {
1174
- destination.x(element);
611
+ var tmp1_safe_receiver = tmp;
612
+ var tmp2_safe_receiver = tmp1_safe_receiver == null ? null : sanitizeNames(tmp1_safe_receiver, _get_sanitizationConfig__sns434(this));
613
+ var tmp_3;
614
+ if (tmp2_safe_receiver == null) {
615
+ tmp_3 = null;
616
+ } else {
617
+ // Inline function 'kotlin.let' call
618
+ // Inline function 'kotlin.collections.buildSet' call
619
+ // Inline function 'kotlin.collections.buildSetInternal' call
620
+ // Inline function 'kotlin.apply' call
621
+ var this_0 = LinkedHashSet_init_$Create$();
622
+ // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
623
+ var scope = new TransformScope(tmp2_safe_receiver);
624
+ scope.v19(RustEmitter$emitGenerator$lambda(this_0));
625
+ var tmp_4 = scope.e19_1;
626
+ isInterface(tmp_4, Element) || THROW_CCE();
627
+ var generatorReferences = this_0.r5();
628
+ // Inline function 'kotlin.collections.filterNot' call
629
+ var tmp0 = collectCustomTypeNames(tmp2_safe_receiver);
630
+ // Inline function 'kotlin.collections.filterNotTo' call
631
+ var destination = ArrayList_init_$Create$();
632
+ var _iterator__ex2g4s = tmp0.t();
633
+ while (_iterator__ex2g4s.u()) {
634
+ var element = _iterator__ex2g4s.v();
635
+ if (!(startsWith(element, 'Wirespec.') || element === 'Wirespec')) {
636
+ destination.x(element);
637
+ }
1175
638
  }
1176
- }
1177
- // Inline function 'kotlin.collections.map' call
1178
- var this_0 = distinct_0(plus(destination, generatorRefs));
1179
- // Inline function 'kotlin.collections.mapTo' call
1180
- var destination_0 = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
1181
- var _iterator__ex2g4s_0 = this_0.t();
1182
- while (_iterator__ex2g4s_0.u()) {
1183
- var item = _iterator__ex2g4s_0.v();
1184
- var tmp$ret$8 = import_0('super::' + toSnakeCase(this, item), item);
1185
- destination_0.x(tmp$ret$8);
1186
- }
1187
- var generatorImports = destination_0;
1188
- // Inline function 'kotlin.collections.filterNot' call
1189
- // Inline function 'kotlin.collections.filterNotTo' call
1190
- var destination_1 = ArrayList_init_$Create$_0();
1191
- var _iterator__ex2g4s_1 = customNames.t();
1192
- while (_iterator__ex2g4s_1.u()) {
1193
- var element_0 = _iterator__ex2g4s_1.v();
1194
- if (!endsWith(element_0, 'Generator')) {
1195
- destination_1.x(element_0);
639
+ // Inline function 'kotlin.collections.map' call
640
+ // Inline function 'kotlin.collections.mapTo' call
641
+ var destination_0 = ArrayList_init_$Create$_0(collectionSizeOrDefault(destination, 10));
642
+ var _iterator__ex2g4s_0 = destination.t();
643
+ while (_iterator__ex2g4s_0.u()) {
644
+ var item = _iterator__ex2g4s_0.v();
645
+ var tmp$ret$13 = substringBefore(item, _Char___init__impl__6a9atx(60));
646
+ destination_0.x(tmp$ret$13);
1196
647
  }
648
+ // Inline function 'kotlin.collections.filterNot' call
649
+ var tmp0_0 = distinct(plus(destination_0, generatorReferences));
650
+ // Inline function 'kotlin.collections.filterNotTo' call
651
+ var destination_1 = ArrayList_init_$Create$();
652
+ var _iterator__ex2g4s_1 = tmp0_0.t();
653
+ while (_iterator__ex2g4s_1.u()) {
654
+ var element_0 = _iterator__ex2g4s_1.v();
655
+ if (!(element_0 === definition.es().o1() + 'Generator')) {
656
+ destination_1.x(element_0);
657
+ }
658
+ }
659
+ // Inline function 'kotlin.collections.partition' call
660
+ var first = ArrayList_init_$Create$();
661
+ var second = ArrayList_init_$Create$();
662
+ var _iterator__ex2g4s_2 = destination_1.t();
663
+ while (_iterator__ex2g4s_2.u()) {
664
+ var element_1 = _iterator__ex2g4s_2.v();
665
+ if (endsWith(element_1, 'Generator')) {
666
+ first.x(element_1);
667
+ } else {
668
+ second.x(element_1);
669
+ }
670
+ }
671
+ var _destruct__k2r9zo = new Pair(first, second);
672
+ var generators = _destruct__k2r9zo.af();
673
+ var types = _destruct__k2r9zo.bf();
674
+ var tmp_5 = Companion_getInstance().au(plus_2(this.m38_1, 'generator').dt() + toSnakeCase(tmp2_safe_receiver.fv_1.du()));
675
+ var tmp_6 = get_wirespecImports();
676
+ // Inline function 'kotlin.collections.map' call
677
+ // Inline function 'kotlin.collections.mapTo' call
678
+ var destination_2 = ArrayList_init_$Create$_0(collectionSizeOrDefault(types, 10));
679
+ var _iterator__ex2g4s_3 = types.t();
680
+ while (_iterator__ex2g4s_3.u()) {
681
+ var item_0 = _iterator__ex2g4s_3.v();
682
+ var tmp$ret$21 = import_0('super::super::model::' + toSnakeCase(item_0), item_0);
683
+ destination_2.x(tmp$ret$21);
684
+ }
685
+ var tmp_7 = plus(tmp_6, destination_2);
686
+ // Inline function 'kotlin.collections.map' call
687
+ // Inline function 'kotlin.collections.mapTo' call
688
+ var destination_3 = ArrayList_init_$Create$_0(collectionSizeOrDefault(generators, 10));
689
+ var _iterator__ex2g4s_4 = generators.t();
690
+ while (_iterator__ex2g4s_4.u()) {
691
+ var item_1 = _iterator__ex2g4s_4.v();
692
+ var tmp$ret$24 = import_0('super::' + toSnakeCase(item_1), item_1);
693
+ destination_3.x(tmp$ret$24);
694
+ }
695
+ tmp_3 = new File(tmp_5, plus(plus(tmp_7, destination_3), tmp2_safe_receiver.gv_1));
1197
696
  }
1198
- // Inline function 'kotlin.collections.map' call
1199
- // Inline function 'kotlin.collections.mapTo' call
1200
- var destination_2 = ArrayList_init_$Create$(collectionSizeOrDefault(destination_1, 10));
1201
- var _iterator__ex2g4s_2 = destination_1.t();
1202
- while (_iterator__ex2g4s_2.u()) {
1203
- var item_0 = _iterator__ex2g4s_2.v();
1204
- var tmp$ret$14 = import_0('super::super::model::' + toSnakeCase(this, item_0), item_0);
1205
- destination_2.x(tmp$ret$14);
1206
- }
1207
- var typeImports = destination_2;
1208
- var subPackageName = plus_2(this.m38_1, 'generator');
1209
- return new File(Companion_getInstance().au(subPackageName.dt() + toSnakeCase(this, generatorFile.fv_1.du())), plus(plus(plus(this.r38_1, typeImports), generatorImports), generatorFile.gv_1));
697
+ return tmp_3;
1210
698
  };
1211
699
  protoOf(RustEmitter).vs = function (type, module_0) {
1212
- return prependImports(this, sanitizeNames(convert_0(type), _get_sanitizationConfig__sns434(this)), buildModelImports(type));
700
+ return withImports(sanitizeNames(convert_0(type), _get_sanitizationConfig__sns434(this)), toImports(importReferences(type), 'super::'));
1213
701
  };
1214
702
  protoOf(RustEmitter).ts = function (enum_0, module_0) {
1215
703
  var tmp = convert_1(enum_0);
1216
- return sanitizeEnumEntries(tmp, RustEmitter$emit$lambda_2(this));
704
+ return sanitizeEnumEntries(tmp, RustEmitter$emit$lambda_0);
1217
705
  };
1218
706
  protoOf(RustEmitter).js = function (union) {
1219
707
  return convert_2(union);
@@ -1223,17 +711,13 @@ protoOf(RustEmitter).os = function (refined) {
1223
711
  };
1224
712
  protoOf(RustEmitter).us = function (endpoint) {
1225
713
  // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
1226
- var this_0 = stripResponseGenerics(stripHandlerExtends(convertSimpleRawExpressionsToVariableRefs(stripWirespecPrefix(flattenForRust(convert_4(endpoint))))));
714
+ var this_0 = stripResponseGenerics(rustHandlerTraits(convertSimpleRawExpressionsToVariableRefs(stripWirespecPrefix(flattenForRust(convert_4(endpoint))))));
1227
715
  var scope = new TransformScope(this_0);
1228
716
  scope.j19(fixResponseSwitchPatterns());
717
+ scope.j19(fixConstructorCalls());
1229
718
  var tmp = scope.e19_1;
1230
- // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
1231
- var this_1 = isInterface(tmp, Element) ? tmp : THROW_CCE();
1232
- var scope_0 = new TransformScope(this_1);
1233
- scope_0.j19(fixConstructorCalls());
1234
- var tmp_0 = scope_0.e19_1;
1235
- var tmp$ret$2 = isInterface(tmp_0, Element) ? tmp_0 : THROW_CCE();
1236
- return prependImports(this, sanitizeNames(injectApiStruct(injectResponseFromImpls(injectHandlerImplForClient(injectSelfToHandlerMethods(tmp$ret$2))), endpoint), _get_sanitizationConfig__sns434(this)), buildEndpointImports(endpoint));
719
+ var tmp$ret$0 = isInterface(tmp, Element) ? tmp : THROW_CCE();
720
+ return withImports(sanitizeNames(injectApiStruct(injectResponseFromImpls(injectHandlerImplForClient(tmp$ret$0)), endpoint), _get_sanitizationConfig__sns434(this)), toImports(importReferences(endpoint), 'super::super::model::'));
1237
721
  };
1238
722
  protoOf(RustEmitter).is = function (channel) {
1239
723
  return convert_5(channel);
@@ -1241,155 +725,53 @@ protoOf(RustEmitter).is = function (channel) {
1241
725
  protoOf(RustEmitter).hs = function (rpc) {
1242
726
  // Inline function 'kotlin.let' call
1243
727
  var file = convert_6(rpc);
1244
- // Inline function 'kotlin.collections.distinctBy' call
1245
- var this_0 = importReferences(rpc);
1246
- var set = HashSet_init_$Create$();
1247
- var list = ArrayList_init_$Create$_0();
728
+ var tmp = toImports(importReferences(rpc), 'super::super::model::');
729
+ // Inline function 'kotlin.collections.map' call
730
+ var this_0 = file.gv_1;
731
+ // Inline function 'kotlin.collections.mapTo' call
732
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
1248
733
  var _iterator__ex2g4s = this_0.t();
1249
734
  while (_iterator__ex2g4s.u()) {
1250
- var e = _iterator__ex2g4s.v();
1251
- var key = e.b1a_1;
1252
- if (set.x(key)) {
1253
- list.x(e);
1254
- }
1255
- }
1256
- // Inline function 'kotlin.collections.map' call
1257
- // Inline function 'kotlin.collections.mapTo' call
1258
- var destination = ArrayList_init_$Create$(collectionSizeOrDefault(list, 10));
1259
- var _iterator__ex2g4s_0 = list.t();
1260
- while (_iterator__ex2g4s_0.u()) {
1261
- var item = _iterator__ex2g4s_0.v();
1262
- var tmp$ret$6 = import_0('super::super::model::' + toSnakeCase(this, item.b1a_1), Companion_getInstance().au(item.b1a_1).du());
1263
- destination.x(tmp$ret$6);
1264
- }
1265
- var rpcImports = destination;
1266
- // Inline function 'kotlin.collections.map' call
1267
- var this_1 = file.gv_1;
1268
- // Inline function 'kotlin.collections.mapTo' call
1269
- var destination_0 = ArrayList_init_$Create$(collectionSizeOrDefault(this_1, 10));
1270
- var _iterator__ex2g4s_1 = this_1.t();
1271
- while (_iterator__ex2g4s_1.u()) {
1272
- var item_0 = _iterator__ex2g4s_1.v();
1273
- var tmp;
1274
- if (item_0 instanceof Namespace) {
1275
- // Inline function 'kotlin.collections.flatMap' call
1276
- var tmp0 = item_0.mv_1;
1277
- // Inline function 'kotlin.collections.flatMapTo' call
1278
- var destination_1 = ArrayList_init_$Create$_0();
1279
- var _iterator__ex2g4s_2 = tmp0.t();
1280
- while (_iterator__ex2g4s_2.u()) {
1281
- var element = _iterator__ex2g4s_2.v();
1282
- var tmp_0;
1283
- if (element instanceof Struct) {
1284
- tmp_0 = listOf_0([new RawElement('#[derive(Debug, Clone, Default, PartialEq)]'), element]);
1285
- } else {
1286
- tmp_0 = listOf(element);
1287
- }
1288
- var list_0 = tmp_0;
1289
- addAll(destination_1, list_0);
1290
- }
1291
- tmp = item_0.qv(VOID, destination_1);
735
+ var item = _iterator__ex2g4s.v();
736
+ var tmp_0;
737
+ if (item instanceof Namespace) {
738
+ tmp_0 = item.qv(VOID, withStructDerives(item.mv_1));
1292
739
  } else {
1293
- tmp = item_0;
740
+ tmp_0 = item;
1294
741
  }
1295
- var tmp$ret$9 = tmp;
1296
- destination_0.x(tmp$ret$9);
742
+ var tmp$ret$4 = tmp_0;
743
+ destination.x(tmp$ret$4);
1297
744
  }
1298
- return file.jv(VOID, plus(rpcImports, destination_0));
745
+ return file.jv(VOID, plus(tmp, destination));
1299
746
  };
1300
747
  protoOf(RustEmitter).n1b = function (endpoint) {
1301
- var endpointName = endpoint.gr_1.o1();
1302
- var endpointModuleName = toSnakeCase(this, endpointName);
1303
- var clientName = endpointName + 'Client';
1304
- var methodName = toSnakeCase(this, endpointName);
1305
- var _destruct__k2r9zo = buildClientParams(this, endpoint);
1306
- var paramsStr = _destruct__k2r9zo.af();
1307
- var requestArgs = _destruct__k2r9zo.bf();
1308
- var requestConstruction = endpointModuleName + '::Request::new(' + requestArgs + ')';
1309
- // Inline function 'kotlin.collections.distinctBy' call
1310
- var this_0 = importReferences(endpoint);
1311
- var set = HashSet_init_$Create$();
1312
- var list = ArrayList_init_$Create$_0();
1313
- var _iterator__ex2g4s = this_0.t();
1314
- while (_iterator__ex2g4s.u()) {
1315
- var e = _iterator__ex2g4s.v();
1316
- var key = e.b1a_1;
1317
- if (set.x(key)) {
1318
- list.x(e);
1319
- }
1320
- }
1321
- // Inline function 'kotlin.collections.map' call
1322
- // Inline function 'kotlin.collections.mapTo' call
1323
- var destination = ArrayList_init_$Create$(collectionSizeOrDefault(list, 10));
1324
- var _iterator__ex2g4s_0 = list.t();
1325
- while (_iterator__ex2g4s_0.u()) {
1326
- var item = _iterator__ex2g4s_0.v();
1327
- var tmp$ret$4 = import_0('super::super::model::' + toSnakeCase(this, item.b1a_1), item.b1a_1);
1328
- destination.x(tmp$ret$4);
1329
- }
1330
- var modelImports = destination;
1331
- var namespacePath = endpointModuleName + '::' + endpointName;
1332
- // Inline function 'kotlin.collections.buildList' call
1333
- // Inline function 'kotlin.collections.buildListInternal' call
1334
- // Inline function 'kotlin.apply' call
1335
- var this_1 = ArrayList_init_$Create$_0();
1336
- this_1.x('pub struct ' + clientName + "<'a, S: Serialization, T: Transportation> {");
1337
- this_1.x(" pub serialization: &'a S,");
1338
- this_1.x(" pub transportation: &'a T,");
1339
- this_1.x('}');
1340
- this_1.x("impl<'a, S: Serialization, T: Transportation> " + namespacePath + '::Call for ' + clientName + "<'a, S, T> {");
1341
- this_1.x(' async fn ' + methodName + '(&self' + paramsStr + ') -> ' + endpointModuleName + '::Response {');
1342
- this_1.x(' let request = ' + requestConstruction + ';');
1343
- this_1.x(' let raw_request = ' + namespacePath + '::to_raw_request(self.serialization, request);');
1344
- this_1.x(' let raw_response = self.transportation.transport(&raw_request).await;');
1345
- this_1.x(' ' + namespacePath + '::from_raw_response(self.serialization, raw_response)');
1346
- this_1.x(' }');
1347
- this_1.x('}');
1348
- var tmp$ret$5 = this_1.r5();
1349
- var code = joinToString(tmp$ret$5, '\n');
1350
- var subPackageName = plus_2(this.m38_1, 'client');
1351
- var tmp = Companion_getInstance().au(subPackageName.dt() + toSnakeCase(this, clientName));
1352
- // Inline function 'kotlin.collections.buildList' call
1353
- // Inline function 'kotlin.collections.buildListInternal' call
1354
- // Inline function 'kotlin.apply' call
1355
- var this_2 = ArrayList_init_$Create$_0();
1356
- this_2.x(import_0('super::super::wirespec', '*'));
1357
- this_2.x(import_0('super::super::endpoint', endpointModuleName));
1358
- this_2.g1(modelImports);
1359
- this_2.x(new RawElement(code));
1360
- var tmp$ret$9 = this_2.r5();
1361
- return new File(tmp, tmp$ret$9);
748
+ var module_0 = toSnakeCase(endpoint.gr_1.o1());
749
+ var namespace = module_0 + '::' + endpoint.gr_1.o1();
750
+ var _destruct__k2r9zo = clientParameters(this, endpoint);
751
+ var params = _destruct__k2r9zo.af();
752
+ var args = _destruct__k2r9zo.bf();
753
+ var code = trimIndent('\n pub struct ' + _get_clientName__yc59yj(this, endpoint) + "<'a, S: Serialization, T: Transportation> {\n pub serialization: &'a S,\n pub transportation: &'a T,\n }\n impl<'a, S: Serialization, T: Transportation> " + namespace + '::Call for ' + _get_clientName__yc59yj(this, endpoint) + "<'a, S, T> {\n async fn " + module_0 + '(&self' + params + ') -> ' + module_0 + '::Response {\n let request = ' + module_0 + '::Request::new(' + args + ');\n let raw_request = ' + namespace + '::to_raw_request(self.serialization, request);\n let raw_response = self.transportation.transport(&raw_request).await;\n ' + namespace + '::from_raw_response(self.serialization, raw_response)\n }\n }\n ');
754
+ return new File(Companion_getInstance().au(plus_2(this.m38_1, 'client').dt() + toSnakeCase(_get_clientName__yc59yj(this, endpoint))), plus_0(plus(listOf_0([import_0('super::super::wirespec', '*'), import_0('super::super::endpoint', module_0)]), toImports(importReferences(endpoint), 'super::super::model::')), new RawElement(code)));
1362
755
  };
1363
756
  protoOf(RustEmitter).h1b = function (endpoints, logger) {
1364
757
  logger.bs('Emitting main Client for ' + endpoints.c1() + ' endpoints');
1365
758
  var modDeclarations = joinToString(endpoints, '\n', VOID, VOID, VOID, VOID, RustEmitter$emitClient$lambda(this));
1366
759
  // Inline function 'kotlin.collections.flatMap' call
1367
760
  // Inline function 'kotlin.collections.flatMapTo' call
1368
- var destination = ArrayList_init_$Create$_0();
761
+ var destination = ArrayList_init_$Create$();
1369
762
  var _iterator__ex2g4s = endpoints.t();
1370
763
  while (_iterator__ex2g4s.u()) {
1371
764
  var element = _iterator__ex2g4s.v();
1372
765
  var list = importReferences(element);
1373
766
  addAll(destination, list);
1374
767
  }
1375
- // Inline function 'kotlin.collections.distinctBy' call
1376
- var set = HashSet_init_$Create$();
1377
- var list_0 = ArrayList_init_$Create$_0();
1378
- var _iterator__ex2g4s_0 = destination.t();
1379
- while (_iterator__ex2g4s_0.u()) {
1380
- var e = _iterator__ex2g4s_0.v();
1381
- var key = e.b1a_1;
1382
- if (set.x(key)) {
1383
- list_0.x(e);
1384
- }
1385
- }
1386
768
  // Inline function 'kotlin.collections.filter' call
1387
769
  // Inline function 'kotlin.collections.filterTo' call
1388
- var destination_0 = ArrayList_init_$Create$_0();
1389
- var _iterator__ex2g4s_1 = list_0.t();
1390
- while (_iterator__ex2g4s_1.u()) {
1391
- var element_0 = _iterator__ex2g4s_1.v();
1392
- var tmp$ret$8;
770
+ var destination_0 = ArrayList_init_$Create$();
771
+ var _iterator__ex2g4s_0 = destination.t();
772
+ while (_iterator__ex2g4s_0.u()) {
773
+ var element_0 = _iterator__ex2g4s_0.v();
774
+ var tmp$ret$6;
1393
775
  $l$block_0: {
1394
776
  // Inline function 'kotlin.collections.none' call
1395
777
  var tmp;
@@ -1399,77 +781,294 @@ protoOf(RustEmitter).h1b = function (endpoints, logger) {
1399
781
  tmp = false;
1400
782
  }
1401
783
  if (tmp) {
1402
- tmp$ret$8 = true;
784
+ tmp$ret$6 = true;
1403
785
  break $l$block_0;
1404
786
  }
1405
- var _iterator__ex2g4s_2 = endpoints.t();
1406
- while (_iterator__ex2g4s_2.u()) {
1407
- var element_1 = _iterator__ex2g4s_2.v();
787
+ var _iterator__ex2g4s_1 = endpoints.t();
788
+ while (_iterator__ex2g4s_1.u()) {
789
+ var element_1 = _iterator__ex2g4s_1.v();
1408
790
  if (element_1.gr_1.o1() === element_0.b1a_1) {
1409
- tmp$ret$8 = false;
791
+ tmp$ret$6 = false;
1410
792
  break $l$block_0;
1411
793
  }
1412
794
  }
1413
- tmp$ret$8 = true;
795
+ tmp$ret$6 = true;
1414
796
  }
1415
- if (tmp$ret$8) {
797
+ if (tmp$ret$6) {
1416
798
  destination_0.x(element_0);
1417
799
  }
1418
800
  }
1419
- // Inline function 'kotlin.collections.map' call
1420
- // Inline function 'kotlin.collections.mapTo' call
1421
- var destination_1 = ArrayList_init_$Create$(collectionSizeOrDefault(destination_0, 10));
1422
- var _iterator__ex2g4s_3 = destination_0.t();
1423
- while (_iterator__ex2g4s_3.u()) {
1424
- var item = _iterator__ex2g4s_3.v();
1425
- var tmp$ret$12 = import_0('super::model::' + toSnakeCase(this, item.b1a_1), item.b1a_1);
1426
- destination_1.x(tmp$ret$12);
1427
- }
1428
- var modelImports = destination_1;
801
+ var modelImports = toImports(destination_0, 'super::model::');
1429
802
  // Inline function 'kotlin.collections.flatMap' call
1430
803
  // Inline function 'kotlin.collections.flatMapTo' call
1431
- var destination_2 = ArrayList_init_$Create$_0();
1432
- var _iterator__ex2g4s_4 = endpoints.t();
1433
- while (_iterator__ex2g4s_4.u()) {
1434
- var element_2 = _iterator__ex2g4s_4.v();
1435
- var endpointModuleName = toSnakeCase(this, element_2.gr_1.o1());
1436
- var clientModuleName = toSnakeCase(this, element_2.gr_1.o1() + 'Client');
1437
- var list_1 = listOf_0([import_0('super::endpoint', endpointModuleName), import_0(clientModuleName, element_2.gr_1.o1() + 'Client')]);
1438
- addAll(destination_2, list_1);
804
+ var destination_1 = ArrayList_init_$Create$();
805
+ var _iterator__ex2g4s_2 = endpoints.t();
806
+ while (_iterator__ex2g4s_2.u()) {
807
+ var element_2 = _iterator__ex2g4s_2.v();
808
+ var list_0 = listOf_0([import_0('super::endpoint', toSnakeCase(element_2.gr_1.o1())), import_0(toSnakeCase(_get_clientName__yc59yj(this, element_2)), _get_clientName__yc59yj(this, element_2))]);
809
+ addAll(destination_1, list_0);
810
+ }
811
+ var endpointAndClientImports = destination_1;
812
+ var implementations = joinToString(endpoints, '\n', VOID, VOID, VOID, VOID, RustEmitter$emitClient$lambda_0(this));
813
+ var code = 'pub struct Client<S: Serialization, T: Transportation> {\n pub serialization: S,\n pub transportation: T,\n}\n' + implementations;
814
+ return new File(Companion_getInstance().au(this.m38_1.dt() + 'client'), plus_0(plus(plus(listOf_0([new RawElement(modDeclarations), import_0('super::wirespec', '*')]), modelImports), endpointAndClientImports), new RawElement(code)));
815
+ };
816
+ function isDerivable(_this__u8e3s4) {
817
+ _init_properties_RustEmitter_kt__ix9brc();
818
+ var tmp;
819
+ var tmp_0;
820
+ if (equals(_this__u8e3s4, Any_instance)) {
821
+ tmp_0 = true;
822
+ } else {
823
+ tmp_0 = _this__u8e3s4 instanceof Function;
824
+ }
825
+ if (tmp_0) {
826
+ tmp = false;
827
+ } else {
828
+ if (_this__u8e3s4 instanceof Custom) {
829
+ var tmp0 = _this__u8e3s4.su_1;
830
+ var tmp$ret$0;
831
+ $l$block_0: {
832
+ // Inline function 'kotlin.collections.all' call
833
+ var tmp_1;
834
+ if (isInterface(tmp0, Collection)) {
835
+ tmp_1 = tmp0.r();
836
+ } else {
837
+ tmp_1 = false;
838
+ }
839
+ if (tmp_1) {
840
+ tmp$ret$0 = true;
841
+ break $l$block_0;
842
+ }
843
+ var _iterator__ex2g4s = tmp0.t();
844
+ while (_iterator__ex2g4s.u()) {
845
+ var element = _iterator__ex2g4s.v();
846
+ if (!isDerivable(element)) {
847
+ tmp$ret$0 = false;
848
+ break $l$block_0;
849
+ }
850
+ }
851
+ tmp$ret$0 = true;
852
+ }
853
+ tmp = tmp$ret$0;
854
+ } else {
855
+ if (_this__u8e3s4 instanceof Nullable) {
856
+ tmp = isDerivable(_this__u8e3s4.vu_1);
857
+ } else {
858
+ if (_this__u8e3s4 instanceof Array_0) {
859
+ tmp = isDerivable(_this__u8e3s4.mu_1);
860
+ } else {
861
+ if (_this__u8e3s4 instanceof Dict) {
862
+ tmp = (isDerivable(_this__u8e3s4.ou_1) && isDerivable(_this__u8e3s4.pu_1));
863
+ } else {
864
+ var tmp_2;
865
+ var tmp_3;
866
+ var tmp_4;
867
+ if (_this__u8e3s4 instanceof Integer) {
868
+ tmp_4 = true;
869
+ } else {
870
+ tmp_4 = _this__u8e3s4 instanceof Number_0;
871
+ }
872
+ if (tmp_4) {
873
+ tmp_3 = true;
874
+ } else {
875
+ tmp_3 = equals(_this__u8e3s4, String_instance) || (equals(_this__u8e3s4, Boolean_instance) || equals(_this__u8e3s4, Bytes_instance));
876
+ }
877
+ if (tmp_3) {
878
+ tmp_2 = true;
879
+ } else {
880
+ var tmp_5;
881
+ if (equals(_this__u8e3s4, Unit_instance_0) || equals(_this__u8e3s4, Wildcard_instance)) {
882
+ tmp_5 = true;
883
+ } else {
884
+ var tmp_6;
885
+ if (equals(_this__u8e3s4, Reflect_instance)) {
886
+ tmp_6 = true;
887
+ } else {
888
+ var tmp_7;
889
+ if (_this__u8e3s4 instanceof IntegerLiteral) {
890
+ tmp_7 = true;
891
+ } else {
892
+ tmp_7 = _this__u8e3s4 instanceof StringLiteral;
893
+ }
894
+ tmp_6 = tmp_7;
895
+ }
896
+ tmp_5 = tmp_6;
897
+ }
898
+ tmp_2 = tmp_5;
899
+ }
900
+ if (tmp_2) {
901
+ tmp = true;
902
+ } else {
903
+ noWhenBranchMatchedException();
904
+ }
905
+ }
906
+ }
907
+ }
908
+ }
909
+ }
910
+ return tmp;
911
+ }
912
+ function moduleName(_this__u8e3s4) {
913
+ _init_properties_RustEmitter_kt__ix9brc();
914
+ // Inline function 'kotlin.collections.mapIndexed' call
915
+ var this_0 = split(_this__u8e3s4.o1(), ['.', ' ']);
916
+ // Inline function 'kotlin.collections.mapIndexedTo' call
917
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
918
+ var index = 0;
919
+ var _iterator__ex2g4s = this_0.t();
920
+ while (_iterator__ex2g4s.u()) {
921
+ var item = _iterator__ex2g4s.v();
922
+ var _unary__edvuaz = index;
923
+ index = _unary__edvuaz + 1 | 0;
924
+ var tmp$ret$2 = checkIndexOverflow(_unary__edvuaz) > 0 ? Companion_instance_1.zr(item) : item;
925
+ destination.x(tmp$ret$2);
926
+ }
927
+ // Inline function 'kotlin.text.filter' call
928
+ var tmp0 = joinToString(destination, '');
929
+ // Inline function 'kotlin.text.filterTo' call
930
+ var destination_0 = StringBuilder_init_$Create$();
931
+ var inductionVariable = 0;
932
+ var last = charSequenceLength(tmp0);
933
+ if (inductionVariable < last)
934
+ do {
935
+ var index_0 = inductionVariable;
936
+ inductionVariable = inductionVariable + 1 | 0;
937
+ var element = charSequenceGet(tmp0, index_0);
938
+ if (isLetterOrDigit(element) || element === _Char___init__impl__6a9atx(95)) {
939
+ destination_0.s(element);
940
+ }
941
+ }
942
+ while (inductionVariable < last);
943
+ // Inline function 'kotlin.let' call
944
+ var it = destination_0.toString();
945
+ var tmp;
946
+ var tmp0_safe_receiver = firstOrNull_0(it);
947
+ var tmp_0;
948
+ var tmp_1 = tmp0_safe_receiver;
949
+ if ((tmp_1 == null ? null : new Char(tmp_1)) == null) {
950
+ tmp_0 = null;
951
+ } else {
952
+ tmp_0 = isDigit(tmp0_safe_receiver);
953
+ }
954
+ if (tmp_0 === true) {
955
+ tmp = '_' + it;
956
+ } else {
957
+ tmp = it;
1439
958
  }
1440
- var endpointAndClientImports = destination_2;
959
+ var tmp$ret$6 = tmp;
960
+ return toSnakeCase(tmp$ret$6);
961
+ }
962
+ function withStructDerives(_this__u8e3s4) {
963
+ _init_properties_RustEmitter_kt__ix9brc();
1441
964
  // Inline function 'kotlin.collections.flatMap' call
1442
965
  // Inline function 'kotlin.collections.flatMapTo' call
1443
- var destination_3 = ArrayList_init_$Create$_0();
1444
- var _iterator__ex2g4s_5 = endpoints.t();
1445
- while (_iterator__ex2g4s_5.u()) {
1446
- var element_3 = _iterator__ex2g4s_5.v();
1447
- var endpointName = element_3.gr_1.o1();
1448
- var endpointModuleName_0 = toSnakeCase(this, endpointName);
1449
- var namespacePath = endpointModuleName_0 + '::' + endpointName;
1450
- var methodName = toSnakeCase(this, endpointName);
1451
- var _destruct__k2r9zo = buildClientParams(this, element_3);
1452
- var paramsStr = _destruct__k2r9zo.af();
1453
- var callArgs = _destruct__k2r9zo.bf();
1454
- var delegateCall = endpointName + 'Client { serialization: &self.serialization, transportation: &self.transportation }\n' + (' .' + methodName + '(' + callArgs + ').await');
1455
- var list_2 = listOf_0(['impl<S: Serialization, T: Transportation> ' + namespacePath + '::Call for Client<S, T> {', ' async fn ' + methodName + '(&self' + paramsStr + ') -> ' + endpointModuleName_0 + '::Response {', ' ' + delegateCall, ' }', '}']);
1456
- addAll(destination_3, list_2);
966
+ var destination = ArrayList_init_$Create$();
967
+ var _iterator__ex2g4s = _this__u8e3s4.t();
968
+ while (_iterator__ex2g4s.u()) {
969
+ var element = _iterator__ex2g4s.v();
970
+ var tmp;
971
+ if (element instanceof Struct) {
972
+ tmp = listOf_0([new RawElement('#[derive(Debug, Clone, Default, PartialEq)]'), element]);
973
+ } else {
974
+ tmp = listOf(element);
975
+ }
976
+ var list = tmp;
977
+ addAll(destination, list);
1457
978
  }
1458
- var implBlocks = destination_3;
1459
- var code = joinToString(plus(listOf_0(['pub struct Client<S: Serialization, T: Transportation> {', ' pub serialization: S,', ' pub transportation: T,', '}']), implBlocks), '\n');
1460
- var tmp_0 = Companion_getInstance().au(this.m38_1.dt() + 'client');
1461
- // Inline function 'kotlin.collections.buildList' call
1462
- // Inline function 'kotlin.collections.buildListInternal' call
1463
- // Inline function 'kotlin.apply' call
1464
- var this_0 = ArrayList_init_$Create$_0();
1465
- this_0.x(new RawElement(modDeclarations));
1466
- this_0.x(import_0('super::wirespec', '*'));
1467
- this_0.g1(modelImports);
1468
- this_0.g1(endpointAndClientImports);
1469
- this_0.x(new RawElement(code));
1470
- var tmp$ret$19 = this_0.r5();
1471
- return new File(tmp_0, tmp$ret$19);
1472
- };
979
+ return destination;
980
+ }
981
+ function withImports(_this__u8e3s4, imports) {
982
+ _init_properties_RustEmitter_kt__ix9brc();
983
+ return _this__u8e3s4.jv(VOID, plus(imports, _this__u8e3s4.gv_1));
984
+ }
985
+ function toImports(_this__u8e3s4, path) {
986
+ _init_properties_RustEmitter_kt__ix9brc();
987
+ // Inline function 'kotlin.collections.distinctBy' call
988
+ var set = HashSet_init_$Create$();
989
+ var list = ArrayList_init_$Create$();
990
+ var _iterator__ex2g4s = _this__u8e3s4.t();
991
+ while (_iterator__ex2g4s.u()) {
992
+ var e = _iterator__ex2g4s.v();
993
+ var key = e.b1a_1;
994
+ if (set.x(key)) {
995
+ list.x(e);
996
+ }
997
+ }
998
+ // Inline function 'kotlin.collections.map' call
999
+ // Inline function 'kotlin.collections.mapTo' call
1000
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(list, 10));
1001
+ var _iterator__ex2g4s_0 = list.t();
1002
+ while (_iterator__ex2g4s_0.u()) {
1003
+ var item = _iterator__ex2g4s_0.v();
1004
+ var tmp$ret$4 = import_0(path + toSnakeCase(item.b1a_1), Companion_getInstance().au(item.b1a_1).du());
1005
+ destination.x(tmp$ret$4);
1006
+ }
1007
+ return destination;
1008
+ }
1009
+ function sanitizeEnum(_this__u8e3s4) {
1010
+ _init_properties_RustEmitter_kt__ix9brc();
1011
+ var tmp = split(_this__u8e3s4, ['-', ', ', '.', ' ', '//', '_']);
1012
+ // Inline function 'kotlin.let' call
1013
+ var it = joinToString(tmp, '', VOID, VOID, VOID, VOID, sanitizeEnum$lambda);
1014
+ var tmp_0;
1015
+ var tmp0_safe_receiver = firstOrNull_0(it);
1016
+ var tmp_1;
1017
+ var tmp_2 = tmp0_safe_receiver;
1018
+ if ((tmp_2 == null ? null : new Char(tmp_2)) == null) {
1019
+ tmp_1 = null;
1020
+ } else {
1021
+ tmp_1 = isDigit(tmp0_safe_receiver);
1022
+ }
1023
+ if (tmp_1 === true) {
1024
+ tmp_0 = '_' + it;
1025
+ } else {
1026
+ tmp_0 = it;
1027
+ }
1028
+ return tmp_0;
1029
+ }
1030
+ function sanitizeEnum$lambda(s) {
1031
+ _init_properties_RustEmitter_kt__ix9brc();
1032
+ // Inline function 'kotlin.text.replaceFirstChar' call
1033
+ var tmp;
1034
+ // Inline function 'kotlin.text.isNotEmpty' call
1035
+ if (charSequenceLength(s) > 0) {
1036
+ var it = charCodeAt(s, 0);
1037
+ var tmp0 = uppercaseChar(it);
1038
+ // Inline function 'kotlin.text.plus' call
1039
+ var other = substring(s, 1);
1040
+ tmp = toString(tmp0) + other;
1041
+ } else {
1042
+ tmp = s;
1043
+ }
1044
+ return tmp;
1045
+ }
1046
+ var properties_initialized_RustEmitter_kt_u3ttd2;
1047
+ function _init_properties_RustEmitter_kt__ix9brc() {
1048
+ if (!properties_initialized_RustEmitter_kt_u3ttd2) {
1049
+ properties_initialized_RustEmitter_kt_u3ttd2 = true;
1050
+ wirespecImports = listOf_0([import_0('super::super::wirespec', '*'), import_0('', 'regex')]);
1051
+ sharedImports = listOf_0([import_0('std::any', 'TypeId'), import_0('std::collections', 'HashMap')]);
1052
+ sharedDerive = new RawElement('#[derive(Debug, Clone, PartialEq)]');
1053
+ sharedMethod = new RawElement('#[derive(Debug, Clone, Default, PartialEq)]\npub enum Method {\n #[default]\n GET,\n PUT,\n POST,\n DELETE,\n OPTIONS,\n HEAD,\n PATCH,\n TRACE,\n}');
1054
+ // Inline function 'kotlin.collections.mapValues' call
1055
+ var this_0 = mapOf([to('Enum', '\n pub trait Enum: Sized {\n fn label(&self) -> &str;\n fn from_label(s: &str) -> Option<Self>;\n }\n '), to('Refined', '\n pub trait Refined<T> {\n fn value(&self) -> &T;\n fn validate(&self) -> bool;\n }\n '), to('Request', '\n pub trait Request<T> {\n fn path(&self) -> &dyn Path;\n fn method(&self) -> &Method;\n fn queries(&self) -> &dyn Queries;\n fn headers(&self) -> &dyn RequestHeaders;\n fn body(&self) -> &T;\n }\n pub trait RequestHeaders: Headers {}\n '), to('Response', '\n pub trait Response<T> {\n fn status(&self) -> i32;\n fn headers(&self) -> &dyn ResponseHeaders;\n fn body(&self) -> &T;\n }\n pub trait ResponseHeaders: Headers {}\n '), to('BodySerializer', "\n pub trait BodySerializer {\n fn serialize_body<T: 'static>(&self, t: &T, r#type: TypeId) -> Vec<u8>;\n }\n "), to('BodyDeserializer', "\n pub trait BodyDeserializer {\n fn deserialize_body<T: 'static>(&self, raw: &[u8], r#type: TypeId) -> T;\n }\n "), to('PathSerializer', '\n pub trait PathSerializer {\n fn serialize_path<T: std::fmt::Display>(&self, t: &T, r#type: TypeId) -> String;\n }\n '), to('PathDeserializer', '\n pub trait PathDeserializer {\n fn deserialize_path<T: std::str::FromStr>(&self, raw: &str, r#type: TypeId) -> T where T::Err: std::fmt::Debug;\n }\n '), to('ParamSerializer', "\n pub trait ParamSerializer {\n fn serialize_param<T: 'static>(&self, value: &T, r#type: TypeId) -> Vec<String>;\n }\n "), to('ParamDeserializer', "\n pub trait ParamDeserializer {\n fn deserialize_param<T: 'static>(&self, values: &[String], r#type: TypeId) -> T;\n }\n "), to('Transportation', '\n pub trait Transportation {\n async fn transport(&self, request: &RawRequest) -> RawResponse;\n }\n '), to('Generator', '\n pub trait Generator {\n fn generate<T>(&self, path: Vec<String>, field: impl GeneratorField<T>) -> T;\n }\n ')]);
1056
+ // Inline function 'kotlin.collections.mapValuesTo' call
1057
+ var destination = LinkedHashMap_init_$Create$(mapCapacity(this_0.c1()));
1058
+ // Inline function 'kotlin.collections.associateByTo' call
1059
+ var _iterator__ex2g4s = this_0.m1().t();
1060
+ while (_iterator__ex2g4s.u()) {
1061
+ var element = _iterator__ex2g4s.v();
1062
+ var tmp = element.n1();
1063
+ // Inline function 'kotlin.collections.component2' call
1064
+ var code = element.o1();
1065
+ var tmp$ret$4 = new RawElement(trimIndent(code));
1066
+ destination.w2(tmp, tmp$ret$4);
1067
+ }
1068
+ sharedTraits = destination;
1069
+ sharedClientAndServer = listOf_0([new RawElement('pub trait Client {\n type Transport: Transportation;\n type Ser: Serialization;\n fn transport(&self) -> &Self::Transport;\n fn serialization(&self) -> &Self::Ser;\n}'), new RawElement("pub trait Server {\n type Req;\n type Res;\n fn path_template(&self) -> &'static str;\n fn method(&self) -> Method;\n}")]);
1070
+ }
1071
+ }
1473
1072
  function get_rustSelfParam() {
1474
1073
  _init_properties_RustIrTransformer_kt__rrvmwq();
1475
1074
  return rustSelfParam;
@@ -1480,6 +1079,35 @@ function get_rustResponsePattern() {
1480
1079
  return rustResponsePattern;
1481
1080
  }
1482
1081
  var rustResponsePattern;
1082
+ function get_serializerTraits() {
1083
+ _init_properties_RustIrTransformer_kt__rrvmwq();
1084
+ return serializerTraits;
1085
+ }
1086
+ var serializerTraits;
1087
+ function get_serializationFunctions() {
1088
+ _init_properties_RustIrTransformer_kt__rrvmwq();
1089
+ return serializationFunctions;
1090
+ }
1091
+ var serializationFunctions;
1092
+ function get_borrowParameters() {
1093
+ _init_properties_RustIrTransformer_kt__rrvmwq();
1094
+ return borrowParameters;
1095
+ }
1096
+ var borrowParameters;
1097
+ function get_borrowSerializationArguments() {
1098
+ _init_properties_RustIrTransformer_kt__rrvmwq();
1099
+ return borrowSerializationArguments;
1100
+ }
1101
+ var borrowSerializationArguments;
1102
+ function applyBorrowRules(_this__u8e3s4) {
1103
+ _init_properties_RustIrTransformer_kt__rrvmwq();
1104
+ // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
1105
+ var scope = new TransformScope(_this__u8e3s4);
1106
+ scope.j19(get_borrowParameters());
1107
+ scope.j19(get_borrowSerializationArguments());
1108
+ var tmp = scope.e19_1;
1109
+ return isInterface(tmp, Element) ? tmp : THROW_CCE();
1110
+ }
1483
1111
  function fixResponseSwitchPatterns() {
1484
1112
  _init_properties_RustIrTransformer_kt__rrvmwq();
1485
1113
  // Inline function 'community.flock.wirespec.compiler.core.ir.transformer' call
@@ -1488,30 +1116,33 @@ function fixResponseSwitchPatterns() {
1488
1116
  this_0.u19(fixResponseSwitchPatterns$lambda);
1489
1117
  return this_0.t19();
1490
1118
  }
1491
- function buildModelImports(_this__u8e3s4) {
1119
+ function withSelfReceivers(_this__u8e3s4) {
1492
1120
  _init_properties_RustIrTransformer_kt__rrvmwq();
1493
- // Inline function 'kotlin.collections.distinctBy' call
1494
- var this_0 = importReferences(_this__u8e3s4);
1495
- var set = HashSet_init_$Create$();
1496
- var list = ArrayList_init_$Create$_0();
1121
+ // Inline function 'kotlin.collections.map' call
1122
+ var this_0 = _this__u8e3s4.sv_1;
1123
+ // Inline function 'kotlin.collections.mapTo' call
1124
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
1497
1125
  var _iterator__ex2g4s = this_0.t();
1498
1126
  while (_iterator__ex2g4s.u()) {
1499
- var e = _iterator__ex2g4s.v();
1500
- var key = e.b1a_1;
1501
- if (set.x(key)) {
1502
- list.x(e);
1127
+ var item = _iterator__ex2g4s.v();
1128
+ var tmp;
1129
+ if (item instanceof Function_0) {
1130
+ tmp = item.dy(VOID, VOID, plus(listOf(get_rustSelfParam()), item.tx_1));
1131
+ } else {
1132
+ tmp = item;
1503
1133
  }
1134
+ var tmp$ret$2 = tmp;
1135
+ destination.x(tmp$ret$2);
1504
1136
  }
1505
- // Inline function 'kotlin.collections.map' call
1506
- // Inline function 'kotlin.collections.mapTo' call
1507
- var destination = ArrayList_init_$Create$(collectionSizeOrDefault(list, 10));
1508
- var _iterator__ex2g4s_0 = list.t();
1509
- while (_iterator__ex2g4s_0.u()) {
1510
- var item = _iterator__ex2g4s_0.v();
1511
- var tmp$ret$4 = import_0('super::' + toRustSnakeCase(item.b1a_1), Companion_getInstance().au(item.b1a_1).du());
1512
- destination.x(tmp$ret$4);
1513
- }
1514
- return destination;
1137
+ return _this__u8e3s4.zv(VOID, destination);
1138
+ }
1139
+ function toSnakeCase(_this__u8e3s4) {
1140
+ _init_properties_RustIrTransformer_kt__rrvmwq();
1141
+ return Companion_getInstance().au(_this__u8e3s4).eu();
1142
+ }
1143
+ function sanitizeKeywords(_this__u8e3s4) {
1144
+ _init_properties_RustIrTransformer_kt__rrvmwq();
1145
+ return Companion_getInstance_0().n37().i1(_this__u8e3s4) ? 'r#' + _this__u8e3s4 : _this__u8e3s4;
1515
1146
  }
1516
1147
  function replaceStructWithRefinedFunctions(_this__u8e3s4, refined) {
1517
1148
  _init_properties_RustIrTransformer_kt__rrvmwq();
@@ -1581,28 +1212,11 @@ function injectHandlerImplForClient(_this__u8e3s4) {
1581
1212
  var tmp_0 = scope.e19_1;
1582
1213
  return isInterface(tmp_0, Element) ? tmp_0 : THROW_CCE();
1583
1214
  }
1584
- function injectSelfToHandlerMethods(_this__u8e3s4) {
1215
+ function stripResponseGenerics(_this__u8e3s4) {
1585
1216
  _init_properties_RustIrTransformer_kt__rrvmwq();
1586
1217
  // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
1587
1218
  var scope = new TransformScope(_this__u8e3s4);
1588
- // Inline function 'community.flock.wirespec.compiler.core.ir.TransformScope.matchingElements' call
1589
- var tmp = scope;
1590
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformMatchingElements' call
1591
- var this_0 = scope.e19_1;
1592
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformer' call
1593
- // Inline function 'kotlin.apply' call
1594
- var this_1 = new TransformerBuilder();
1595
- this_1.y19(injectSelfToHandlerMethods$lambda);
1596
- var tmp$ret$4 = this_1.t19();
1597
- tmp.e19_1 = transform(this_0, tmp$ret$4);
1598
- var tmp_0 = scope.e19_1;
1599
- return isInterface(tmp_0, Element) ? tmp_0 : THROW_CCE();
1600
- }
1601
- function stripResponseGenerics(_this__u8e3s4) {
1602
- _init_properties_RustIrTransformer_kt__rrvmwq();
1603
- // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
1604
- var scope = new TransformScope(_this__u8e3s4);
1605
- // Inline function 'community.flock.wirespec.compiler.core.ir.TransformScope.matching' call
1219
+ // Inline function 'community.flock.wirespec.compiler.core.ir.TransformScope.matching' call
1606
1220
  var tmp = scope;
1607
1221
  // Inline function 'community.flock.wirespec.compiler.core.ir.transformMatching' call
1608
1222
  var this_0 = scope.e19_1;
@@ -1615,7 +1229,7 @@ function stripResponseGenerics(_this__u8e3s4) {
1615
1229
  var tmp_0 = scope.e19_1;
1616
1230
  return isInterface(tmp_0, Element) ? tmp_0 : THROW_CCE();
1617
1231
  }
1618
- function stripHandlerExtends(_this__u8e3s4) {
1232
+ function rustHandlerTraits(_this__u8e3s4) {
1619
1233
  _init_properties_RustIrTransformer_kt__rrvmwq();
1620
1234
  // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
1621
1235
  var scope = new TransformScope(_this__u8e3s4);
@@ -1626,7 +1240,7 @@ function stripHandlerExtends(_this__u8e3s4) {
1626
1240
  // Inline function 'community.flock.wirespec.compiler.core.ir.transformer' call
1627
1241
  // Inline function 'kotlin.apply' call
1628
1242
  var this_1 = new TransformerBuilder();
1629
- this_1.y19(stripHandlerExtends$lambda);
1243
+ this_1.y19(rustHandlerTraits$lambda);
1630
1244
  var tmp$ret$4 = this_1.t19();
1631
1245
  tmp.e19_1 = transform(this_0, tmp$ret$4);
1632
1246
  var tmp_0 = scope.e19_1;
@@ -1664,7 +1278,7 @@ function flattenForRust(_this__u8e3s4) {
1664
1278
  // Inline function 'kotlin.collections.filterIsInstance' call
1665
1279
  var tmp0 = _this__u8e3s4.hv();
1666
1280
  // Inline function 'kotlin.collections.filterIsInstanceTo' call
1667
- var destination = ArrayList_init_$Create$_0();
1281
+ var destination = ArrayList_init_$Create$();
1668
1282
  var _iterator__ex2g4s = tmp0.t();
1669
1283
  while (_iterator__ex2g4s.u()) {
1670
1284
  var element = _iterator__ex2g4s.v();
@@ -1672,13 +1286,13 @@ function flattenForRust(_this__u8e3s4) {
1672
1286
  destination.x(element);
1673
1287
  }
1674
1288
  }
1675
- var tmp$ret$0 = firstOrNull_0(destination);
1289
+ var tmp$ret$0 = firstOrNull(destination);
1676
1290
  var namespace = ensureNotNull(tmp$ret$0);
1677
- // Inline function 'kotlin.collections.filter' call
1678
- var tmp0_0 = namespace.mv_1;
1679
- // Inline function 'kotlin.collections.filterTo' call
1680
- var destination_0 = ArrayList_init_$Create$_0();
1681
- var _iterator__ex2g4s_0 = tmp0_0.t();
1291
+ // Inline function 'kotlin.collections.partition' call
1292
+ var this_0 = namespace.mv_1;
1293
+ var first = ArrayList_init_$Create$();
1294
+ var second = ArrayList_init_$Create$();
1295
+ var _iterator__ex2g4s_0 = this_0.t();
1682
1296
  while (_iterator__ex2g4s_0.u()) {
1683
1297
  var element_0 = _iterator__ex2g4s_0.v();
1684
1298
  var tmp;
@@ -1688,94 +1302,80 @@ function flattenForRust(_this__u8e3s4) {
1688
1302
  tmp = element_0 instanceof Union_0;
1689
1303
  }
1690
1304
  if (tmp) {
1691
- destination_0.x(element_0);
1305
+ first.x(element_0);
1306
+ } else {
1307
+ second.x(element_0);
1308
+ }
1309
+ }
1310
+ var _destruct__k2r9zo = new Pair(first, second);
1311
+ var moduleElements = _destruct__k2r9zo.af();
1312
+ var classElements = _destruct__k2r9zo.bf();
1313
+ // Inline function 'kotlin.collections.filterIsInstance' call
1314
+ var tmp0_0 = namespace.mv_1;
1315
+ // Inline function 'kotlin.collections.filterIsInstanceTo' call
1316
+ var destination_0 = ArrayList_init_$Create$();
1317
+ var _iterator__ex2g4s_1 = tmp0_0.t();
1318
+ while (_iterator__ex2g4s_1.u()) {
1319
+ var element_1 = _iterator__ex2g4s_1.v();
1320
+ if (element_1 instanceof Struct) {
1321
+ destination_0.x(element_1);
1692
1322
  }
1693
1323
  }
1694
1324
  // Inline function 'kotlin.collections.map' call
1695
1325
  // Inline function 'kotlin.collections.mapTo' call
1696
- var destination_1 = ArrayList_init_$Create$(collectionSizeOrDefault(destination_0, 10));
1697
- var _iterator__ex2g4s_1 = destination_0.t();
1698
- while (_iterator__ex2g4s_1.u()) {
1699
- var item = _iterator__ex2g4s_1.v();
1326
+ var destination_1 = ArrayList_init_$Create$_0(collectionSizeOrDefault(destination_0, 10));
1327
+ var _iterator__ex2g4s_2 = destination_0.t();
1328
+ while (_iterator__ex2g4s_2.u()) {
1329
+ var item = _iterator__ex2g4s_2.v();
1330
+ var tmp$ret$9 = item.fx_1.du();
1331
+ destination_1.x(tmp$ret$9);
1332
+ }
1333
+ // Inline function 'kotlin.collections.filter' call
1334
+ // Inline function 'kotlin.collections.filterTo' call
1335
+ var destination_2 = ArrayList_init_$Create$();
1336
+ var _iterator__ex2g4s_3 = destination_1.t();
1337
+ while (_iterator__ex2g4s_3.u()) {
1338
+ var element_2 = _iterator__ex2g4s_3.v();
1339
+ if (get_rustResponsePattern().sc(element_2)) {
1340
+ destination_2.x(element_2);
1341
+ }
1342
+ }
1343
+ // Inline function 'kotlin.collections.map' call
1344
+ // Inline function 'kotlin.collections.mapTo' call
1345
+ var destination_3 = ArrayList_init_$Create$_0(collectionSizeOrDefault(destination_2, 10));
1346
+ var _iterator__ex2g4s_4 = destination_2.t();
1347
+ while (_iterator__ex2g4s_4.u()) {
1348
+ var item_0 = _iterator__ex2g4s_4.v();
1349
+ var tmp$ret$15 = Custom_init_$Create$(item_0);
1350
+ destination_3.x(tmp$ret$15);
1351
+ }
1352
+ var responseMembers = destination_3;
1353
+ // Inline function 'kotlin.collections.map' call
1354
+ // Inline function 'kotlin.collections.mapTo' call
1355
+ var destination_4 = ArrayList_init_$Create$_0(collectionSizeOrDefault(moduleElements, 10));
1356
+ var _iterator__ex2g4s_5 = moduleElements.t();
1357
+ while (_iterator__ex2g4s_5.u()) {
1358
+ var item_1 = _iterator__ex2g4s_5.v();
1700
1359
  var tmp_0;
1701
1360
  var tmp_1;
1702
- if (item instanceof Union_0) {
1703
- tmp_1 = item.lw_1.du() === 'Response';
1361
+ if (item_1 instanceof Union_0) {
1362
+ tmp_1 = item_1.lw_1.du() === 'Response';
1704
1363
  } else {
1705
1364
  tmp_1 = false;
1706
1365
  }
1707
1366
  if (tmp_1) {
1708
- // Inline function 'kotlin.collections.filterIsInstance' call
1709
- var tmp0_1 = namespace.mv_1;
1710
- // Inline function 'kotlin.collections.filterIsInstanceTo' call
1711
- var destination_2 = ArrayList_init_$Create$_0();
1712
- var _iterator__ex2g4s_2 = tmp0_1.t();
1713
- while (_iterator__ex2g4s_2.u()) {
1714
- var element_1 = _iterator__ex2g4s_2.v();
1715
- if (element_1 instanceof Struct) {
1716
- destination_2.x(element_1);
1717
- }
1718
- }
1719
- // Inline function 'kotlin.collections.map' call
1720
- // Inline function 'kotlin.collections.mapTo' call
1721
- var destination_3 = ArrayList_init_$Create$(collectionSizeOrDefault(destination_2, 10));
1722
- var _iterator__ex2g4s_3 = destination_2.t();
1723
- while (_iterator__ex2g4s_3.u()) {
1724
- var item_0 = _iterator__ex2g4s_3.v();
1725
- var tmp$ret$13 = item_0.fx_1.du();
1726
- destination_3.x(tmp$ret$13);
1727
- }
1728
- // Inline function 'kotlin.collections.filter' call
1729
- // Inline function 'kotlin.collections.filterTo' call
1730
- var destination_4 = ArrayList_init_$Create$_0();
1731
- var _iterator__ex2g4s_4 = destination_3.t();
1732
- while (_iterator__ex2g4s_4.u()) {
1733
- var element_2 = _iterator__ex2g4s_4.v();
1734
- if (get_rustResponsePattern().sc(element_2)) {
1735
- destination_4.x(element_2);
1736
- }
1737
- }
1738
- // Inline function 'kotlin.collections.map' call
1739
- // Inline function 'kotlin.collections.mapTo' call
1740
- var destination_5 = ArrayList_init_$Create$(collectionSizeOrDefault(destination_4, 10));
1741
- var _iterator__ex2g4s_5 = destination_4.t();
1742
- while (_iterator__ex2g4s_5.u()) {
1743
- var item_1 = _iterator__ex2g4s_5.v();
1744
- var tmp$ret$19 = Custom_init_$Create$(item_1);
1745
- destination_5.x(tmp$ret$19);
1746
- }
1747
- var members = destination_5;
1748
- tmp_0 = item.rw(VOID, VOID, members, emptyList());
1367
+ tmp_0 = item_1.rw(VOID, VOID, responseMembers, emptyList());
1749
1368
  } else {
1750
- if (item instanceof Union_0) {
1751
- tmp_0 = item.rw(VOID, VOID, VOID, emptyList());
1369
+ if (item_1 instanceof Union_0) {
1370
+ tmp_0 = item_1.rw(VOID, VOID, VOID, emptyList());
1752
1371
  } else {
1753
- tmp_0 = item;
1372
+ tmp_0 = item_1;
1754
1373
  }
1755
1374
  }
1756
- var tmp$ret$8 = tmp_0;
1757
- destination_1.x(tmp$ret$8);
1375
+ var tmp$ret$18 = tmp_0;
1376
+ destination_4.x(tmp$ret$18);
1758
1377
  }
1759
- var moduleElements = destination_1;
1760
- // Inline function 'kotlin.collections.filterNot' call
1761
- var tmp0_2 = namespace.mv_1;
1762
- // Inline function 'kotlin.collections.filterNotTo' call
1763
- var destination_6 = ArrayList_init_$Create$_0();
1764
- var _iterator__ex2g4s_6 = tmp0_2.t();
1765
- while (_iterator__ex2g4s_6.u()) {
1766
- var element_3 = _iterator__ex2g4s_6.v();
1767
- var tmp_2;
1768
- if (element_3 instanceof Struct) {
1769
- tmp_2 = true;
1770
- } else {
1771
- tmp_2 = element_3 instanceof Union_0;
1772
- }
1773
- if (!tmp_2) {
1774
- destination_6.x(element_3);
1775
- }
1776
- }
1777
- var classElements = destination_6;
1778
- return new File(namespace.lv_1, plus_0(moduleElements, new Namespace(namespace.lv_1, classElements, namespace.nv_1)));
1378
+ return new File(namespace.lv_1, plus_0(destination_4, new Namespace(namespace.lv_1, classElements, namespace.nv_1)));
1779
1379
  }
1780
1380
  function fixConstructorCalls() {
1781
1381
  _init_properties_RustIrTransformer_kt__rrvmwq();
@@ -1785,163 +1385,454 @@ function fixConstructorCalls() {
1785
1385
  this_0.w19(fixConstructorCalls$lambda);
1786
1386
  return this_0.t19();
1787
1387
  }
1788
- function buildEndpointImports(_this__u8e3s4) {
1388
+ function rustName(_this__u8e3s4) {
1789
1389
  _init_properties_RustIrTransformer_kt__rrvmwq();
1790
- // Inline function 'kotlin.collections.distinctBy' call
1791
- var this_0 = importReferences(_this__u8e3s4);
1792
- var set = HashSet_init_$Create$();
1793
- var list = ArrayList_init_$Create$_0();
1794
- var _iterator__ex2g4s = this_0.t();
1795
- while (_iterator__ex2g4s.u()) {
1796
- var e = _iterator__ex2g4s.v();
1797
- var key = e.b1a_1;
1798
- if (set.x(key)) {
1799
- list.x(e);
1390
+ var tmp;
1391
+ if (_this__u8e3s4 instanceof Custom) {
1392
+ var tmp_0;
1393
+ if (_this__u8e3s4.su_1.r()) {
1394
+ tmp_0 = _this__u8e3s4.ru_1.du();
1395
+ } else {
1396
+ var tmp_1 = _this__u8e3s4.ru_1.du();
1397
+ tmp_0 = tmp_1 + '<' + joinToString(_this__u8e3s4.su_1, ', ', VOID, VOID, VOID, VOID, rustName$lambda) + '>';
1398
+ }
1399
+ tmp = tmp_0;
1400
+ } else {
1401
+ if (equals(_this__u8e3s4, String_instance)) {
1402
+ tmp = 'String';
1403
+ } else {
1404
+ if (_this__u8e3s4 instanceof Nullable) {
1405
+ tmp = 'Option<' + rustName(_this__u8e3s4.vu_1) + '>';
1406
+ } else {
1407
+ if (_this__u8e3s4 instanceof Array_0) {
1408
+ tmp = 'Vec<' + rustName(_this__u8e3s4.mu_1) + '>';
1409
+ } else {
1410
+ if (_this__u8e3s4 instanceof Dict) {
1411
+ tmp = 'std::collections::HashMap<' + rustName(_this__u8e3s4.ou_1) + ', ' + rustName(_this__u8e3s4.pu_1) + '>';
1412
+ } else {
1413
+ if (equals(_this__u8e3s4, Any_instance)) {
1414
+ tmp = 'Box<dyn std::any::Any>';
1415
+ } else {
1416
+ if (equals(_this__u8e3s4, Bytes_instance)) {
1417
+ tmp = 'Vec<u8>';
1418
+ } else {
1419
+ if (equals(_this__u8e3s4, Unit_instance_0)) {
1420
+ tmp = '()';
1421
+ } else {
1422
+ if (equals(_this__u8e3s4, Boolean_instance)) {
1423
+ tmp = 'bool';
1424
+ } else {
1425
+ if (equals(_this__u8e3s4, Wildcard_instance)) {
1426
+ tmp = '_';
1427
+ } else {
1428
+ if (equals(_this__u8e3s4, Reflect_instance)) {
1429
+ tmp = 'std::any::TypeId';
1430
+ } else {
1431
+ if (_this__u8e3s4 instanceof Integer) {
1432
+ var tmp_2;
1433
+ switch (_this__u8e3s4.ku_1.f3_1) {
1434
+ case 0:
1435
+ tmp_2 = 'i32';
1436
+ break;
1437
+ case 1:
1438
+ tmp_2 = 'i64';
1439
+ break;
1440
+ default:
1441
+ noWhenBranchMatchedException();
1442
+ break;
1443
+ }
1444
+ tmp = tmp_2;
1445
+ } else {
1446
+ if (_this__u8e3s4 instanceof Number_0) {
1447
+ var tmp_3;
1448
+ switch (_this__u8e3s4.lu_1.f3_1) {
1449
+ case 0:
1450
+ tmp_3 = 'f32';
1451
+ break;
1452
+ case 1:
1453
+ tmp_3 = 'f64';
1454
+ break;
1455
+ default:
1456
+ noWhenBranchMatchedException();
1457
+ break;
1458
+ }
1459
+ tmp = tmp_3;
1460
+ } else {
1461
+ if (_this__u8e3s4 instanceof IntegerLiteral) {
1462
+ tmp = 'i32';
1463
+ } else {
1464
+ if (_this__u8e3s4 instanceof StringLiteral) {
1465
+ tmp = 'String';
1466
+ } else {
1467
+ if (_this__u8e3s4 instanceof Function) {
1468
+ tmp = 'Box<dyn Fn(' + joinToString(_this__u8e3s4.yu_1, ', ', VOID, VOID, VOID, VOID, rustName$lambda_0) + ') -> ' + rustName(_this__u8e3s4.zu_1) + '>';
1469
+ } else {
1470
+ noWhenBranchMatchedException();
1471
+ }
1472
+ }
1473
+ }
1474
+ }
1475
+ }
1476
+ }
1477
+ }
1478
+ }
1479
+ }
1480
+ }
1481
+ }
1482
+ }
1483
+ }
1484
+ }
1800
1485
  }
1801
1486
  }
1802
- // Inline function 'kotlin.collections.map' call
1803
- // Inline function 'kotlin.collections.mapTo' call
1804
- var destination = ArrayList_init_$Create$(collectionSizeOrDefault(list, 10));
1805
- var _iterator__ex2g4s_0 = list.t();
1806
- while (_iterator__ex2g4s_0.u()) {
1807
- var item = _iterator__ex2g4s_0.v();
1808
- var tmp$ret$4 = import_0('super::super::model::' + toRustSnakeCase(item.b1a_1), Companion_getInstance().au(item.b1a_1).du());
1809
- destination.x(tmp$ret$4);
1810
- }
1811
- return destination;
1812
- }
1813
- function toRustSnakeCase(_this__u8e3s4) {
1814
- _init_properties_RustIrTransformer_kt__rrvmwq();
1815
- return Companion_getInstance().au(_this__u8e3s4).eu();
1816
- }
1817
- function buildValidateFunction(refined) {
1818
- _init_properties_RustIrTransformer_kt__rrvmwq();
1819
- var constraintExpr = convertConstraint(refined.ns_1, new FieldCall(new VariableReference(Companion_getInstance().au('self')), Companion_getInstance().au('value')));
1820
- return function_0('validate', VOID, VOID, buildValidateFunction$lambda(constraintExpr));
1487
+ return tmp;
1821
1488
  }
1822
- function buildToStringFunction(refined) {
1489
+ function borrowed(_this__u8e3s4) {
1823
1490
  _init_properties_RustIrTransformer_kt__rrvmwq();
1824
1491
  var tmp;
1825
- if (refined.ns_1.d1a_1 instanceof String_0) {
1826
- tmp = 'self.value.clone()';
1492
+ if (_this__u8e3s4 instanceof Nullable) {
1493
+ tmp = _this__u8e3s4.nu(borrowed(_this__u8e3s4.vu_1));
1827
1494
  } else {
1828
- tmp = 'format!("{}", self.value)';
1495
+ if (equals(_this__u8e3s4, String_instance)) {
1496
+ tmp = Custom_init_$Create$('&str');
1497
+ } else {
1498
+ var tmp_0;
1499
+ if (_this__u8e3s4 instanceof Custom) {
1500
+ tmp_0 = get_serializerTraits().i1(_this__u8e3s4.ru_1.du());
1501
+ } else {
1502
+ tmp_0 = false;
1503
+ }
1504
+ if (tmp_0) {
1505
+ tmp = _this__u8e3s4.uu(new Name(listOf('&impl ' + _this__u8e3s4.ru_1.du())));
1506
+ } else {
1507
+ tmp = _this__u8e3s4;
1508
+ }
1509
+ }
1829
1510
  }
1830
- var expr = tmp;
1831
- return function_0('to_string', VOID, VOID, buildToStringFunction$lambda(expr));
1832
- }
1833
- function buildApiStruct(endpoint) {
1834
- _init_properties_RustIrTransformer_kt__rrvmwq();
1835
- return new RawElement(generateApiStructCode(endpoint));
1836
- }
1837
- function generateApiStructCode(_this__u8e3s4) {
1838
- _init_properties_RustIrTransformer_kt__rrvmwq();
1839
- // Inline function 'kotlin.let' call
1840
- var pathTemplate = '/' + joinToString(_this__u8e3s4.ir_1, '/', VOID, VOID, VOID, VOID, generateApiStructCode$lambda);
1841
- var methodName = _this__u8e3s4.hr_1.e3_1;
1842
- return trimIndent('\n pub struct Api;\n impl Server for Api {\n type Req = Request;\n type Res = Response;\n fn path_template(&self) -> &\'static str { "' + pathTemplate + '" }\n fn method(&self) -> Method { Method::' + methodName + ' }\n }\n ');
1511
+ return tmp;
1843
1512
  }
1844
- function fixResponseSwitchPatterns$lambda(s, t) {
1513
+ function toRawCode(_this__u8e3s4) {
1845
1514
  _init_properties_RustIrTransformer_kt__rrvmwq();
1846
1515
  var tmp;
1847
- if (!(s instanceof Switch)) {
1848
- tmp = true;
1516
+ if (_this__u8e3s4 instanceof VariableReference) {
1517
+ tmp = sanitizeKeywords(_this__u8e3s4.ev_1.eu());
1849
1518
  } else {
1850
- var tmp0_safe_receiver = s.cz_1;
1851
- tmp = !((tmp0_safe_receiver == null ? null : tmp0_safe_receiver.cu()) === 'r');
1852
- }
1853
- if (tmp)
1854
- return transformChildren(s, t);
1855
- // Inline function 'kotlin.collections.map' call
1856
- var this_0 = s.az_1;
1857
- // Inline function 'kotlin.collections.mapTo' call
1858
- var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
1859
- var _iterator__ex2g4s = this_0.t();
1860
- while (_iterator__ex2g4s.u()) {
1861
- var item = _iterator__ex2g4s.v();
1862
- var tmp_0 = item.hz_1;
1863
- var tmp0_safe_receiver_0 = tmp_0 instanceof Custom ? tmp_0 : null;
1864
- var tmp1_safe_receiver = tmp0_safe_receiver_0 == null ? null : tmp0_safe_receiver_0.ru_1;
1865
- var typeName = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.du();
1866
- var tmp_1;
1867
- if (!(typeName == null) && get_rustResponsePattern().sc(typeName)) {
1868
- var tmp_2 = new RawExpression('Response::' + typeName + '(' + ensureNotNull(s.cz_1).eu() + ')');
1869
- // Inline function 'kotlin.collections.map' call
1870
- var this_1 = item.gz_1;
1871
- // Inline function 'kotlin.collections.mapTo' call
1872
- var destination_0 = ArrayList_init_$Create$(collectionSizeOrDefault(this_1, 10));
1873
- var _iterator__ex2g4s_0 = this_1.t();
1874
- while (_iterator__ex2g4s_0.u()) {
1875
- var item_0 = _iterator__ex2g4s_0.v();
1876
- var tmp$ret$5 = t.y18(item_0);
1877
- destination_0.x(tmp$ret$5);
1519
+ if (_this__u8e3s4 instanceof FieldCall) {
1520
+ var tmp1_safe_receiver = _this__u8e3s4.kz_1;
1521
+ var tmp_0;
1522
+ if (tmp1_safe_receiver == null) {
1523
+ tmp_0 = null;
1524
+ } else {
1525
+ // Inline function 'kotlin.let' call
1526
+ tmp_0 = toRawCode(tmp1_safe_receiver) + '.';
1878
1527
  }
1879
- tmp_1 = new Case(tmp_2, destination_0, null);
1528
+ // Inline function 'kotlin.text.orEmpty' call
1529
+ var tmp0_elvis_lhs = tmp_0;
1530
+ tmp = (tmp0_elvis_lhs == null ? '' : tmp0_elvis_lhs) + sanitizeKeywords(_this__u8e3s4.lz_1.eu());
1880
1531
  } else {
1881
- var tmp_3 = t.z18(item.fz_1);
1882
- // Inline function 'kotlin.collections.map' call
1883
- var this_2 = item.gz_1;
1884
- // Inline function 'kotlin.collections.mapTo' call
1885
- var destination_1 = ArrayList_init_$Create$(collectionSizeOrDefault(this_2, 10));
1886
- var _iterator__ex2g4s_1 = this_2.t();
1887
- while (_iterator__ex2g4s_1.u()) {
1888
- var item_1 = _iterator__ex2g4s_1.v();
1889
- var tmp$ret$8 = t.y18(item_1);
1890
- destination_1.x(tmp$ret$8);
1891
- }
1892
- var tmp_4 = destination_1;
1893
- var tmp2_safe_receiver = item.hz_1;
1894
- var tmp_5;
1895
- if (tmp2_safe_receiver == null) {
1896
- tmp_5 = null;
1532
+ if (_this__u8e3s4 instanceof ArrayIndexCall) {
1533
+ var tmp_1 = _this__u8e3s4.c10_1;
1534
+ var tmp2_safe_receiver = tmp_1 instanceof Literal ? tmp_1 : null;
1535
+ var tmp_2;
1536
+ if (tmp2_safe_receiver == null) {
1537
+ tmp_2 = null;
1538
+ } else {
1539
+ // Inline function 'kotlin.takeIf' call
1540
+ var tmp_3;
1541
+ var tmp_4 = tmp2_safe_receiver.wy_1;
1542
+ if (tmp_4 instanceof String_0) {
1543
+ tmp_3 = tmp2_safe_receiver;
1544
+ } else {
1545
+ tmp_3 = null;
1546
+ }
1547
+ tmp_2 = tmp_3;
1548
+ }
1549
+ var tmp3_safe_receiver = tmp_2;
1550
+ var tmp_5;
1551
+ if (tmp3_safe_receiver == null) {
1552
+ tmp_5 = null;
1553
+ } else {
1554
+ // Inline function 'kotlin.let' call
1555
+ tmp_5 = '"' + toString_0(tmp3_safe_receiver.vy_1) + '"';
1556
+ }
1557
+ var tmp4_elvis_lhs = tmp_5;
1558
+ var key = tmp4_elvis_lhs == null ? toRawCode(_this__u8e3s4.c10_1) : tmp4_elvis_lhs;
1559
+ tmp = toRawCode(_this__u8e3s4.b10_1) + '[' + key + ']';
1897
1560
  } else {
1898
- // Inline function 'kotlin.let' call
1899
- tmp_5 = t.w18(tmp2_safe_receiver);
1561
+ if (_this__u8e3s4 instanceof ConstructorStatement) {
1562
+ var tmp_6 = _this__u8e3s4.gu_1;
1563
+ var tmp5_safe_receiver = tmp_6 instanceof Custom ? tmp_6 : null;
1564
+ var tmp6_safe_receiver = tmp5_safe_receiver == null ? null : tmp5_safe_receiver.ru_1;
1565
+ var tmp7_elvis_lhs = tmp6_safe_receiver == null ? null : tmp6_safe_receiver.du();
1566
+ var typeName = tmp7_elvis_lhs == null ? toString_0(_this__u8e3s4.gu_1) : tmp7_elvis_lhs;
1567
+ var tmp_7 = _this__u8e3s4.hu_1.m1();
1568
+ var args = joinToString(tmp_7, ', ', VOID, VOID, VOID, VOID, toRawCode$lambda);
1569
+ var tmp_8;
1570
+ // Inline function 'kotlin.text.isEmpty' call
1571
+ if (charSequenceLength(args) === 0) {
1572
+ tmp_8 = typeName + ' {}';
1573
+ } else {
1574
+ tmp_8 = typeName + ' { ' + args + ' }';
1575
+ }
1576
+ tmp = tmp_8;
1577
+ } else {
1578
+ if (_this__u8e3s4 instanceof Literal) {
1579
+ var tmp_9;
1580
+ var tmp_10 = _this__u8e3s4.wy_1;
1581
+ if (tmp_10 instanceof String_0) {
1582
+ tmp_9 = 'String::from("' + toString_0(_this__u8e3s4.vy_1) + '")';
1583
+ } else {
1584
+ tmp_9 = toString_0(_this__u8e3s4.vy_1);
1585
+ }
1586
+ tmp = tmp_9;
1587
+ } else {
1588
+ if (_this__u8e3s4 instanceof RawExpression) {
1589
+ tmp = _this__u8e3s4.gy_1;
1590
+ } else {
1591
+ // Inline function 'kotlin.error' call
1592
+ var message = 'Unsupported expression type in toRawCode: ' + getKClassFromExpression(_this__u8e3s4).o();
1593
+ throw IllegalStateException_init_$Create$(toString_0(message));
1594
+ }
1595
+ }
1596
+ }
1900
1597
  }
1901
- tmp_1 = new Case(tmp_3, tmp_4, tmp_5);
1902
1598
  }
1903
- var tmp$ret$2 = tmp_1;
1904
- destination.x(tmp$ret$2);
1905
1599
  }
1906
- var transformedCases = destination;
1907
- return s.ez(t.z18(s.zy_1), transformedCases, null);
1600
+ return tmp;
1908
1601
  }
1909
- function replaceStructWithRefinedFunctions$lambda($refined) {
1910
- return function (element, transformer) {
1911
- var tmp;
1912
- if (element instanceof Struct) {
1913
- tmp = element.qx(VOID, VOID, VOID, VOID, listOf_0([buildValidateFunction($refined), buildToStringFunction($refined)]));
1602
+ function matchingResponse(_this__u8e3s4, variable, t) {
1603
+ _init_properties_RustIrTransformer_kt__rrvmwq();
1604
+ var tmp = _this__u8e3s4.hz_1;
1605
+ var tmp0_safe_receiver = tmp instanceof Custom ? tmp : null;
1606
+ var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.ru_1;
1607
+ var tmp2_safe_receiver = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.du();
1608
+ var tmp_0;
1609
+ if (tmp2_safe_receiver == null) {
1610
+ tmp_0 = null;
1611
+ } else {
1612
+ // Inline function 'kotlin.takeIf' call
1613
+ var tmp_1;
1614
+ if (get_rustResponsePattern().sc(tmp2_safe_receiver)) {
1615
+ tmp_1 = tmp2_safe_receiver;
1914
1616
  } else {
1915
- tmp = element;
1617
+ tmp_1 = null;
1916
1618
  }
1917
- var transformed = tmp;
1918
- return transformChildren_0(transformed, transformer);
1919
- };
1920
- }
1921
- function injectApiStruct$lambda($endpoint) {
1922
- return function (element, transformer) {
1923
- var tmp;
1924
- if (element instanceof Namespace) {
1925
- tmp = element.qv(VOID, plus(element.mv_1, listOf(buildApiStruct($endpoint))));
1926
- } else {
1927
- tmp = element;
1619
+ tmp_0 = tmp_1;
1620
+ }
1621
+ var tmp3_safe_receiver = tmp_0;
1622
+ var tmp_2;
1623
+ if (tmp3_safe_receiver == null) {
1624
+ tmp_2 = null;
1625
+ } else {
1626
+ // Inline function 'kotlin.let' call
1627
+ var tmp_3 = new RawExpression('Response::' + tmp3_safe_receiver + '(' + variable.eu() + ')');
1628
+ // Inline function 'kotlin.collections.map' call
1629
+ var this_0 = _this__u8e3s4.gz_1;
1630
+ // Inline function 'kotlin.collections.mapTo' call
1631
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
1632
+ var _iterator__ex2g4s = this_0.t();
1633
+ while (_iterator__ex2g4s.u()) {
1634
+ var item = _iterator__ex2g4s.v();
1635
+ var tmp$ret$6 = t.y18(item);
1636
+ destination.x(tmp$ret$6);
1928
1637
  }
1929
- var transformed = tmp;
1930
- return transformChildren_0(transformed, transformer);
1931
- };
1638
+ tmp_2 = new Case(tmp_3, destination);
1639
+ }
1640
+ var tmp4_elvis_lhs = tmp_2;
1641
+ return tmp4_elvis_lhs == null ? transformChildren_1(_this__u8e3s4, t) : tmp4_elvis_lhs;
1932
1642
  }
1933
- function injectResponseFromImpls$lambda(element, transformer) {
1643
+ function validateFunction(_this__u8e3s4) {
1934
1644
  _init_properties_RustIrTransformer_kt__rrvmwq();
1935
- var tmp;
1645
+ return function_0('validate', VOID, VOID, validateFunction$lambda(_this__u8e3s4));
1646
+ }
1647
+ function toStringFunction(_this__u8e3s4) {
1648
+ _init_properties_RustIrTransformer_kt__rrvmwq();
1649
+ return function_0('to_string', VOID, VOID, toStringFunction$lambda(_this__u8e3s4));
1650
+ }
1651
+ function apiStruct(_this__u8e3s4) {
1652
+ _init_properties_RustIrTransformer_kt__rrvmwq();
1653
+ var pathTemplate = joinToString(_this__u8e3s4.ir_1, '/', '/', VOID, VOID, VOID, apiStruct$lambda);
1654
+ return trimIndent('\n pub struct Api;\n impl Server for Api {\n type Req = Request;\n type Res = Response;\n fn path_template(&self) -> &\'static str { "' + pathTemplate + '" }\n fn method(&self) -> Method { Method::' + _this__u8e3s4.hr_1.e3_1 + ' }\n }\n ');
1655
+ }
1656
+ function transformedArguments(_this__u8e3s4, t) {
1657
+ _init_properties_RustIrTransformer_kt__rrvmwq();
1658
+ // Inline function 'kotlin.collections.mapValues' call
1659
+ var this_0 = _this__u8e3s4.hu_1;
1660
+ // Inline function 'kotlin.collections.mapValuesTo' call
1661
+ var destination = LinkedHashMap_init_$Create$(mapCapacity(this_0.c1()));
1662
+ // Inline function 'kotlin.collections.associateByTo' call
1663
+ var _iterator__ex2g4s = this_0.m1().t();
1664
+ while (_iterator__ex2g4s.u()) {
1665
+ var element = _iterator__ex2g4s.v();
1666
+ var tmp = element.n1();
1667
+ var tmp$ret$4 = t.z18(element.o1());
1668
+ destination.w2(tmp, tmp$ret$4);
1669
+ }
1670
+ return destination;
1671
+ }
1672
+ function borrowParameters$lambda(element, transformer) {
1673
+ _init_properties_RustIrTransformer_kt__rrvmwq();
1674
+ var tmp;
1675
+ var tmp_0;
1676
+ if (element instanceof Interface) {
1677
+ tmp_0 = element.rv_1.equals(Companion_getInstance().au('Call'));
1678
+ } else {
1679
+ tmp_0 = false;
1680
+ }
1681
+ if (tmp_0) {
1682
+ tmp = element;
1683
+ } else {
1684
+ if (element instanceof Function_0) {
1685
+ // Inline function 'kotlin.collections.map' call
1686
+ var this_0 = element.tx_1;
1687
+ // Inline function 'kotlin.collections.mapTo' call
1688
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
1689
+ var _iterator__ex2g4s = this_0.t();
1690
+ while (_iterator__ex2g4s.u()) {
1691
+ var item = _iterator__ex2g4s.v();
1692
+ var tmp$ret$2 = item.sz(VOID, borrowed(item.pz_1));
1693
+ destination.x(tmp$ret$2);
1694
+ }
1695
+ tmp = transformChildren_2(element.dy(VOID, VOID, destination), transformer);
1696
+ } else {
1697
+ tmp = transformChildren_2(element, transformer);
1698
+ }
1699
+ }
1700
+ return tmp;
1701
+ }
1702
+ function borrowSerializationArguments$lambda(statement, transformer) {
1703
+ _init_properties_RustIrTransformer_kt__rrvmwq();
1704
+ var tmp;
1705
+ var tmp_0;
1706
+ if (statement instanceof FunctionCall) {
1707
+ tmp_0 = get_serializationFunctions().i1(statement.qy_1.eu());
1708
+ } else {
1709
+ tmp_0 = false;
1710
+ }
1711
+ if (tmp_0) {
1712
+ // Inline function 'kotlin.collections.mapIndexed' call
1713
+ var this_0 = statement.ry_1.m1();
1714
+ // Inline function 'kotlin.collections.mapIndexedTo' call
1715
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
1716
+ var index = 0;
1717
+ var _iterator__ex2g4s = this_0.t();
1718
+ while (_iterator__ex2g4s.u()) {
1719
+ var item = _iterator__ex2g4s.v();
1720
+ var _unary__edvuaz = index;
1721
+ index = _unary__edvuaz + 1 | 0;
1722
+ var index_0 = checkIndexOverflow(_unary__edvuaz);
1723
+ // Inline function 'kotlin.collections.component1' call
1724
+ var name = item.n1();
1725
+ // Inline function 'kotlin.collections.component2' call
1726
+ var value = item.o1();
1727
+ // Inline function 'kotlin.let' call
1728
+ var argument = transformer.z18(value);
1729
+ var tmp_1;
1730
+ var tmp_2;
1731
+ if (index_0 === 0) {
1732
+ var tmp_3;
1733
+ if (argument instanceof VariableReference) {
1734
+ tmp_3 = argument.ev_1.bu() === 'it';
1735
+ } else {
1736
+ tmp_3 = false;
1737
+ }
1738
+ tmp_2 = !tmp_3;
1739
+ } else {
1740
+ tmp_2 = false;
1741
+ }
1742
+ if (tmp_2) {
1743
+ tmp_1 = new RawExpression('&' + toRawCode(argument));
1744
+ } else {
1745
+ tmp_1 = argument;
1746
+ }
1747
+ var tmp$ret$5 = tmp_1;
1748
+ var tmp$ret$2 = to(name, tmp$ret$5);
1749
+ destination.x(tmp$ret$2);
1750
+ }
1751
+ tmp = statement.uy(VOID, VOID, VOID, toMap(destination));
1752
+ } else {
1753
+ tmp = transformChildren(statement, transformer);
1754
+ }
1755
+ return tmp;
1756
+ }
1757
+ function fixResponseSwitchPatterns$lambda(s, t) {
1758
+ _init_properties_RustIrTransformer_kt__rrvmwq();
1759
+ var tmp0_safe_receiver = s instanceof Switch ? s : null;
1760
+ var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.cz_1;
1761
+ var tmp;
1762
+ if (tmp1_safe_receiver == null) {
1763
+ tmp = null;
1764
+ } else {
1765
+ // Inline function 'kotlin.takeIf' call
1766
+ var tmp_0;
1767
+ if (tmp1_safe_receiver.cu() === 'r') {
1768
+ tmp_0 = tmp1_safe_receiver;
1769
+ } else {
1770
+ tmp_0 = null;
1771
+ }
1772
+ tmp = tmp_0;
1773
+ }
1774
+ var variable = tmp;
1775
+ var tmp_1;
1776
+ var tmp_2;
1777
+ if (s instanceof Switch) {
1778
+ tmp_2 = !(variable == null);
1779
+ } else {
1780
+ tmp_2 = false;
1781
+ }
1782
+ if (tmp_2) {
1783
+ var tmp_3 = t.z18(s.zy_1);
1784
+ // Inline function 'kotlin.collections.map' call
1785
+ var this_0 = s.az_1;
1786
+ // Inline function 'kotlin.collections.mapTo' call
1787
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
1788
+ var _iterator__ex2g4s = this_0.t();
1789
+ while (_iterator__ex2g4s.u()) {
1790
+ var item = _iterator__ex2g4s.v();
1791
+ var tmp$ret$4 = matchingResponse(item, variable, t);
1792
+ destination.x(tmp$ret$4);
1793
+ }
1794
+ tmp_1 = s.ez(tmp_3, destination, null);
1795
+ } else {
1796
+ tmp_1 = transformChildren(s, t);
1797
+ }
1798
+ return tmp_1;
1799
+ }
1800
+ function replaceStructWithRefinedFunctions$lambda($refined) {
1801
+ return function (element, transformer) {
1802
+ var tmp;
1803
+ if (element instanceof Struct) {
1804
+ tmp = element.qx(VOID, VOID, VOID, VOID, listOf_0([validateFunction($refined), toStringFunction($refined)]));
1805
+ } else {
1806
+ tmp = element;
1807
+ }
1808
+ var transformed = tmp;
1809
+ return transformChildren_2(transformed, transformer);
1810
+ };
1811
+ }
1812
+ function injectApiStruct$lambda($endpoint) {
1813
+ return function (element, transformer) {
1814
+ var tmp;
1815
+ if (element instanceof Namespace) {
1816
+ tmp = element.qv(VOID, plus_0(element.mv_1, new RawElement(apiStruct($endpoint))));
1817
+ } else {
1818
+ tmp = element;
1819
+ }
1820
+ var transformed = tmp;
1821
+ return transformChildren_2(transformed, transformer);
1822
+ };
1823
+ }
1824
+ function injectResponseFromImpls$lambda(element, transformer) {
1825
+ _init_properties_RustIrTransformer_kt__rrvmwq();
1826
+ var tmp;
1936
1827
  if (element instanceof File) {
1937
1828
  // Inline function 'kotlin.collections.flatMap' call
1938
1829
  var tmp0 = element.gv_1;
1939
1830
  // Inline function 'kotlin.collections.flatMapTo' call
1940
- var destination = ArrayList_init_$Create$_0();
1831
+ var destination = ArrayList_init_$Create$();
1941
1832
  var _iterator__ex2g4s = tmp0.t();
1942
1833
  while (_iterator__ex2g4s.u()) {
1943
1834
  var element_0 = _iterator__ex2g4s.v();
1944
- var tmp_0;
1835
+ var tmp_0 = listOf(element_0);
1945
1836
  var tmp_1;
1946
1837
  var tmp_2;
1947
1838
  if (element_0 instanceof Union_0) {
@@ -1950,29 +1841,22 @@ function injectResponseFromImpls$lambda(element, transformer) {
1950
1841
  tmp_2 = false;
1951
1842
  }
1952
1843
  if (tmp_2) {
1953
- // Inline function 'kotlin.collections.isNotEmpty' call
1954
- tmp_1 = !element_0.nw_1.r();
1955
- } else {
1956
- tmp_1 = false;
1957
- }
1958
- if (tmp_1) {
1959
- var tmp_3 = listOf(element_0);
1960
1844
  // Inline function 'kotlin.collections.map' call
1961
1845
  var this_0 = element_0.nw_1;
1962
1846
  // Inline function 'kotlin.collections.mapTo' call
1963
- var destination_0 = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
1847
+ var destination_0 = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
1964
1848
  var _iterator__ex2g4s_0 = this_0.t();
1965
1849
  while (_iterator__ex2g4s_0.u()) {
1966
1850
  var item = _iterator__ex2g4s_0.v();
1967
1851
  var memberName = item.ru_1.du();
1968
- var tmp$ret$7 = new RawElement('impl From<' + memberName + '> for Response { fn from(value: ' + memberName + ') -> Self { Response::' + memberName + '(value) } }\n');
1969
- destination_0.x(tmp$ret$7);
1852
+ var tmp$ret$6 = new RawElement('impl From<' + memberName + '> for Response { fn from(value: ' + memberName + ') -> Self { Response::' + memberName + '(value) } }\n');
1853
+ destination_0.x(tmp$ret$6);
1970
1854
  }
1971
- tmp_0 = plus(tmp_3, destination_0);
1855
+ tmp_1 = destination_0;
1972
1856
  } else {
1973
- tmp_0 = listOf(element_0);
1857
+ tmp_1 = emptyList();
1974
1858
  }
1975
- var list = tmp_0;
1859
+ var list = plus(tmp_0, tmp_1);
1976
1860
  addAll(destination, list);
1977
1861
  }
1978
1862
  tmp = element.jv(VOID, destination);
@@ -1980,51 +1864,47 @@ function injectResponseFromImpls$lambda(element, transformer) {
1980
1864
  tmp = element;
1981
1865
  }
1982
1866
  var transformed = tmp;
1983
- return transformChildren_0(transformed, transformer);
1867
+ return transformChildren_2(transformed, transformer);
1984
1868
  }
1985
1869
  function injectHandlerImplForClient$lambda(element, transformer) {
1986
1870
  _init_properties_RustIrTransformer_kt__rrvmwq();
1987
1871
  var tmp;
1988
1872
  if (element instanceof Namespace) {
1989
- var tmp$ret$0;
1990
- $l$block_1: {
1991
- // Inline function 'kotlin.collections.filterIsInstance' call
1992
- var tmp0 = element.mv_1;
1993
- // Inline function 'kotlin.collections.filterIsInstanceTo' call
1994
- var destination = ArrayList_init_$Create$_0();
1995
- var _iterator__ex2g4s = tmp0.t();
1996
- while (_iterator__ex2g4s.u()) {
1997
- var element_0 = _iterator__ex2g4s.v();
1998
- if (element_0 instanceof Interface) {
1999
- destination.x(element_0);
2000
- }
1873
+ // Inline function 'community.flock.wirespec.compiler.core.ir.findElement' call
1874
+ // Inline function 'kotlin.collections.filterIsInstance' call
1875
+ var tmp0 = element.hv();
1876
+ // Inline function 'kotlin.collections.filterIsInstanceTo' call
1877
+ var destination = ArrayList_init_$Create$();
1878
+ var _iterator__ex2g4s = tmp0.t();
1879
+ while (_iterator__ex2g4s.u()) {
1880
+ var element_0 = _iterator__ex2g4s.v();
1881
+ if (element_0 instanceof Interface) {
1882
+ destination.x(element_0);
2001
1883
  }
2002
- var tmp$ret$3;
2003
- $l$block: {
2004
- // Inline function 'kotlin.collections.firstOrNull' call
2005
- var _iterator__ex2g4s_0 = destination.t();
2006
- while (_iterator__ex2g4s_0.u()) {
2007
- var element_1 = _iterator__ex2g4s_0.v();
2008
- if (element_1.rv_1.equals(Companion_getInstance().au('Handler'))) {
2009
- tmp$ret$3 = element_1;
2010
- break $l$block;
2011
- }
1884
+ }
1885
+ var tmp$ret$4;
1886
+ $l$block: {
1887
+ // Inline function 'kotlin.collections.firstOrNull' call
1888
+ var _iterator__ex2g4s_0 = destination.t();
1889
+ while (_iterator__ex2g4s_0.u()) {
1890
+ var element_1 = _iterator__ex2g4s_0.v();
1891
+ if (element_1.rv_1.equals(Companion_getInstance().au('Handler'))) {
1892
+ tmp$ret$4 = element_1;
1893
+ break $l$block;
2012
1894
  }
2013
- tmp$ret$3 = null;
2014
1895
  }
2015
- var tmp0_elvis_lhs = tmp$ret$3;
2016
- var tmp_0;
2017
- if (tmp0_elvis_lhs == null) {
2018
- tmp$ret$0 = element;
2019
- break $l$block_1;
2020
- } else {
2021
- tmp_0 = tmp0_elvis_lhs;
2022
- }
2023
- var handler = tmp_0;
1896
+ tmp$ret$4 = null;
1897
+ }
1898
+ var tmp0_safe_receiver = tmp$ret$4;
1899
+ var tmp_0;
1900
+ if (tmp0_safe_receiver == null) {
1901
+ tmp_0 = null;
1902
+ } else {
1903
+ // Inline function 'community.flock.wirespec.compiler.core.ir.findElement' call
2024
1904
  // Inline function 'kotlin.collections.filterIsInstance' call
2025
- var tmp0_0 = handler.sv_1;
1905
+ var tmp0_0 = tmp0_safe_receiver.hv();
2026
1906
  // Inline function 'kotlin.collections.filterIsInstanceTo' call
2027
- var destination_0 = ArrayList_init_$Create$_0();
1907
+ var destination_0 = ArrayList_init_$Create$();
2028
1908
  var _iterator__ex2g4s_1 = tmp0_0.t();
2029
1909
  while (_iterator__ex2g4s_1.u()) {
2030
1910
  var element_2 = _iterator__ex2g4s_1.v();
@@ -2032,67 +1912,23 @@ function injectHandlerImplForClient$lambda(element, transformer) {
2032
1912
  destination_0.x(element_2);
2033
1913
  }
2034
1914
  }
2035
- var tmp1_elvis_lhs = firstOrNull_0(destination_0);
2036
- var tmp_1;
2037
- if (tmp1_elvis_lhs == null) {
2038
- tmp$ret$0 = element;
2039
- break $l$block_1;
2040
- } else {
2041
- tmp_1 = tmp1_elvis_lhs;
2042
- }
2043
- var method = tmp_1;
2044
- var methodName = method.rx_1.eu();
2045
- tmp$ret$0 = element.qv(VOID, plus(element.mv_1, listOf(new RawElement(trimIndent('\n impl<C: Client> Handler for C {\n async fn ' + methodName + '(&self, request: Request) -> Response {\n let raw = to_raw_request(self.serialization(), request);\n let resp = self.transport().transport(&raw).await;\n from_raw_response(self.serialization(), resp)\n }\n }\n ')))));
1915
+ tmp_0 = firstOrNull(destination_0);
2046
1916
  }
2047
- tmp = tmp$ret$0;
2048
- } else {
2049
- tmp = element;
2050
- }
2051
- var transformed = tmp;
2052
- return transformChildren_0(transformed, transformer);
2053
- }
2054
- function injectSelfToHandlerMethods$lambda(element, transformer) {
2055
- _init_properties_RustIrTransformer_kt__rrvmwq();
2056
- var tmp;
2057
- if (element instanceof Interface) {
2058
- var tmp$ret$0;
2059
- $l$block: {
2060
- if (!element.rv_1.equals(Companion_getInstance().au('Handler')) && !element.rv_1.equals(Companion_getInstance().au('Call'))) {
2061
- tmp$ret$0 = element;
2062
- break $l$block;
2063
- }
2064
- // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
2065
- var scope = new TransformScope(element);
2066
- // Inline function 'community.flock.wirespec.compiler.core.ir.TransformScope.matchingElements' call
2067
- var tmp_0 = scope;
2068
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformMatchingElements' call
2069
- var this_0 = scope.e19_1;
2070
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformer' call
2071
- // Inline function 'kotlin.apply' call
2072
- var this_1 = new TransformerBuilder();
2073
- this_1.y19(injectSelfToHandlerMethods$lambda$lambda);
2074
- var tmp$ret$5 = this_1.t19();
2075
- tmp_0.e19_1 = transform(this_0, tmp$ret$5);
2076
- var tmp_1 = scope.e19_1;
2077
- tmp$ret$0 = isInterface(tmp_1, Element) ? tmp_1 : THROW_CCE();
1917
+ var tmp1_safe_receiver = tmp_0;
1918
+ var tmp_1;
1919
+ if (tmp1_safe_receiver == null) {
1920
+ tmp_1 = null;
1921
+ } else {
1922
+ // Inline function 'kotlin.let' call
1923
+ tmp_1 = element.qv(VOID, plus_0(element.mv_1, new RawElement(trimIndent('\n impl<C: Client> Handler for C {\n async fn ' + tmp1_safe_receiver.rx_1.eu() + '(&self, request: Request) -> Response {\n let raw = to_raw_request(self.serialization(), request);\n let resp = self.transport().transport(&raw).await;\n from_raw_response(self.serialization(), resp)\n }\n }\n '))));
2078
1924
  }
2079
- tmp = tmp$ret$0;
1925
+ var tmp2_elvis_lhs = tmp_1;
1926
+ tmp = tmp2_elvis_lhs == null ? element : tmp2_elvis_lhs;
2080
1927
  } else {
2081
1928
  tmp = element;
2082
1929
  }
2083
1930
  var transformed = tmp;
2084
- return transformChildren_0(transformed, transformer);
2085
- }
2086
- function injectSelfToHandlerMethods$lambda$lambda(element, transformer) {
2087
- _init_properties_RustIrTransformer_kt__rrvmwq();
2088
- var tmp;
2089
- if (element instanceof Function_0) {
2090
- tmp = element.dy(Companion_getInstance().au(element.rx_1.eu()), VOID, plus(listOf(get_rustSelfParam()), element.tx_1));
2091
- } else {
2092
- tmp = element;
2093
- }
2094
- var transformed = tmp;
2095
- return transformChildren_0(transformed, transformer);
1931
+ return transformChildren_2(transformed, transformer);
2096
1932
  }
2097
1933
  function stripResponseGenerics$lambda(type, transformer) {
2098
1934
  _init_properties_RustIrTransformer_kt__rrvmwq();
@@ -2116,31 +1952,25 @@ function stripResponseGenerics$lambda(type, transformer) {
2116
1952
  tmp = type;
2117
1953
  }
2118
1954
  var transformed = tmp;
2119
- return transformChildren_2(transformed, transformer);
1955
+ return transformChildren_3(transformed, transformer);
2120
1956
  }
2121
- function stripHandlerExtends$lambda(element, transformer) {
1957
+ function rustHandlerTraits$lambda(element, transformer) {
2122
1958
  _init_properties_RustIrTransformer_kt__rrvmwq();
2123
1959
  var tmp;
2124
1960
  if (element instanceof Interface) {
2125
- tmp = element.rv_1.equals(Companion_getInstance().au('Handler')) || element.rv_1.equals(Companion_getInstance().au('Call')) ? element.zv(VOID, VOID, emptyList()) : element;
1961
+ tmp = element.rv_1.equals(Companion_getInstance().au('Handler')) || element.rv_1.equals(Companion_getInstance().au('Call')) ? withSelfReceivers(element.zv(VOID, VOID, emptyList())) : element;
2126
1962
  } else {
2127
1963
  tmp = element;
2128
1964
  }
2129
1965
  var transformed = tmp;
2130
- return transformChildren_0(transformed, transformer);
1966
+ return transformChildren_2(transformed, transformer);
2131
1967
  }
2132
1968
  function convertSimpleRawExpressionsToVariableRefs$lambda($identifierPattern) {
2133
1969
  return function (s, t) {
2134
1970
  var tmp;
2135
1971
  var tmp_0;
2136
- var tmp_1;
2137
1972
  if (s instanceof RawExpression) {
2138
- tmp_1 = $identifierPattern.sc(s.gy_1);
2139
- } else {
2140
- tmp_1 = false;
2141
- }
2142
- if (tmp_1) {
2143
- tmp_0 = !contains(s.gy_1, '.');
1973
+ tmp_0 = $identifierPattern.sc(s.gy_1);
2144
1974
  } else {
2145
1975
  tmp_0 = false;
2146
1976
  }
@@ -2157,62 +1987,80 @@ function stripWirespecPrefix$lambda(type, transformer) {
2157
1987
  var tmp;
2158
1988
  if (type instanceof Custom) {
2159
1989
  var pascalName = type.ru_1.du();
2160
- var tmp_0;
2161
- if (startsWith(pascalName, 'Wirespec.')) {
2162
- tmp_0 = type.uu(Companion_getInstance().au(removePrefix(pascalName, 'Wirespec.')));
2163
- } else {
2164
- tmp_0 = type;
2165
- }
2166
- tmp = tmp_0;
1990
+ tmp = startsWith(pascalName, 'Wirespec.') ? type.uu(Companion_getInstance().au(removePrefix(pascalName, 'Wirespec.'))) : type;
2167
1991
  } else {
2168
1992
  tmp = type;
2169
1993
  }
2170
1994
  var transformed = tmp;
2171
- return transformChildren_2(transformed, transformer);
1995
+ return transformChildren_3(transformed, transformer);
2172
1996
  }
2173
1997
  function fixConstructorCalls$lambda(s, t) {
2174
1998
  _init_properties_RustIrTransformer_kt__rrvmwq();
2175
- if (!(s instanceof ConstructorStatement))
2176
- return transformChildren(s, t);
2177
- var tmp = s.gu_1;
2178
- var tmp0_safe_receiver = tmp instanceof Custom ? tmp : null;
2179
- var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.ru_1;
2180
- var typeName = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.du();
2181
- // Inline function 'kotlin.collections.mapValues' call
2182
- var this_0 = s.hu_1;
2183
- // Inline function 'kotlin.collections.mapValuesTo' call
2184
- var destination = LinkedHashMap_init_$Create$(mapCapacity(this_0.c1()));
2185
- // Inline function 'kotlin.collections.associateByTo' call
2186
- var _iterator__ex2g4s = this_0.m1().t();
2187
- while (_iterator__ex2g4s.u()) {
2188
- var element = _iterator__ex2g4s.v();
2189
- var tmp_0 = element.n1();
2190
- var tmp$ret$4 = t.z18(element.o1());
2191
- destination.w2(tmp_0, tmp$ret$4);
1999
+ var tmp0_safe_receiver = s instanceof ConstructorStatement ? s : null;
2000
+ var tmp = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.gu_1;
2001
+ var tmp1_safe_receiver = tmp instanceof Custom ? tmp : null;
2002
+ var tmp2_safe_receiver = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.ru_1;
2003
+ var typeName = tmp2_safe_receiver == null ? null : tmp2_safe_receiver.du();
2004
+ var tmp_0;
2005
+ var tmp_1;
2006
+ if (!(s instanceof ConstructorStatement)) {
2007
+ tmp_1 = true;
2008
+ } else {
2009
+ tmp_1 = typeName == null;
2192
2010
  }
2193
- var transformedArgs = destination;
2194
- return !(typeName == null) && get_rustResponsePattern().sc(typeName) ? new FunctionCall(VOID, VOID, new Name(listOf('Response::' + typeName)), mapOf_0(to(Companion_getInstance().au('inner'), new FunctionCall(VOID, VOID, new Name(listOf(typeName + '::new')), transformedArgs)))) : typeName === 'Request' ? new FunctionCall(VOID, VOID, new Name(listOf('Request::new')), transformedArgs) : transformChildren(s, t);
2011
+ if (tmp_1) {
2012
+ tmp_0 = transformChildren(s, t);
2013
+ } else {
2014
+ if (get_rustResponsePattern().sc(typeName)) {
2015
+ tmp_0 = new FunctionCall(VOID, VOID, new Name(listOf('Response::' + typeName)), mapOf_0(to(Companion_getInstance().au('inner'), new FunctionCall(VOID, VOID, new Name(listOf(typeName + '::new')), transformedArguments(s, t)))));
2016
+ } else {
2017
+ if (typeName === 'Request') {
2018
+ tmp_0 = new FunctionCall(VOID, VOID, new Name(listOf('Request::new')), transformedArguments(s, t));
2019
+ } else {
2020
+ tmp_0 = transformChildren(s, t);
2021
+ }
2022
+ }
2023
+ }
2024
+ return tmp_0;
2025
+ }
2026
+ function rustName$lambda(it) {
2027
+ _init_properties_RustIrTransformer_kt__rrvmwq();
2028
+ return rustName(it);
2029
+ }
2030
+ function rustName$lambda_0(it) {
2031
+ _init_properties_RustIrTransformer_kt__rrvmwq();
2032
+ return rustName(it);
2033
+ }
2034
+ function toRawCode$lambda(it) {
2035
+ _init_properties_RustIrTransformer_kt__rrvmwq();
2036
+ return it.n1().eu() + ': ' + toRawCode(it.o1());
2195
2037
  }
2196
- function buildValidateFunction$lambda($constraintExpr) {
2038
+ function validateFunction$lambda($this_validateFunction) {
2197
2039
  return function ($this$function) {
2198
2040
  $this$function.a14('&self', Custom_init_$Create$(''));
2199
2041
  $this$function.x13(Boolean_instance);
2200
- $this$function.d14($constraintExpr);
2042
+ $this$function.d14(convertConstraint($this_validateFunction.ns_1, new FieldCall(new VariableReference(Companion_getInstance().au('self')), Companion_getInstance().au('value'))));
2201
2043
  return Unit_instance;
2202
2044
  };
2203
2045
  }
2204
- function buildToStringFunction$lambda($expr) {
2046
+ function toStringFunction$lambda($this_toStringFunction) {
2205
2047
  return function ($this$function) {
2206
2048
  $this$function.a14('&self', Custom_init_$Create$(''));
2207
2049
  $this$function.x13(String_instance);
2208
- $this$function.d14(new RawExpression($expr));
2050
+ var tmp;
2051
+ if ($this_toStringFunction.ns_1.d1a_1 instanceof String_1) {
2052
+ tmp = 'self.value.clone()';
2053
+ } else {
2054
+ tmp = 'format!("{}", self.value)';
2055
+ }
2056
+ $this$function.d14(new RawExpression(tmp));
2209
2057
  return Unit_instance;
2210
2058
  };
2211
2059
  }
2212
- function generateApiStructCode$lambda(segment) {
2060
+ function apiStruct$lambda(segment) {
2213
2061
  _init_properties_RustIrTransformer_kt__rrvmwq();
2214
2062
  var tmp;
2215
- if (segment instanceof Literal) {
2063
+ if (segment instanceof Literal_0) {
2216
2064
  tmp = segment.e1b_1;
2217
2065
  } else {
2218
2066
  if (segment instanceof Param) {
@@ -2229,483 +2077,20 @@ function _init_properties_RustIrTransformer_kt__rrvmwq() {
2229
2077
  properties_initialized_RustIrTransformer_kt_hr6k9w = true;
2230
2078
  rustSelfParam = new Parameter(Companion_getInstance().au('&self'), Custom_init_$Create$(''));
2231
2079
  rustResponsePattern = Regex_init_$Create$('Response(\\d+|Default)');
2080
+ serializerTraits = setOf(['Serializer', 'Deserializer']);
2081
+ serializationFunctions = setOf(['serialize_path', 'serialize_param', 'serialize_body', 'deserialize_path', 'deserialize_param', 'deserialize_body']);
2082
+ // Inline function 'community.flock.wirespec.compiler.core.ir.transformer' call
2083
+ // Inline function 'kotlin.apply' call
2084
+ var this_0 = new TransformerBuilder();
2085
+ this_0.y19(borrowParameters$lambda);
2086
+ borrowParameters = this_0.t19();
2087
+ // Inline function 'community.flock.wirespec.compiler.core.ir.transformer' call
2088
+ // Inline function 'kotlin.apply' call
2089
+ var this_1 = new TransformerBuilder();
2090
+ this_1.w19(borrowSerializationArguments$lambda);
2091
+ borrowSerializationArguments = this_1.t19();
2232
2092
  }
2233
2093
  }
2234
- function borrowParamsOf($this, fn) {
2235
- // Inline function 'kotlin.collections.map' call
2236
- var this_0 = fn.tx_1;
2237
- // Inline function 'kotlin.collections.mapTo' call
2238
- var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
2239
- var _iterator__ex2g4s = this_0.t();
2240
- while (_iterator__ex2g4s.u()) {
2241
- var item = _iterator__ex2g4s.v();
2242
- var tmp;
2243
- if (RustTransform_getInstance().c39(item.oz_1)) {
2244
- tmp = item;
2245
- } else {
2246
- tmp = item.sz(VOID, applyBorrowRule(RustTransform_getInstance(), item.pz_1));
2247
- }
2248
- var tmp$ret$2 = tmp;
2249
- destination.x(tmp$ret$2);
2250
- }
2251
- return fn.dy(VOID, VOID, destination);
2252
- }
2253
- function applyBorrowRule($this, type) {
2254
- var tmp;
2255
- if (type instanceof Nullable) {
2256
- tmp = new Nullable(applyBorrowRule($this, type.vu_1));
2257
- } else {
2258
- if (equals(type, String_instance)) {
2259
- tmp = Custom_init_$Create$('&str');
2260
- } else {
2261
- if (type instanceof Custom) {
2262
- tmp = $this.f39(type) ? type : $this.e39(type) ? borrowImpl(type) : $this.d39(type) ? ownedImpl(type) : type;
2263
- } else {
2264
- tmp = type;
2265
- }
2266
- }
2267
- }
2268
- return tmp;
2269
- }
2270
- function toBorrowedRaw($this, $receiver) {
2271
- return new RawExpression('&' + toRawCode($this, $receiver));
2272
- }
2273
- function sanitizeKeywords_0($this, $receiver) {
2274
- return Companion_getInstance_0().n37().i1($receiver) ? 'r#' + $receiver : $receiver;
2275
- }
2276
- function toRawCode($this, $receiver) {
2277
- var tmp;
2278
- if ($receiver instanceof VariableReference) {
2279
- tmp = sanitizeKeywords_0($this, $receiver.ev_1.eu());
2280
- } else {
2281
- if ($receiver instanceof FieldCall) {
2282
- var tmp1_safe_receiver = $receiver.kz_1;
2283
- var tmp_0;
2284
- if (tmp1_safe_receiver == null) {
2285
- tmp_0 = null;
2286
- } else {
2287
- // Inline function 'kotlin.let' call
2288
- tmp_0 = toRawCode(RustTransform_getInstance(), tmp1_safe_receiver) + '.';
2289
- }
2290
- var tmp2_elvis_lhs = tmp_0;
2291
- var recv = tmp2_elvis_lhs == null ? '' : tmp2_elvis_lhs;
2292
- tmp = recv + sanitizeKeywords_0($this, $receiver.lz_1.eu());
2293
- } else {
2294
- if ($receiver instanceof ArrayIndexCall) {
2295
- var tmp_1 = $receiver.c10_1;
2296
- var lit = tmp_1 instanceof Literal_0 ? tmp_1 : null;
2297
- var tmp_2;
2298
- var tmp_3;
2299
- if (!(lit == null)) {
2300
- var tmp_4;
2301
- var tmp_5 = lit.wy_1;
2302
- if (tmp_5 instanceof Integer) {
2303
- tmp_4 = true;
2304
- } else {
2305
- var tmp_6 = lit.wy_1;
2306
- tmp_4 = tmp_6 instanceof Number_0;
2307
- }
2308
- tmp_3 = tmp_4;
2309
- } else {
2310
- tmp_3 = false;
2311
- }
2312
- if (tmp_3) {
2313
- tmp_2 = toString_0(lit.vy_1);
2314
- } else {
2315
- var tmp_7;
2316
- if (!(lit == null)) {
2317
- var tmp_8 = lit.wy_1;
2318
- tmp_7 = tmp_8 instanceof String_1;
2319
- } else {
2320
- tmp_7 = false;
2321
- }
2322
- if (tmp_7) {
2323
- tmp_2 = '"' + toString_0(lit.vy_1) + '"';
2324
- } else {
2325
- tmp_2 = toRawCode($this, $receiver.c10_1);
2326
- }
2327
- }
2328
- var idx = tmp_2;
2329
- tmp = toRawCode($this, $receiver.b10_1) + '[' + idx + ']';
2330
- } else {
2331
- if ($receiver instanceof ConstructorStatement) {
2332
- var tmp_9 = $receiver.gu_1;
2333
- var tmp3_safe_receiver = tmp_9 instanceof Custom ? tmp_9 : null;
2334
- var tmp4_safe_receiver = tmp3_safe_receiver == null ? null : tmp3_safe_receiver.ru_1;
2335
- var tmp5_elvis_lhs = tmp4_safe_receiver == null ? null : tmp4_safe_receiver.du();
2336
- var typeName = tmp5_elvis_lhs == null ? toString_0($receiver.gu_1) : tmp5_elvis_lhs;
2337
- var tmp_10 = $receiver.hu_1.m1();
2338
- var args = joinToString(tmp_10, ', ', VOID, VOID, VOID, VOID, RustTransform$toRawCode$lambda);
2339
- var tmp_11;
2340
- // Inline function 'kotlin.text.isEmpty' call
2341
- if (charSequenceLength(args) === 0) {
2342
- tmp_11 = typeName + ' {}';
2343
- } else {
2344
- tmp_11 = typeName + ' { ' + args + ' }';
2345
- }
2346
- tmp = tmp_11;
2347
- } else {
2348
- if ($receiver instanceof Literal_0) {
2349
- var tmp_12;
2350
- var tmp_13 = $receiver.wy_1;
2351
- if (tmp_13 instanceof String_1) {
2352
- tmp_12 = 'String::from("' + toString_0($receiver.vy_1) + '")';
2353
- } else {
2354
- var tmp_14 = $receiver.wy_1;
2355
- if (tmp_14 instanceof Boolean_0) {
2356
- tmp_12 = toString_0($receiver.vy_1);
2357
- } else {
2358
- var tmp_15 = $receiver.wy_1;
2359
- if (tmp_15 instanceof Integer) {
2360
- tmp_12 = toString_0($receiver.vy_1);
2361
- } else {
2362
- var tmp_16 = $receiver.wy_1;
2363
- if (tmp_16 instanceof Number_0) {
2364
- tmp_12 = toString_0($receiver.vy_1);
2365
- } else {
2366
- tmp_12 = toString_0($receiver.vy_1);
2367
- }
2368
- }
2369
- }
2370
- }
2371
- tmp = tmp_12;
2372
- } else {
2373
- if ($receiver instanceof RawExpression) {
2374
- tmp = $receiver.gy_1;
2375
- } else {
2376
- // Inline function 'kotlin.error' call
2377
- var message = 'Unsupported expression type in toRawCode: ' + getKClassFromExpression($receiver).o();
2378
- throw IllegalStateException_init_$Create$(toString_0(message));
2379
- }
2380
- }
2381
- }
2382
- }
2383
- }
2384
- }
2385
- return tmp;
2386
- }
2387
- function RustTransform$primitivesToCustom$lambda(t, tr) {
2388
- var tmp;
2389
- if (equals(t, Any_instance)) {
2390
- tmp = Custom_init_$Create$('Box<dyn std::any::Any>');
2391
- } else {
2392
- if (equals(t, Bytes_instance)) {
2393
- tmp = Custom_init_$Create$('Vec<u8>');
2394
- } else {
2395
- if (equals(t, Reflect_instance)) {
2396
- tmp = Custom_init_$Create$('std::any::TypeId');
2397
- } else {
2398
- if (equals(t, Wildcard_instance)) {
2399
- tmp = Custom_init_$Create$('_');
2400
- } else {
2401
- if (t instanceof IntegerLiteral) {
2402
- tmp = Custom_init_$Create$('i32');
2403
- } else {
2404
- if (t instanceof StringLiteral) {
2405
- tmp = Custom_init_$Create$('String');
2406
- } else {
2407
- tmp = transformChildren_2(t, tr);
2408
- }
2409
- }
2410
- }
2411
- }
2412
- }
2413
- }
2414
- return tmp;
2415
- }
2416
- function RustTransform$borrow$lambda(element, tr) {
2417
- var tmp;
2418
- if (element instanceof Interface) {
2419
- var tmp_0;
2420
- if (element.rv_1.equals(Companion_getInstance().au('Call'))) {
2421
- tmp_0 = element;
2422
- } else {
2423
- // Inline function 'kotlin.collections.map' call
2424
- var this_0 = element.sv_1;
2425
- // Inline function 'kotlin.collections.mapTo' call
2426
- var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
2427
- var _iterator__ex2g4s = this_0.t();
2428
- while (_iterator__ex2g4s.u()) {
2429
- var item = _iterator__ex2g4s.v();
2430
- var tmp_1;
2431
- if (item instanceof Function_0) {
2432
- tmp_1 = borrowParamsOf(RustTransform_getInstance(), item);
2433
- } else {
2434
- tmp_1 = item;
2435
- }
2436
- var tmp$ret$2 = tmp_1;
2437
- destination.x(tmp$ret$2);
2438
- }
2439
- var borrowed = destination;
2440
- tmp_0 = transformChildren_0(element.zv(VOID, borrowed), tr);
2441
- }
2442
- tmp = tmp_0;
2443
- } else {
2444
- if (element instanceof Function_0) {
2445
- tmp = transformChildren_0(borrowParamsOf(RustTransform_getInstance(), element), tr);
2446
- } else {
2447
- tmp = transformChildren_0(element, tr);
2448
- }
2449
- }
2450
- return tmp;
2451
- }
2452
- function RustTransform$serializationArgs$lambda(s, t) {
2453
- var tmp;
2454
- var tmp_0;
2455
- if (s instanceof FunctionCall) {
2456
- tmp_0 = RustTransform_getInstance().y38_1.i1(s.qy_1.eu());
2457
- } else {
2458
- tmp_0 = false;
2459
- }
2460
- if (tmp_0) {
2461
- // Inline function 'kotlin.collections.mapIndexed' call
2462
- var this_0 = s.ry_1.m1();
2463
- // Inline function 'kotlin.collections.mapIndexedTo' call
2464
- var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
2465
- var index = 0;
2466
- var _iterator__ex2g4s = this_0.t();
2467
- while (_iterator__ex2g4s.u()) {
2468
- var item = _iterator__ex2g4s.v();
2469
- var _unary__edvuaz = index;
2470
- index = _unary__edvuaz + 1 | 0;
2471
- var idx = checkIndexOverflow(_unary__edvuaz);
2472
- // Inline function 'kotlin.collections.component1' call
2473
- var key = item.n1();
2474
- // Inline function 'kotlin.collections.component2' call
2475
- var value = item.o1();
2476
- var transformed = t.z18(value);
2477
- var tmp_1;
2478
- var tmp_2;
2479
- if (idx === 0) {
2480
- var tmp_3;
2481
- if (transformed instanceof VariableReference) {
2482
- tmp_3 = transformed.ev_1.bu() === 'it';
2483
- } else {
2484
- tmp_3 = false;
2485
- }
2486
- tmp_2 = !tmp_3;
2487
- } else {
2488
- tmp_2 = false;
2489
- }
2490
- if (tmp_2) {
2491
- tmp_1 = to(key, toBorrowedRaw(RustTransform_getInstance(), transformed));
2492
- } else {
2493
- tmp_1 = to(key, transformed);
2494
- }
2495
- var tmp$ret$2 = tmp_1;
2496
- destination.x(tmp$ret$2);
2497
- }
2498
- var newArgs = toMap(destination);
2499
- tmp = s.uy(VOID, VOID, VOID, newArgs);
2500
- } else {
2501
- tmp = transformChildren(s, t);
2502
- }
2503
- return tmp;
2504
- }
2505
- function RustTransform$rustName$lambda(it) {
2506
- return RustTransform_getInstance().a39(it);
2507
- }
2508
- function RustTransform$rustName$lambda_0(it) {
2509
- return RustTransform_getInstance().a39(it);
2510
- }
2511
- function RustTransform$toRawCode$lambda(it) {
2512
- return it.n1().eu() + ': ' + toRawCode(RustTransform_getInstance(), it.o1());
2513
- }
2514
- function RustTransform() {
2515
- RustTransform_instance = this;
2516
- var tmp = this;
2517
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformer' call
2518
- // Inline function 'kotlin.apply' call
2519
- var this_0 = new TransformerBuilder();
2520
- this_0.k19(RustTransform$primitivesToCustom$lambda);
2521
- tmp.v38_1 = this_0.t19();
2522
- var tmp_0 = this;
2523
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformer' call
2524
- // Inline function 'kotlin.apply' call
2525
- var this_1 = new TransformerBuilder();
2526
- this_1.y19(RustTransform$borrow$lambda);
2527
- tmp_0.w38_1 = this_1.t19();
2528
- var tmp_1 = this;
2529
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformer' call
2530
- // Inline function 'kotlin.apply' call
2531
- tmp_1.x38_1 = (new TransformerBuilder()).t19();
2532
- this.y38_1 = setOf(['serialize_path', 'serialize_param', 'serialize_body', 'deserialize_path', 'deserialize_param', 'deserialize_body']);
2533
- var tmp_2 = this;
2534
- // Inline function 'community.flock.wirespec.compiler.core.ir.transformer' call
2535
- // Inline function 'kotlin.apply' call
2536
- var this_2 = new TransformerBuilder();
2537
- this_2.w19(RustTransform$serializationArgs$lambda);
2538
- tmp_2.z38_1 = this_2.t19();
2539
- }
2540
- protoOf(RustTransform).b39 = function (element) {
2541
- // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
2542
- var scope = new TransformScope(element);
2543
- scope.j19(RustTransform_getInstance().v38_1);
2544
- var tmp = scope.e19_1;
2545
- // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
2546
- var this_0 = isInterface(tmp, Element) ? tmp : THROW_CCE();
2547
- var scope_0 = new TransformScope(this_0);
2548
- scope_0.j19(RustTransform_getInstance().w38_1);
2549
- var tmp_0 = scope_0.e19_1;
2550
- // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
2551
- var this_1 = isInterface(tmp_0, Element) ? tmp_0 : THROW_CCE();
2552
- var scope_1 = new TransformScope(this_1);
2553
- scope_1.j19(RustTransform_getInstance().x38_1);
2554
- var tmp_1 = scope_1.e19_1;
2555
- // Inline function 'community.flock.wirespec.compiler.core.ir.transform' call
2556
- var this_2 = isInterface(tmp_1, Element) ? tmp_1 : THROW_CCE();
2557
- var scope_2 = new TransformScope(this_2);
2558
- scope_2.j19(RustTransform_getInstance().z38_1);
2559
- var tmp_2 = scope_2.e19_1;
2560
- return isInterface(tmp_2, Element) ? tmp_2 : THROW_CCE();
2561
- };
2562
- protoOf(RustTransform).a39 = function (_this__u8e3s4) {
2563
- var tmp;
2564
- if (_this__u8e3s4 instanceof Custom) {
2565
- var pascalName = _this__u8e3s4.ru_1.du();
2566
- var tmp_0;
2567
- if (_this__u8e3s4.su_1.r()) {
2568
- tmp_0 = pascalName;
2569
- } else {
2570
- tmp_0 = pascalName + '<' + joinToString(_this__u8e3s4.su_1, ', ', VOID, VOID, VOID, VOID, RustTransform$rustName$lambda) + '>';
2571
- }
2572
- tmp = tmp_0;
2573
- } else {
2574
- if (equals(_this__u8e3s4, String_instance)) {
2575
- tmp = 'String';
2576
- } else {
2577
- if (_this__u8e3s4 instanceof Nullable) {
2578
- tmp = 'Option<' + this.a39(_this__u8e3s4.vu_1) + '>';
2579
- } else {
2580
- if (_this__u8e3s4 instanceof Array_0) {
2581
- tmp = 'Vec<' + this.a39(_this__u8e3s4.mu_1) + '>';
2582
- } else {
2583
- if (_this__u8e3s4 instanceof Dict) {
2584
- tmp = 'std::collections::HashMap<' + this.a39(_this__u8e3s4.ou_1) + ', ' + this.a39(_this__u8e3s4.pu_1) + '>';
2585
- } else {
2586
- if (equals(_this__u8e3s4, Any_instance)) {
2587
- tmp = 'Box<dyn std::any::Any>';
2588
- } else {
2589
- if (equals(_this__u8e3s4, Bytes_instance)) {
2590
- tmp = 'Vec<u8>';
2591
- } else {
2592
- if (equals(_this__u8e3s4, Unit_instance_0)) {
2593
- tmp = '()';
2594
- } else {
2595
- if (equals(_this__u8e3s4, Boolean_instance)) {
2596
- tmp = 'bool';
2597
- } else {
2598
- if (equals(_this__u8e3s4, Wildcard_instance)) {
2599
- tmp = '_';
2600
- } else {
2601
- if (equals(_this__u8e3s4, Reflect_instance)) {
2602
- tmp = 'std::any::TypeId';
2603
- } else {
2604
- if (_this__u8e3s4 instanceof Integer) {
2605
- var tmp_1;
2606
- switch (_this__u8e3s4.ku_1.f3_1) {
2607
- case 0:
2608
- tmp_1 = 'i32';
2609
- break;
2610
- case 1:
2611
- tmp_1 = 'i64';
2612
- break;
2613
- default:
2614
- noWhenBranchMatchedException();
2615
- break;
2616
- }
2617
- tmp = tmp_1;
2618
- } else {
2619
- if (_this__u8e3s4 instanceof Number_0) {
2620
- var tmp_2;
2621
- switch (_this__u8e3s4.lu_1.f3_1) {
2622
- case 0:
2623
- tmp_2 = 'f32';
2624
- break;
2625
- case 1:
2626
- tmp_2 = 'f64';
2627
- break;
2628
- default:
2629
- noWhenBranchMatchedException();
2630
- break;
2631
- }
2632
- tmp = tmp_2;
2633
- } else {
2634
- if (_this__u8e3s4 instanceof IntegerLiteral) {
2635
- tmp = 'i32';
2636
- } else {
2637
- if (_this__u8e3s4 instanceof StringLiteral) {
2638
- tmp = 'String';
2639
- } else {
2640
- if (_this__u8e3s4 instanceof Function) {
2641
- tmp = 'Box<dyn Fn(' + joinToString(_this__u8e3s4.yu_1, ', ', VOID, VOID, VOID, VOID, RustTransform$rustName$lambda_0) + ') -> ' + this.a39(_this__u8e3s4.zu_1) + '>';
2642
- } else {
2643
- noWhenBranchMatchedException();
2644
- }
2645
- }
2646
- }
2647
- }
2648
- }
2649
- }
2650
- }
2651
- }
2652
- }
2653
- }
2654
- }
2655
- }
2656
- }
2657
- }
2658
- }
2659
- }
2660
- return tmp;
2661
- };
2662
- protoOf(RustTransform).f39 = function (_this__u8e3s4) {
2663
- var tmp;
2664
- if (_this__u8e3s4 instanceof Custom) {
2665
- // Inline function 'kotlin.let' call
2666
- var it = _this__u8e3s4.ru_1.du();
2667
- tmp = startsWith(it, '&') || startsWith(it, '&dyn ') || startsWith(it, '&impl ') || startsWith(it, '&mut ');
2668
- } else {
2669
- tmp = false;
2670
- }
2671
- return tmp;
2672
- };
2673
- protoOf(RustTransform).e39 = function (_this__u8e3s4) {
2674
- // Inline function 'kotlin.let' call
2675
- var it = _this__u8e3s4.ru_1.du();
2676
- return it === 'Serializer' || it === 'Deserializer';
2677
- };
2678
- protoOf(RustTransform).d39 = function (_this__u8e3s4) {
2679
- return _this__u8e3s4.ru_1.du() === 'GeneratorField';
2680
- };
2681
- protoOf(RustTransform).c39 = function (_this__u8e3s4) {
2682
- var v = _this__u8e3s4.bu();
2683
- switch (v) {
2684
- case 'self':
2685
- case '&self':
2686
- return true;
2687
- default:
2688
- return v === '&mut self';
2689
- }
2690
- };
2691
- var RustTransform_instance;
2692
- function RustTransform_getInstance() {
2693
- if (RustTransform_instance == null)
2694
- new RustTransform();
2695
- return RustTransform_instance;
2696
- }
2697
- function borrow(_this__u8e3s4) {
2698
- return _this__u8e3s4.uu(new Name(listOf('&' + _this__u8e3s4.ru_1.du())));
2699
- }
2700
- function borrowDyn(_this__u8e3s4) {
2701
- return _this__u8e3s4.uu(new Name(listOf('&dyn ' + _this__u8e3s4.ru_1.du())));
2702
- }
2703
- function borrowImpl(_this__u8e3s4) {
2704
- return _this__u8e3s4.uu(new Name(listOf('&impl ' + _this__u8e3s4.ru_1.du())));
2705
- }
2706
- function ownedImpl(_this__u8e3s4) {
2707
- return _this__u8e3s4.uu(new Name(listOf('impl ' + _this__u8e3s4.ru_1.du())));
2708
- }
2709
2094
  //region block: post-declaration
2710
2095
  protoOf(RustEmitter).i1b = get_extensions;
2711
2096
  protoOf(RustEmitter).uo = emit_1;