Commit Graph

31 Commits

Author SHA1 Message Date
Konrad `ktoso` Malawski
5faf82c553 Improve usability of _mangledTypeName with Any.Type arguments 2020-04-05 12:27:50 +09:00
Konrad `ktoso` Malawski
33444489e5 Add _mangledTypeName to allow round trips T->mangledName->T 2020-03-10 12:20:08 +09:00
fischertony
f14604e225 Demangle: Test demangling of nested types with contextual where clauses 2020-03-05 07:29:28 +03:00
Doug Gregor
a53b2e285c [Standard library] Drop _typeByMangledName().
This underscored function was only intended for testing; drop it from the
ABI. We’re keeping _typeByName because it’s used by Foundation.
2018-11-15 11:06:52 -08:00
Doug Gregor
e87dea480c [IRGen] Make (most) builtin type metadata round-trippable.
Rather than mapping all of the builtin floating-point and vector
types down to the type metadata symbols for power-of-two integers,
map down to the type metadata symbols provided by the runtime.
This allows us to round-trip type metadata <-> mangled name for all of
the builtin types that have such symbols. When we don’t have a runtime
symbol, we will fail to link if that builtin type gets referenced.
2018-10-26 16:09:21 -07:00
Doug Gregor
65d5d15fc1 [Runtime] Extend known builtin metadata for floating point and vector types.
Expose symbols for metadata for the various builtin floating point types
and vector types. This is used by the demangler to handle builtin names.

This is a narrow fix for rdar://problem/45569984 (where we couldn’t
demangle a builtin vector type). A more extensive fix will require us
to add a general runtime facility for creating opaque type metadata
with specific size/alignment/stride/uniquing name.
2018-10-26 16:05:31 -07:00
Doug Gregor
7d88a7d335 [Runtime] Demangle @autoclosure function types to metadata.
@autoclosure is currently represented in mangled names, but the
demangle-to-metadata path did not handle it. Add basic support for it
so we can round-trip.
2018-10-18 21:53:48 -07:00
Doug Gregor
cf2a47e14c [Runtime] Handle non-key generic parameters when demangling to metadata.
When forming metadata for a nested generic type, gather all of the
generic arguments from the parent type “as written”, so that we can directly
map generic parameters to those generic arguments when they occur within
requirements. This allows us to demangle nested types within extensions
that have same-type constraints on generic parameters into type metadata.

Fixes rdar://problem/37170296.
2018-09-26 14:41:04 -07:00
Arnold Schwaighofer
db0597ec68 Codesign test/Runtime 2018-08-13 07:45:16 -07:00
Joe Groff
0d438c91c4 [Demangle to metadata] Support simple extension contexts.
Support demangling for types nested within some simple extension contexts.
Still does not support nested types within constrained extensions that
involve same-type constraints among generic parameters, nor
deeply-nested types in extensions. However, it fixes
rdar://problem/40071688.
2018-05-10 23:36:01 -07:00
Huon Wilson
e7002b6413 [AST] ParenType needs enough bits to store ValueOwnership::Owned.
The truncation here meant func foo(_: __owned X) {} was the same as
foo(_: X), so @guaranteed when that's the default.

Fixes rdar://problem/38390524.
2018-03-13 10:18:40 +11:00
Doug Gregor
90afecfda8 [Runtime] Dynamically evaluate superclass constraints. 2018-02-01 17:35:47 -08:00
Doug Gregor
9445839208 [Runtime] Evaluate layout constraints at runtime. 2018-02-01 17:20:44 -08:00
Doug Gregor
5c59e81480 [Runtime] Evaluate same-type requirements at runtime.
Extend the runtime's ability for evaluating generic requirements to
handle same-type requirements, demangling/substituting the name from
the generic requirement metadata.
2018-02-01 17:00:51 -08:00
Doug Gregor
f8c769c4ae [Demangle-to-type] Handle type arguments and requirements for nested generics.
Extend the support for mangled-name-to-type-metadata's handling of generic
types to handle nested types, including gathering type arguments from
parent contents and checking generic requirements.
2018-02-01 14:45:13 -08:00
Pavel Yaskevich
86916cf4d8 [Mangled name -> metadata] Add built-in types support 2018-01-24 00:29:24 -08:00
Doug Gregor
59c98e6ecf [Mangled name -> type metadata] Support arbitrary # of generic args.
Now that we have a suitable calling convention for the access function
of a generic nominal type descriptor with > 3 arguments, add support
for calling with an arbitrary number of generic arguments.
2018-01-13 22:34:51 -08:00
Doug Gregor
a2d97719d3 [Runtime] Support nested generic types in mangled name -> type metadata. 2018-01-12 15:35:12 -08:00
Doug Gregor
0b62e4000f [Mangled name -> type] Support simple generic types up to 3 arguments.
Support demangling bound generic types (e.g., Array<Int>) and forming
type metadata for them. For now, only support non-nested generic types
with up to three generic parameters.
2018-01-12 15:35:12 -08:00
Doug Gregor
3405852ef0 [Runtime] Find metadata for substitutions into demangled dependent members.
Extend the protocol descriptor with a (space-separated) list of associated
type names, in the order of their requirements. Use this information in
the runtime to support lookup of associated type witnesses by name when
mapping a mangled name to a type and substituting generic parameters.
2018-01-11 16:04:53 -08:00
Doug Gregor
cd1bd20fce [Runtime mangling -> meadata] Support type parameter substitutions.
Extend _typeByMangledName with support for user-provided type parameter
substitutions, where type parameters that occur in the mangling can be
replaced with specific types.
2018-01-11 11:08:57 -08:00
Doug Gregor
2c86f918de [Runtime] Add tests for demanling never-before-seen types to metadata.
This helps ensure that we're uniquing metadata properly when given
non-constant inputs, for existential types and function types.
2018-01-10 23:12:09 -08:00
Doug Gregor
a08653496f [Runtime demangling] Add test for AnyObject composition case 2018-01-09 22:20:03 -08:00
Doug Gregor
a7fef62a44 [Runtime] Search through protocols to resolve protocol declarations.
Search through the new section containing Swift protocol descriptor
references to resolve protocols by mangled name. Use this
functionality to support protocol composition types within
_typeForMangledName.
2018-01-09 20:17:44 -08:00
Doug Gregor
c9b7ec935f [Runtime] Round up tuple labels allocation size to alignment of a pointer.
The metadata allocation functions assume this alignment, and we
weren't guaranteeing it.
2018-01-08 13:12:25 -08:00
Doug Gregor
909e882110 [Runtime] Support "ModuleName.ClassName" syntax for mangled type lookup. 2018-01-06 23:56:51 -08:00
Doug Gregor
78e8ad87be [Runtime] Find (simple) nominal types based on a mangled name. 2018-01-06 23:30:31 -08:00
Doug Gregor
04a151d8a0 [Runtime] Form existential types and existential types based on mangled names.
Introduce basic support for existential types (just Any and AnyObject), so
we can test those, shared/owned parameters, and existential metatypes.
2018-01-05 16:56:56 -08:00
Doug Gregor
33f89a1344 [Runtime] Form metatypes based on mangled names. 2018-01-05 16:34:55 -08:00
Doug Gregor
83fd37a2d0 [Runtime] Form function types based on mangled names.
Fixes some issues in the type decoder with function flags not getting
set when forming function types.
2018-01-05 16:23:49 -08:00
Doug Gregor
7148e84099 [Runtime] Stub out the implementation of _typeByMangledName().
Introduce a standard library/runtime entry point that produces type metadata
given a mangled name, based on the TypeDecoder logic lifted from the remote
mirrors library.

Implement support for tuple types as a proof-of-concept.
2018-01-05 15:42:45 -08:00