| ... | ... | @@ -265,16 +265,7 @@ pub const Type = struct { |
| 265 | 265 | |
| 266 | 266 | pub const Generic = struct { |
| 267 | 267 | param_count: usize, |
| 268 | | cc: CC, |
| 269 | | |
| 270 | | pub const CC = union(CallingConvention) { |
| 271 | | Auto, |
| 272 | | C, |
| 273 | | Cold, |
| 274 | | Naked, |
| 275 | | Stdcall, |
| 276 | | Async: *Type, // allocator type |
| 277 | | }; |
| 268 | cc: CallingConvention, |
| 278 | 269 | }; |
| 279 | 270 | |
| 280 | 271 | pub fn hash(self: *const Key) u32 { |
| ... | ... | @@ -283,10 +274,7 @@ pub const Type = struct { |
| 283 | 274 | switch (self.data) { |
| 284 | 275 | Kind.Generic => |generic| { |
| 285 | 276 | result +%= hashAny(generic.param_count, 1); |
| 286 | | switch (generic.cc) { |
| 287 | | CallingConvention.Async => |allocator_type| result +%= hashAny(allocator_type, 2), |
| 288 | | else => result +%= hashAny(CallingConvention(generic.cc), 3), |
| 289 | | } |
| 277 | result +%= hashAny(generic.cc, 3); |
| 290 | 278 | }, |
| 291 | 279 | Kind.Normal => |normal| { |
| 292 | 280 | result +%= hashAny(normal.return_type, 4); |
| ... | ... | @@ -311,14 +299,7 @@ pub const Type = struct { |
| 311 | 299 | Kind.Generic => |*self_generic| { |
| 312 | 300 | const other_generic = &other.data.Generic; |
| 313 | 301 | if (self_generic.param_count != other_generic.param_count) return false; |
| 314 | | if (CallingConvention(self_generic.cc) != CallingConvention(other_generic.cc)) return false; |
| 315 | | switch (self_generic.cc) { |
| 316 | | CallingConvention.Async => |self_allocator_type| { |
| 317 | | const other_allocator_type = other_generic.cc.Async; |
| 318 | | if (self_allocator_type != other_allocator_type) return false; |
| 319 | | }, |
| 320 | | else => {}, |
| 321 | | } |
| 302 | if (self_generic.cc != other_generic.cc) return false; |
| 322 | 303 | }, |
| 323 | 304 | Kind.Normal => |*self_normal| { |
| 324 | 305 | const other_normal = &other.data.Normal; |
| ... | ... | @@ -337,12 +318,7 @@ pub const Type = struct { |
| 337 | 318 | |
| 338 | 319 | pub fn deref(key: Key, comp: *Compilation) void { |
| 339 | 320 | switch (key.data) { |
| 340 | | Kind.Generic => |generic| { |
| 341 | | switch (generic.cc) { |
| 342 | | CallingConvention.Async => |allocator_type| allocator_type.base.deref(comp), |
| 343 | | else => {}, |
| 344 | | } |
| 345 | | }, |
| 321 | Kind.Generic => {}, |
| 346 | 322 | Kind.Normal => |normal| { |
| 347 | 323 | normal.return_type.base.deref(comp); |
| 348 | 324 | for (normal.params) |param| { |
| ... | ... | @@ -354,12 +330,7 @@ pub const Type = struct { |
| 354 | 330 | |
| 355 | 331 | pub fn ref(key: Key) void { |
| 356 | 332 | switch (key.data) { |
| 357 | | Kind.Generic => |generic| { |
| 358 | | switch (generic.cc) { |
| 359 | | CallingConvention.Async => |allocator_type| allocator_type.base.ref(), |
| 360 | | else => {}, |
| 361 | | } |
| 362 | | }, |
| 333 | Kind.Generic => {}, |
| 363 | 334 | Kind.Normal => |normal| { |
| 364 | 335 | normal.return_type.base.ref(); |
| 365 | 336 | for (normal.params) |param| { |
| ... | ... | @@ -370,14 +341,7 @@ pub const Type = struct { |
| 370 | 341 | } |
| 371 | 342 | }; |
| 372 | 343 | |
| 373 | | pub const CallingConvention = enum { |
| 374 | | Auto, |
| 375 | | C, |
| 376 | | Cold, |
| 377 | | Naked, |
| 378 | | Stdcall, |
| 379 | | Async, |
| 380 | | }; |
| 344 | const CallingConvention = builtin.CallingConvention; |
| 381 | 345 | |
| 382 | 346 | pub const Param = struct { |
| 383 | 347 | is_noalias: bool, |
| ... | ... | @@ -386,12 +350,12 @@ pub const Type = struct { |
| 386 | 350 | |
| 387 | 351 | fn ccFnTypeStr(cc: CallingConvention) []const u8 { |
| 388 | 352 | return switch (cc) { |
| 389 | | CallingConvention.Auto => "", |
| 390 | | CallingConvention.C => "extern ", |
| 391 | | CallingConvention.Cold => "coldcc ", |
| 392 | | CallingConvention.Naked => "nakedcc ", |
| 393 | | CallingConvention.Stdcall => "stdcallcc ", |
| 394 | | CallingConvention.Async => unreachable, |
| 353 | .Auto => "", |
| 354 | .C => "extern ", |
| 355 | .Cold => "coldcc ", |
| 356 | .Naked => "nakedcc ", |
| 357 | .Stdcall => "stdcallcc ", |
| 358 | .Async => "async ", |
| 395 | 359 | }; |
| 396 | 360 | } |
| 397 | 361 | |