mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Revert "Rename @transparent to @_transparent for now."
This reverts commit 90fcbfe9a6.
Seems there are still some tests that are left not modified.
This commit is contained in:
@@ -98,7 +98,7 @@ Modules can also contain `autolinking` information, which the compiler passes
|
||||
on to the linker. This can be used to specify which library implements the
|
||||
declarations in the module.
|
||||
|
||||
.. [#] Specifically, code marked with the ``@_transparent`` attribute is
|
||||
.. [#] Specifically, code marked with the ``[transparent]`` attribute is
|
||||
required to be "transparent" to the compiler: it *must* be inlined and
|
||||
will affect diagnostics.
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ organizational purposes.
|
||||
- The **SIL block** contains SIL-level implementations that can be imported
|
||||
into a client's SILModule context. In most cases this is just a performance
|
||||
concern, but sometimes it affects language semantics as well, as in the case
|
||||
of ``@_transparent``. The SIL block precedes the AST block because it affects
|
||||
of ``@transparent``. The SIL block precedes the AST block because it affects
|
||||
which AST nodes get serialized.
|
||||
|
||||
- The **SIL index black** contains tables for accessing various SIL entities by
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
:orphan:
|
||||
|
||||
``@_transparent``
|
||||
=================
|
||||
``@transparent``
|
||||
================
|
||||
|
||||
Semantically, ``@_transparent`` means something like "treat this operation as
|
||||
if it were a primitive operation". The name is meant to imply that both the
|
||||
Semantically, ``@transparent`` means something like "treat this operation as if
|
||||
it were a primitive operation". The name is meant to imply that both the
|
||||
compiler and the compiled program will "see through" the operation to its
|
||||
implementation.
|
||||
|
||||
This has several consequences:
|
||||
|
||||
- Any calls to a function marked ``@_transparent`` MUST be inlined prior to
|
||||
- Any calls to a function marked ``@transparent`` MUST be inlined prior to
|
||||
doing dataflow-related diagnostics, even under ``-Onone``. This may be
|
||||
necessary to *catch* dataflow errors.
|
||||
|
||||
- Because of this, a ``@_transparent`` function is inherently "fragile", in
|
||||
that changing its implementation most likely will not affect callers in
|
||||
existing compiled binaries.
|
||||
- Because of this, a ``@transparent`` function is inherently "fragile", in that
|
||||
changing its implementation most likely will not affect callers in existing
|
||||
compiled binaries.
|
||||
|
||||
- Because of this, a ``@_transparent`` function MUST only reference public
|
||||
- Because of this, a ``@transparent`` function MUST only reference public
|
||||
symbols, and MUST not be optimized based on knowledge of the module it's in.
|
||||
[This is not currently implemented or enforced.]
|
||||
|
||||
- Debug info SHOULD skip over the inlined operations when single-stepping
|
||||
through the calling function.
|
||||
|
||||
This is all that ``@_transparent`` means.
|
||||
This is all that ``@transparent`` means.
|
||||
|
||||
|
||||
When should you use ``@_transparent``?
|
||||
--------------------------------------
|
||||
When should you use ``@transparent``?
|
||||
-------------------------------------
|
||||
|
||||
- Does the implementation of this function ever have to change? Then you can't
|
||||
allow it to be inlined.
|
||||
@@ -42,19 +42,19 @@ When should you use ``@_transparent``?
|
||||
|
||||
- Is it okay if the function is *not* inlined? You'd just prefer that it were?
|
||||
Then you should use [the attribute we haven't designed yet], rather than
|
||||
``@_transparent``. (If you really need this right now, try
|
||||
``@transparent``. (If you really need this right now, try
|
||||
``@inline(__always)``.)
|
||||
|
||||
- Is it a problem if the function is inlined even under ``-Onone``? Then you're
|
||||
really in the previous case. Trust the compiler.
|
||||
|
||||
- Is it a problem if you can't step through the function that's been inlined?
|
||||
Then you don't want ``@_transparent``; you just want ``@inline(__always)``.
|
||||
Then you don't want ``@transparent``; you just want ``@inline(__always)``.
|
||||
|
||||
- Is it okay if the inlining happens after all the dataflow diagnostics? Then
|
||||
you don't want ``@_transparent``; you just want ``@inline(__always)``.
|
||||
you don't want ``@transparent``; you just want ``@inline(__always)``.
|
||||
|
||||
If you made it this far, it sounds like ``@_transparent`` is the right choice.
|
||||
If you made it this far, it sounds like ``@transparent`` is the right choice.
|
||||
|
||||
|
||||
Current implementation limitations
|
||||
@@ -79,5 +79,5 @@ Current implementation limitations
|
||||
|
||||
- Similarly, when compiling in non-single-frontend mode, no SIL is generated for
|
||||
any functions but those in the primary file (for each frontend invocation),
|
||||
including ``@inline(__always)`` and ``@_transparent`` functions. This is
|
||||
including ``@inline(__always)`` and ``@transparent`` functions. This is
|
||||
semantically a bug. rdar://problem/15366167
|
||||
|
||||
@@ -259,7 +259,7 @@ An example of a conformance for ``CMutablePointer``::
|
||||
|
||||
typealias InOutType = T
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
static func _convertFromInOutAddress(p: Builtin.RawPointer)
|
||||
-> CMutablePointer {
|
||||
return CMutablePointer(p)
|
||||
@@ -315,7 +315,7 @@ An example of a conformance for ``ObjCInOut``::
|
||||
typealias InOutType = T!
|
||||
typealias WritebackType = Builtin.RawPointer
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
static func _createWriteback(inout ref: T!)
|
||||
-> Builtin.RawPointer {
|
||||
// The initial object reference is passed into the callee effectively
|
||||
@@ -323,7 +323,7 @@ An example of a conformance for ``ObjCInOut``::
|
||||
return unsafeBitCast(ref, Builtin.RawPointer.self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
static func _commitWriteback(inout ref: T!,
|
||||
value: Builtin.RawPointer) {
|
||||
// The reference is autoreleased on return from the caller, so retain it
|
||||
@@ -331,7 +331,7 @@ An example of a conformance for ``ObjCInOut``::
|
||||
ref = unsafeBitCast(value, T!.self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
static func _convertFromWritebackAddress(value: Builtin.RawPointer) {
|
||||
return ObjCInOut(value)
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ SIMPLE_DECL_ATTR(infix , Infix , OnFunc | OnOperator | DeclModifier, 23)
|
||||
SIMPLE_DECL_ATTR(prefix , Prefix , OnFunc | OnOperator | DeclModifier, 24)
|
||||
SIMPLE_DECL_ATTR(postfix, Postfix, OnFunc | OnOperator | DeclModifier, 25)
|
||||
|
||||
SIMPLE_DECL_ATTR(_transparent, Transparent,
|
||||
SIMPLE_DECL_ATTR(transparent, Transparent,
|
||||
OnFunc|OnConstructor|OnVar|OnExtension|UserInaccessible, 26)
|
||||
SIMPLE_DECL_ATTR(requires_stored_property_inits, RequiresStoredPropertyInits,
|
||||
OnClass, 27)
|
||||
|
||||
@@ -688,13 +688,13 @@ ERROR(static_functions_not_mutating,sema_tcd,none,
|
||||
"static functions may not be declared mutating", ())
|
||||
|
||||
ERROR(transparent_stored_property,sema_tcd,none,
|
||||
"@_transparent cannot be applied to stored properties", ())
|
||||
"@transparent cannot be applied to stored properties", ())
|
||||
ERROR(transparent_on_invalid_extension,sema_tcd,none,
|
||||
"@_transparent is only supported on struct and enum extensions", ())
|
||||
"@transparent is only supported on struct and enum extensions", ())
|
||||
ERROR(transparent_in_protocols_not_supported,sema_tcd,none,
|
||||
"@_transparent is not supported on declarations within protocols", ())
|
||||
"@transparent is not supported on declarations within protocols", ())
|
||||
ERROR(transparent_in_classes_not_supported,sema_tcd,none,
|
||||
"@_transparent is not supported on declarations within classes", ())
|
||||
"@transparent is not supported on declarations within classes", ())
|
||||
|
||||
ERROR(invalid_iboutlet,sema_tcd,none,
|
||||
"only instance properties can be declared @IBOutlet", ())
|
||||
|
||||
@@ -33,15 +33,15 @@ public struct CGFloat {
|
||||
public typealias NativeType = Double
|
||||
#endif
|
||||
|
||||
@_transparent public init() {
|
||||
@transparent public init() {
|
||||
self.native = 0.0
|
||||
}
|
||||
|
||||
@_transparent public init(_ value: Float) {
|
||||
@transparent public init(_ value: Float) {
|
||||
self.native = NativeType(value)
|
||||
}
|
||||
|
||||
@_transparent public init(_ value: Double) {
|
||||
@transparent public init(_ value: Double) {
|
||||
self.native = NativeType(value)
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public struct CGFloat {
|
||||
public var native: NativeType
|
||||
}
|
||||
|
||||
@_transparent extension CGFloat : FloatingPointType {
|
||||
@transparent extension CGFloat : FloatingPointType {
|
||||
public typealias _BitsType = UInt
|
||||
|
||||
public static func _fromBitPattern(bits: UInt) -> CGFloat {
|
||||
@@ -62,7 +62,7 @@ public struct CGFloat {
|
||||
|
||||
% for src_ty in all_integer_types(word_bits):
|
||||
|
||||
@_transparent public init(_ value: ${src_ty.stdlib_name}) {
|
||||
@transparent public init(_ value: ${src_ty.stdlib_name}) {
|
||||
self.native = NativeType(value)
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public struct CGFloat {
|
||||
}
|
||||
|
||||
extension CGFloat {
|
||||
@_transparent public static var min: CGFloat {
|
||||
@transparent public static var min: CGFloat {
|
||||
#if arch(i386) || arch(arm)
|
||||
return CGFloat(FLT_MIN)
|
||||
#else
|
||||
@@ -126,7 +126,7 @@ extension CGFloat {
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent public static var max: CGFloat {
|
||||
@transparent public static var max: CGFloat {
|
||||
#if arch(i386) || arch(arm)
|
||||
return CGFloat(FLT_MAX)
|
||||
#else
|
||||
@@ -152,14 +152,14 @@ extension CGFloat : _Reflectable {
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent extension CGFloat : CustomStringConvertible {
|
||||
@transparent extension CGFloat : CustomStringConvertible {
|
||||
/// A textual representation of `self`.
|
||||
public var description: String {
|
||||
return native.description
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent extension CGFloat : Hashable {
|
||||
@transparent extension CGFloat : Hashable {
|
||||
/// The hash value.
|
||||
///
|
||||
/// **Axiom:** `x == y` implies `x.hashValue == y.hashValue`
|
||||
@@ -172,23 +172,23 @@ extension CGFloat : _Reflectable {
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent extension CGFloat : FloatLiteralConvertible {
|
||||
@transparent extension CGFloat : FloatLiteralConvertible {
|
||||
/// Create an instance initialized to `value`.
|
||||
public init(floatLiteral value: NativeType) {
|
||||
self = CGFloat(value)
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent extension CGFloat : IntegerLiteralConvertible {
|
||||
@transparent extension CGFloat : IntegerLiteralConvertible {
|
||||
/// Create an instance initialized to `value`.
|
||||
public init(integerLiteral value: Int) {
|
||||
self = CGFloat(value)
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent extension CGFloat : AbsoluteValuable {
|
||||
@transparent extension CGFloat : AbsoluteValuable {
|
||||
/// Returns the absolute value of `x`
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public static func abs(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(NativeType.abs(x.native))
|
||||
@@ -197,7 +197,7 @@ extension CGFloat : _Reflectable {
|
||||
|
||||
% for dst_ty in all_integer_types(word_bits):
|
||||
|
||||
@_transparent extension ${dst_ty.stdlib_name} {
|
||||
@transparent extension ${dst_ty.stdlib_name} {
|
||||
public init(_ value: CGFloat) {
|
||||
self = ${dst_ty.stdlib_name}(value.native)
|
||||
}
|
||||
@@ -206,41 +206,41 @@ extension CGFloat : _Reflectable {
|
||||
% end
|
||||
|
||||
|
||||
@_transparent extension Double {
|
||||
@transparent extension Double {
|
||||
public init(_ value: CGFloat) {
|
||||
self = Double(value.native)
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent extension Float {
|
||||
@transparent extension Float {
|
||||
public init(_ value: CGFloat) {
|
||||
self = Float(value.native)
|
||||
}
|
||||
}
|
||||
|
||||
// Comparisons.
|
||||
@_transparent extension CGFloat : Equatable { }
|
||||
@transparent extension CGFloat : Equatable { }
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ==(lhs: CGFloat, rhs: CGFloat) -> Bool {
|
||||
return lhs.native == rhs.native
|
||||
}
|
||||
|
||||
@_transparent extension CGFloat : Comparable { }
|
||||
@transparent extension CGFloat : Comparable { }
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func <(lhs: CGFloat, rhs: CGFloat) -> Bool {
|
||||
return lhs.native < rhs.native
|
||||
}
|
||||
|
||||
@_transparent extension CGFloat : Strideable {
|
||||
@transparent extension CGFloat : Strideable {
|
||||
/// Returns a stride `x` such that `self.advancedBy(x)` approximates
|
||||
/// `other`.
|
||||
///
|
||||
/// - Complexity: O(1).
|
||||
@_transparent public
|
||||
@transparent public
|
||||
func distanceTo(other: CGFloat) -> CGFloat {
|
||||
return CGFloat(other.native - self.native)
|
||||
}
|
||||
@@ -249,41 +249,41 @@ public func <(lhs: CGFloat, rhs: CGFloat) -> Bool {
|
||||
/// `n`.
|
||||
///
|
||||
/// - Complexity: O(1).
|
||||
@_transparent public
|
||||
@transparent public
|
||||
func advancedBy(amount: CGFloat) -> CGFloat {
|
||||
return CGFloat(self.native + amount.native)
|
||||
}
|
||||
}
|
||||
|
||||
// CGFloat unary operators
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public prefix func + (x: CGFloat) -> CGFloat { return x }
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public prefix func - (x: CGFloat) -> CGFloat { return CGFloat(-x.native) }
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public prefix func ++ (inout x: CGFloat) -> CGFloat {
|
||||
x.native += 1.0
|
||||
return x
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public prefix func -- (inout x: CGFloat) -> CGFloat {
|
||||
x.native -= 1.0
|
||||
return x
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public postfix func ++ (inout x: CGFloat) -> CGFloat {
|
||||
let tmp = x
|
||||
x.native += 1.0
|
||||
return tmp
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public postfix func -- (inout x: CGFloat) -> CGFloat {
|
||||
let tmp = x
|
||||
x.native -= 1.0
|
||||
@@ -291,446 +291,446 @@ public postfix func -- (inout x: CGFloat) -> CGFloat {
|
||||
}
|
||||
|
||||
// CGFloat arithmetic
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func +(lhs: CGFloat, rhs: CGFloat) -> CGFloat {
|
||||
return CGFloat(lhs.native + rhs.native)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func -(lhs: CGFloat, rhs: CGFloat) -> CGFloat {
|
||||
return CGFloat(lhs.native - rhs.native)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func *(lhs: CGFloat, rhs: CGFloat) -> CGFloat {
|
||||
return CGFloat(lhs.native * rhs.native)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func /(lhs: CGFloat, rhs: CGFloat) -> CGFloat {
|
||||
return CGFloat(lhs.native / rhs.native)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func %(lhs: CGFloat, rhs: CGFloat) -> CGFloat {
|
||||
return CGFloat(lhs.native % rhs.native)
|
||||
}
|
||||
|
||||
// CGFloat assignment operators.
|
||||
@_transparent
|
||||
@transparent
|
||||
public func +=(inout lhs: CGFloat, rhs: CGFloat) {
|
||||
lhs.native = lhs.native + rhs.native
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func -=(inout lhs: CGFloat, rhs: CGFloat) {
|
||||
lhs.native = lhs.native - rhs.native
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func *=(inout lhs: CGFloat, rhs: CGFloat) {
|
||||
lhs.native = lhs.native * rhs.native
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func /=(inout lhs: CGFloat, rhs: CGFloat) {
|
||||
lhs.native = lhs.native / rhs.native
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func %=(inout lhs: CGFloat, rhs: CGFloat) {
|
||||
lhs.native = lhs.native % rhs.native
|
||||
}
|
||||
|
||||
// CGFloat tgmath.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func acos(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(acos(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func cos(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(cos(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func sin(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(sin(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func asin(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(asin(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func atan(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(atan(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func tan(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(tan(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func acosh(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(acosh(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func asinh(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(asinh(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func atanh(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(atanh(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func cosh(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(cosh(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func sinh(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(sinh(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func tanh(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(tanh(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func exp(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(exp(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func exp2(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(exp2(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func expm1(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(expm1(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func log(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(log(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func log10(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(log10(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func log2(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(log2(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func log1p(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(log1p(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func logb(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(logb(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func cbrt(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(cbrt(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func erf(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(erf(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func erfc(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(erfc(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func tgamma(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(tgamma(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func fabs(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(fabs(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func sqrt(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(sqrt(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ceil(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(ceil(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func floor(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(floor(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func nearbyint(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(nearbyint(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func rint(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(rint(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func round(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(round(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func trunc(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(trunc(x.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func atan2(lhs: CGFloat, _ rhs: CGFloat) -> CGFloat {
|
||||
return CGFloat(atan2(lhs.native, rhs.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func hypot(lhs: CGFloat, _ rhs: CGFloat) -> CGFloat {
|
||||
return CGFloat(hypot(lhs.native, rhs.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func pow(lhs: CGFloat, _ rhs: CGFloat) -> CGFloat {
|
||||
return CGFloat(pow(lhs.native, rhs.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func fmod(lhs: CGFloat, _ rhs: CGFloat) -> CGFloat {
|
||||
return CGFloat(fmod(lhs.native, rhs.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func remainder(lhs: CGFloat, _ rhs: CGFloat) -> CGFloat {
|
||||
return CGFloat(remainder(lhs.native, rhs.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func copysign(lhs: CGFloat, _ rhs: CGFloat) -> CGFloat {
|
||||
return CGFloat(copysign(lhs.native, rhs.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func nextafter(lhs: CGFloat, _ rhs: CGFloat) -> CGFloat {
|
||||
return CGFloat(nextafter(lhs.native, rhs.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func fdim(lhs: CGFloat, _ rhs: CGFloat) -> CGFloat {
|
||||
return CGFloat(fdim(lhs.native, rhs.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func fmax(lhs: CGFloat, _ rhs: CGFloat) -> CGFloat {
|
||||
return CGFloat(fmax(lhs.native, rhs.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func fmin(lhs: CGFloat, _ rhs: CGFloat) -> CGFloat {
|
||||
return CGFloat(fmin(lhs.native, rhs.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func fpclassify(x: CGFloat) -> Int {
|
||||
return fpclassify(x.native)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func isnormal(x: CGFloat) -> Bool {
|
||||
return isnormal(x.native)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func isfinite(x: CGFloat) -> Bool {
|
||||
return isfinite(x.native)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func isinf(x: CGFloat) -> Bool {
|
||||
return isinf(x.native)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func isnan(x: CGFloat) -> Bool {
|
||||
return isnan(x.native)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func signbit(x: CGFloat) -> Int {
|
||||
return signbit(x.native)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func modf(x: CGFloat) -> (CGFloat, CGFloat) {
|
||||
let (ipart, fpart) = modf(x.native)
|
||||
return (CGFloat(ipart), CGFloat(fpart))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ldexp(x: CGFloat, _ n: Int) -> CGFloat {
|
||||
return CGFloat(ldexp(x.native, n))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func frexp(x: CGFloat) -> (CGFloat, Int) {
|
||||
let (frac, exp) = frexp(x.native)
|
||||
return (CGFloat(frac), exp)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ilogb(x: CGFloat) -> Int {
|
||||
return ilogb(x.native)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func scalbn(x: CGFloat, _ n: Int) -> CGFloat {
|
||||
return CGFloat(scalbn(x.native, n))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func lgamma(x: CGFloat) -> (CGFloat, Int) {
|
||||
let (value, sign) = lgamma(x.native)
|
||||
return (CGFloat(value), sign)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func remquo(x: CGFloat, _ y: CGFloat) -> (CGFloat, Int) {
|
||||
let (rem, quo) = remquo(x.native, y.native)
|
||||
return (CGFloat(rem), quo)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func nan(tag: String) -> CGFloat {
|
||||
return CGFloat(nan(tag) as CGFloat.NativeType)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func fma(x: CGFloat, _ y: CGFloat, _ z: CGFloat) -> CGFloat {
|
||||
return CGFloat(fma(x.native, y.native, z.native))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func j0(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(j0(Double(x.native)))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func j1(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(j1(Double(x.native)))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func jn(n: Int, _ x: CGFloat) -> CGFloat {
|
||||
return CGFloat(jn(n, Double(x.native)))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func y0(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(y0(Double(x.native)))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func y1(x: CGFloat) -> CGFloat {
|
||||
return CGFloat(y1(Double(x.native)))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func yn(n: Int, _ x: CGFloat) -> CGFloat {
|
||||
return CGFloat(yn(n, Double(x.native)))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
extension CGFloat : _CVarArgPassedAsDouble, _CVarArgAlignedType {
|
||||
/// Transform `self` into a series of machine words that can be
|
||||
/// appropriately interpreted by C varargs
|
||||
|
||||
@@ -19,16 +19,16 @@ import Darwin
|
||||
|
||||
public extension CGPoint {
|
||||
static var zero: CGPoint {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGPoint(x: 0, y: 0) }
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
init(x: Int, y: Int) {
|
||||
self.init(x: CGFloat(x), y: CGFloat(y))
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
init(x: Double, y: Double) {
|
||||
self.init(x: CGFloat(x), y: CGFloat(y))
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public extension CGPoint {
|
||||
}
|
||||
|
||||
extension CGPoint : Equatable {}
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
@warn_unused_result
|
||||
public func == (lhs: CGPoint, rhs: CGPoint) -> Bool {
|
||||
return lhs.x == rhs.x && lhs.y == rhs.y
|
||||
@@ -48,16 +48,16 @@ public func == (lhs: CGPoint, rhs: CGPoint) -> Bool {
|
||||
|
||||
public extension CGSize {
|
||||
static var zero: CGSize {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGSize(width: 0, height: 0) }
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
init(width: Int, height: Int) {
|
||||
self.init(width: CGFloat(width), height: CGFloat(height))
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
init(width: Double, height: Double) {
|
||||
self.init(width: CGFloat(width), height: CGFloat(height))
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public extension CGSize {
|
||||
}
|
||||
|
||||
extension CGSize : Equatable {}
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
@warn_unused_result
|
||||
public func == (lhs: CGSize, rhs: CGSize) -> Bool {
|
||||
return lhs.width == rhs.width && lhs.height == rhs.height
|
||||
@@ -77,16 +77,16 @@ public func == (lhs: CGSize, rhs: CGSize) -> Bool {
|
||||
|
||||
public extension CGVector {
|
||||
static var zero: CGVector {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGVector(dx: 0, dy: 0) }
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
init(dx: Int, dy: Int) {
|
||||
self.init(dx: CGFloat(dx), dy: CGFloat(dy))
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
init(dx: Double, dy: Double) {
|
||||
self.init(dx: CGFloat(dx), dy: CGFloat(dy))
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public extension CGVector {
|
||||
}
|
||||
|
||||
extension CGVector : Equatable {}
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
@warn_unused_result
|
||||
public func == (lhs: CGVector, rhs: CGVector) -> Bool {
|
||||
return lhs.dx == rhs.dx && lhs.dy == rhs.dy
|
||||
@@ -107,146 +107,146 @@ public func == (lhs: CGVector, rhs: CGVector) -> Bool {
|
||||
|
||||
public extension CGRect {
|
||||
static var zero: CGRect {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRect(x: 0, y: 0, width: 0, height: 0) }
|
||||
}
|
||||
static var null: CGRect {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRectNull }
|
||||
}
|
||||
static var infinite: CGRect {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRectInfinite }
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
init(x: CGFloat, y: CGFloat, width: CGFloat, height: CGFloat) {
|
||||
self.init(origin: CGPoint(x: x, y: y),
|
||||
size: CGSize(width: width, height: height))
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
init(x: Double, y: Double, width: Double, height: Double) {
|
||||
self.init(origin: CGPoint(x: x, y: y),
|
||||
size: CGSize(width: width, height: height))
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
init(x: Int, y: Int, width: Int, height: Int) {
|
||||
self.init(origin: CGPoint(x: x, y: y),
|
||||
size: CGSize(width: width, height: height))
|
||||
}
|
||||
|
||||
var width: CGFloat {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRectGetWidth(self) }
|
||||
}
|
||||
var height: CGFloat {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRectGetHeight(self) }
|
||||
}
|
||||
|
||||
var minX: CGFloat {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRectGetMinX(self) }
|
||||
}
|
||||
var midX: CGFloat {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRectGetMidX(self) }
|
||||
}
|
||||
var maxX: CGFloat {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRectGetMaxX(self) }
|
||||
}
|
||||
var minY: CGFloat {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRectGetMinY(self) }
|
||||
}
|
||||
var midY: CGFloat {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRectGetMidY(self) }
|
||||
}
|
||||
var maxY: CGFloat {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRectGetMaxY(self) }
|
||||
}
|
||||
var isNull: Bool {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRectIsNull(self) }
|
||||
}
|
||||
var isEmpty: Bool {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRectIsEmpty(self) }
|
||||
}
|
||||
var isInfinite: Bool {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRectIsInfinite(self) }
|
||||
}
|
||||
var standardized: CGRect {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRectStandardize(self) }
|
||||
}
|
||||
|
||||
var integral: CGRect {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRectIntegral(self) }
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
mutating func standardizeInPlace() {
|
||||
self = standardized
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
mutating func makeIntegralInPlace() {
|
||||
self = integral
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
@warn_unused_result(mutable_variant="insetInPlace")
|
||||
func insetBy(dx dx: CGFloat, dy: CGFloat) -> CGRect {
|
||||
return CGRectInset(self, dx, dy)
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
mutating func insetInPlace(dx dx: CGFloat, dy: CGFloat) {
|
||||
self = insetBy(dx: dx, dy: dy)
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
@warn_unused_result(mutable_variant="offsetInPlace")
|
||||
func offsetBy(dx dx: CGFloat, dy: CGFloat) -> CGRect {
|
||||
return CGRectOffset(self, dx, dy)
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
mutating func offsetInPlace(dx dx: CGFloat, dy: CGFloat) {
|
||||
self = offsetBy(dx: dx, dy: dy)
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
@warn_unused_result(mutable_variant="unionInPlace")
|
||||
func union(rect: CGRect) -> CGRect {
|
||||
return CGRectUnion(self, rect)
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
mutating func unionInPlace(rect: CGRect) {
|
||||
self = union(rect)
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
@warn_unused_result(mutable_variant="intersectInPlace")
|
||||
func intersect(rect: CGRect) -> CGRect {
|
||||
return CGRectIntersection(self, rect)
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
mutating func intersectInPlace(rect: CGRect) {
|
||||
self = intersect(rect)
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
@warn_unused_result
|
||||
func divide(atDistance: CGFloat, fromEdge: CGRectEdge)
|
||||
-> (slice: CGRect, remainder: CGRect)
|
||||
@@ -257,19 +257,19 @@ public extension CGRect {
|
||||
return (slice, remainder)
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
@warn_unused_result
|
||||
func contains(rect: CGRect) -> Bool {
|
||||
return CGRectContainsRect(self, rect)
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
@warn_unused_result
|
||||
func contains(point: CGPoint) -> Bool {
|
||||
return CGRectContainsPoint(self, point)
|
||||
}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
@warn_unused_result
|
||||
func intersects(rect: CGRect) -> Bool {
|
||||
return CGRectIntersectsRect(self, rect)
|
||||
@@ -358,7 +358,7 @@ public extension CGRect {
|
||||
}
|
||||
|
||||
extension CGRect : Equatable {}
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
@warn_unused_result
|
||||
public func == (lhs: CGRect, rhs: CGRect) -> Bool {
|
||||
return CGRectEqualToRect(lhs, rhs)
|
||||
@@ -368,21 +368,21 @@ public func == (lhs: CGRect, rhs: CGRect) -> Bool {
|
||||
// C constants are opaque extern globals for no good reason.
|
||||
|
||||
public var CGPointZero: CGPoint {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGPoint.zero }
|
||||
}
|
||||
|
||||
public var CGRectZero: CGRect {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGRect.zero }
|
||||
}
|
||||
|
||||
public var CGSizeZero: CGSize {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGSize.zero }
|
||||
}
|
||||
|
||||
public var CGAffineTransformIdentity: CGAffineTransform {
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
get { return CGAffineTransform(a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0) }
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public struct DarwinBoolean : BooleanType, BooleanLiteralConvertible {
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(booleanLiteral value: Bool) {
|
||||
self.init(value)
|
||||
}
|
||||
@@ -73,10 +73,10 @@ func _convertDarwinBooleanToBool(x: DarwinBoolean) -> Bool {
|
||||
return Bool(x)
|
||||
}
|
||||
|
||||
// FIXME: We can't make the fully-generic versions @_transparent due to
|
||||
// rdar://problem/19418937, so here are some @_transparent overloads
|
||||
// FIXME: We can't make the fully-generic versions @transparent due to
|
||||
// rdar://problem/19418937, so here are some @transparent overloads
|
||||
// for DarwinBoolean.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func && <T : BooleanType>(
|
||||
lhs: T, @autoclosure rhs: () -> DarwinBoolean
|
||||
@@ -84,7 +84,7 @@ public func && <T : BooleanType>(
|
||||
return lhs.boolValue ? rhs().boolValue : false
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func || <T : BooleanType>(
|
||||
lhs: T, @autoclosure rhs: () -> DarwinBoolean
|
||||
|
||||
@@ -113,7 +113,7 @@ def TypedBinaryFunctions():
|
||||
// Unary functions
|
||||
// Note these do not have a corresponding LLVM intrinsic
|
||||
% for T, CT, f, ufunc in TypedUnaryFunctions():
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ${ufunc}(x: ${T}) -> ${T} {
|
||||
return ${T}(${ufunc}${f}(${CT}(x)))
|
||||
@@ -124,7 +124,7 @@ public func ${ufunc}(x: ${T}) -> ${T} {
|
||||
// Unary intrinsic functions
|
||||
// Note these have a corresponding LLVM intrinsic
|
||||
% for T, ufunc in TypedUnaryIntrinsicFunctions():
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ${ufunc}(x: ${T}) -> ${T} {
|
||||
return _${ufunc}(x)
|
||||
@@ -135,7 +135,7 @@ public func ${ufunc}(x: ${T}) -> ${T} {
|
||||
// Binary functions
|
||||
|
||||
% for T, CT, f, bfunc in TypedBinaryFunctions():
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ${bfunc}(lhs: ${T}, _ rhs: ${T}) -> ${T} {
|
||||
return ${T}(${bfunc}${f}(${CT}(lhs), ${CT}(rhs)))
|
||||
@@ -150,7 +150,7 @@ public func ${bfunc}(lhs: ${T}, _ rhs: ${T}) -> ${T} {
|
||||
% if f == '':
|
||||
% f = 'd'
|
||||
% end
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func fpclassify(x: ${T}) -> Int {
|
||||
return Int(__fpclassify${f}(${CT}(x)))
|
||||
@@ -161,31 +161,31 @@ public func fpclassify(x: ${T}) -> Int {
|
||||
% # These are AllFloatTypes not OverlayFloatTypes because we need to cover
|
||||
% # them all because C's declarations are compiler builtins.
|
||||
% for T, CT, f in AllFloatTypes():
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func isnormal(value: ${T}) -> Bool {
|
||||
return value.isNormal
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func isfinite(value: ${T}) -> Bool {
|
||||
return value.isFinite
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func isinf(value: ${T}) -> Bool {
|
||||
return value.isInfinite
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func isnan(value: ${T}) -> Bool {
|
||||
return value.isNaN
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func signbit(value: ${T}) -> Int {
|
||||
return value.isSignMinus ? 1 : 0
|
||||
@@ -195,7 +195,7 @@ public func signbit(value: ${T}) -> Int {
|
||||
|
||||
% # These are AllFloatTypes not OverlayFloatTypes because of the tuple return.
|
||||
% for T, CT, f in AllFloatTypes():
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func modf(value: ${T}) -> (${T}, ${T}) {
|
||||
var ipart = ${CT}(0)
|
||||
@@ -207,7 +207,7 @@ public func modf(value: ${T}) -> (${T}, ${T}) {
|
||||
|
||||
% # This is AllFloatTypes not OverlayFloatTypes because of the Int parameter.
|
||||
% for T, CT, f in AllFloatTypes():
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ldexp(x: ${T}, _ n: Int) -> ${T} {
|
||||
return ${T}(ldexp${f}(${CT}(x), CInt(n)))
|
||||
@@ -217,7 +217,7 @@ public func ldexp(x: ${T}, _ n: Int) -> ${T} {
|
||||
|
||||
% # This is AllFloatTypes not OverlayFloatTypes because of the tuple return.
|
||||
% for T, CT, f in AllFloatTypes():
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func frexp(value: ${T}) -> (${T}, Int) {
|
||||
var exp = CInt(0)
|
||||
@@ -230,7 +230,7 @@ public func frexp(value: ${T}) -> (${T}, Int) {
|
||||
% # This would be AllFloatTypes not OverlayFloatTypes because of the Int return.
|
||||
% # ... except we need an asmname to avoid an overload ambiguity.
|
||||
% for T, CT, f in OverlayFloatTypes():
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ilogb(x: ${T}) -> Int {
|
||||
return Int(ilogb${f}(${CT}(x)))
|
||||
@@ -242,7 +242,7 @@ public func ilogb(x: ${T}) -> Int {
|
||||
@asmname("ilogb")
|
||||
func _swift_Darwin_ilogb(value: CDouble) -> CInt
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ilogb(x: Double) -> Int {
|
||||
return Int(_swift_Darwin_ilogb(CDouble(x)))
|
||||
@@ -251,7 +251,7 @@ public func ilogb(x: Double) -> Int {
|
||||
|
||||
% # This is AllFloatTypes not OverlayFloatTypes because of the Int parameter.
|
||||
% for T, CT, f in AllFloatTypes():
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func scalbn(x: ${T}, _ n: Int) -> ${T} {
|
||||
return ${T}(scalbn${f}(${CT}(x), CInt(n)))
|
||||
@@ -266,7 +266,7 @@ public func scalbn(x: ${T}, _ n: Int) -> ${T} {
|
||||
@asmname("lgamma${f}_r")
|
||||
func _swift_Darwin_lgamma${f}_r(_: ${CT},
|
||||
_: UnsafeMutablePointer<CInt>) -> ${CT}
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func lgamma(x: ${T}) -> (${T}, Int) {
|
||||
var sign = CInt(0)
|
||||
@@ -281,7 +281,7 @@ public func lgamma(x: ${T}) -> (${T}, Int) {
|
||||
|
||||
% # This is AllFloatTypes not OverlayFloatTypes because of the tuple return.
|
||||
% for T, CT, f in AllFloatTypes():
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func remquo(x: ${T}, _ y: ${T}) -> (${T}, Int) {
|
||||
var quo = CInt(0)
|
||||
@@ -292,7 +292,7 @@ public func remquo(x: ${T}, _ y: ${T}) -> (${T}, Int) {
|
||||
% end
|
||||
|
||||
% for T, CT, f in OverlayFloatTypes():
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func nan(tag: String) -> ${T} {
|
||||
return ${T}(nan${f}(tag))
|
||||
@@ -301,7 +301,7 @@ public func nan(tag: String) -> ${T} {
|
||||
% end
|
||||
|
||||
% for T, CT, f in OverlayFloatTypes():
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func fma(x: ${T}, _ y: ${T}, _ z: ${T}) -> ${T} {
|
||||
return ${T}(fma${f}(${CT}(x), ${CT}(y), ${CT}(z)))
|
||||
@@ -310,13 +310,13 @@ public func fma(x: ${T}, _ y: ${T}, _ z: ${T}) -> ${T} {
|
||||
% end
|
||||
|
||||
% # These C functions only support double. The overlay fixes the Int parameter.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func jn(n: Int, _ x: Double) -> Double {
|
||||
return jn(CInt(n), x)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func yn(n: Int, _ x: Double) -> Double {
|
||||
return yn(CInt(n), x)
|
||||
|
||||
@@ -54,7 +54,7 @@ public struct ObjCBool : BooleanType, BooleanLiteralConvertible {
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(booleanLiteral value: Bool) {
|
||||
self.init(value)
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public struct Selector : StringLiteralConvertible, NilLiteralConvertible {
|
||||
}
|
||||
|
||||
/// Create an instance initialized with `nil`.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init(nilLiteral: ()) {
|
||||
ptr = nil
|
||||
}
|
||||
@@ -184,7 +184,7 @@ public struct NSZone : NilLiteralConvertible {
|
||||
public init() { pointer = nil }
|
||||
|
||||
/// Create an instance initialized with `nil`.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init(nilLiteral: ()) {
|
||||
pointer = nil
|
||||
}
|
||||
@@ -220,10 +220,10 @@ public var NO: ObjCBool {
|
||||
fatalError("can't retrieve unavailable property")
|
||||
}
|
||||
|
||||
// FIXME: We can't make the fully-generic versions @_transparent due to
|
||||
// rdar://problem/19418937, so here are some @_transparent overloads
|
||||
// FIXME: We can't make the fully-generic versions @transparent due to
|
||||
// rdar://problem/19418937, so here are some @transparent overloads
|
||||
// for ObjCBool
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func && <T : BooleanType>(
|
||||
lhs: T, @autoclosure rhs: () -> ObjCBool
|
||||
@@ -231,7 +231,7 @@ public func && <T : BooleanType>(
|
||||
return lhs.boolValue ? rhs().boolValue : false
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func || <T : BooleanType>(
|
||||
lhs: T, @autoclosure rhs: () -> ObjCBool
|
||||
|
||||
@@ -18,7 +18,7 @@ import Foundation
|
||||
// Equatable types.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
@warn_unused_result
|
||||
public func == (lhs: UIEdgeInsets, rhs: UIEdgeInsets) -> Bool {
|
||||
return lhs.top == rhs.top &&
|
||||
@@ -29,7 +29,7 @@ public func == (lhs: UIEdgeInsets, rhs: UIEdgeInsets) -> Bool {
|
||||
|
||||
extension UIEdgeInsets : Equatable {}
|
||||
|
||||
@_transparent // @fragile
|
||||
@transparent // @fragile
|
||||
@warn_unused_result
|
||||
public func == (lhs: UIOffset, rhs: UIOffset) -> Bool {
|
||||
return lhs.horizontal == rhs.horizontal &&
|
||||
|
||||
@@ -47,14 +47,14 @@ public struct ${vectype} :
|
||||
|
||||
% for i in xrange(size):
|
||||
public var ${component[i]} : ${type} {
|
||||
@_transparent
|
||||
@transparent
|
||||
get {
|
||||
let elt = Builtin.${extractelement}(_vector,
|
||||
(${i} as Int32)._value)
|
||||
|
||||
return ${type}(_bits: elt)
|
||||
}
|
||||
@_transparent
|
||||
@transparent
|
||||
set {
|
||||
_vector = Builtin.${insertelement}(_vector,
|
||||
newValue._value,
|
||||
@@ -64,16 +64,16 @@ public struct ${vectype} :
|
||||
% end
|
||||
|
||||
/// Initialize to the zero vector.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init() { self.init(0) }
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(_bits: Builtin.${llvm_vectype}) {
|
||||
_vector = _bits
|
||||
}
|
||||
|
||||
/// Initialize a vector with the specified elements.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(${', '.join(map(lambda c: '_ ' + c + ': ' + type, component[:size]))}) {
|
||||
var v: Builtin.${llvm_vectype} = Builtin.zeroInitializer()
|
||||
% for i in xrange(size):
|
||||
@@ -85,13 +85,13 @@ public struct ${vectype} :
|
||||
}
|
||||
|
||||
/// Initialize a vector with the specified elements.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(${', '.join(map(lambda c: c + ': ' + type, component[:size]))}) {
|
||||
self.init(${', '.join(c for c in component[:size])})
|
||||
}
|
||||
|
||||
/// Initialize to a vector with all elements equal to `scalar`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(_ scalar: ${type}) {
|
||||
self.init(${', '.join(['scalar']*size)})
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public struct ${vectype} :
|
||||
|
||||
/// Access individual elements of the vector via subscript.
|
||||
public subscript(index: Int) -> ${type} {
|
||||
@_transparent
|
||||
@transparent
|
||||
get {
|
||||
_precondition(index >= 0, "vector index out of range")
|
||||
_precondition(index < ${size}, "vector index out of range")
|
||||
@@ -122,7 +122,7 @@ public struct ${vectype} :
|
||||
Int32(index)._value)
|
||||
return ${type}(_bits: elt)
|
||||
}
|
||||
@_transparent
|
||||
@transparent
|
||||
set(value) {
|
||||
_precondition(index >= 0, "vector index out of range")
|
||||
_precondition(index < ${size}, "vector index out of range")
|
||||
|
||||
@@ -829,7 +829,7 @@ extension ${Self} : CustomStringConvertible, CustomDebugStringConvertible {
|
||||
}
|
||||
|
||||
extension ${Self} {
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
internal func _cPointerArgs() -> (AnyObject?, Builtin.RawPointer) {
|
||||
let p = _baseAddressIfContiguous
|
||||
@@ -1168,7 +1168,7 @@ internal struct _InitializePointer<T> : _PointerFunctionType {
|
||||
rawMemory.initialize(newValue)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal init(_ newValue: T) {
|
||||
self.newValue = newValue
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// optimizer may assume that it *would* evaluate to `true`. Failure
|
||||
/// to satisfy that assumption in -Ounchecked builds is a serious
|
||||
/// programming error.
|
||||
@_transparent
|
||||
@transparent
|
||||
public func assert(
|
||||
@autoclosure condition: () -> Bool,
|
||||
@autoclosure _ message: () -> String = String(),
|
||||
@@ -57,7 +57,7 @@ public func assert(
|
||||
/// optimizer may assume that it *would* evaluate to `true`. Failure
|
||||
/// to satisfy that assumption in -Ounchecked builds is a serious
|
||||
/// programming error.
|
||||
@_transparent
|
||||
@transparent
|
||||
public func precondition(
|
||||
@autoclosure condition: () -> Bool,
|
||||
@autoclosure _ message: () -> String = String(),
|
||||
@@ -120,7 +120,7 @@ public func assertionFailure(
|
||||
/// * In -Ounchecked builds, the optimizer may assume that this
|
||||
/// function will never be called. Failure to satisfy that assumption
|
||||
/// is a serious programming error.
|
||||
@_transparent @noreturn
|
||||
@transparent @noreturn
|
||||
public func preconditionFailure(
|
||||
@autoclosure message: () -> String = String(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
||||
@@ -135,7 +135,7 @@ public func preconditionFailure(
|
||||
}
|
||||
|
||||
/// Unconditionally print a `message` and stop execution.
|
||||
@_transparent @noreturn
|
||||
@transparent @noreturn
|
||||
public func fatalError(
|
||||
@autoclosure message: () -> String = String(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
||||
@@ -149,7 +149,7 @@ public func fatalError(
|
||||
/// building in fast mode they are disabled. In release mode they don't print
|
||||
/// an error message but just trap. In debug mode they print an error message
|
||||
/// and abort.
|
||||
@_transparent
|
||||
@transparent
|
||||
public func _precondition(
|
||||
@autoclosure condition: () -> Bool, _ message: StaticString = StaticString(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
||||
@@ -165,7 +165,7 @@ public func _precondition(
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent @noreturn
|
||||
@transparent @noreturn
|
||||
public func _preconditionFailure(
|
||||
message: StaticString = StaticString(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__) {
|
||||
@@ -178,7 +178,7 @@ public func _preconditionFailure(
|
||||
/// If `error` is true, prints an error message in debug mode, traps in release
|
||||
/// mode, and returns an undefined error otherwise.
|
||||
/// Otherwise returns `result`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public func _overflowChecked<T>(
|
||||
args: (T, Bool),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
||||
@@ -202,7 +202,7 @@ public func _overflowChecked<T>(
|
||||
/// and abort.
|
||||
/// They are meant to be used when the check is not comprehensively checking for
|
||||
/// all possible errors.
|
||||
@_transparent
|
||||
@transparent
|
||||
public func _debugPrecondition(
|
||||
@autoclosure condition: () -> Bool, _ message: StaticString = StaticString(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
||||
@@ -215,7 +215,7 @@ public func _debugPrecondition(
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent @noreturn
|
||||
@transparent @noreturn
|
||||
public func _debugPreconditionFailure(
|
||||
message: StaticString = StaticString(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__) {
|
||||
@@ -231,7 +231,7 @@ public func _debugPreconditionFailure(
|
||||
/// standard library. They are only enable when the standard library is built
|
||||
/// with the build configuration INTERNAL_CHECKS_ENABLED enabled. Otherwise, the
|
||||
/// call to this function is a noop.
|
||||
@_transparent
|
||||
@transparent
|
||||
public func _sanityCheck(
|
||||
@autoclosure condition: () -> Bool, _ message: StaticString = StaticString(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
||||
@@ -243,7 +243,7 @@ public func _sanityCheck(
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent @noreturn
|
||||
@transparent @noreturn
|
||||
public func _sanityCheckFailure(
|
||||
message: StaticString = StaticString(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
// FIXME: We could go farther with this simplification, e.g. avoiding
|
||||
// UnsafeMutablePointer
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _isDebugAssertConfiguration() -> Bool {
|
||||
@@ -28,7 +28,7 @@ func _isDebugAssertConfiguration() -> Bool {
|
||||
return Int32(Builtin.assert_configuration()) == 0
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
internal func _isReleaseAssertConfiguration() -> Bool {
|
||||
// The values for the assert_configuration call are:
|
||||
@@ -38,7 +38,7 @@ internal func _isReleaseAssertConfiguration() -> Bool {
|
||||
return Int32(Builtin.assert_configuration()) == 1
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _isFastAssertConfiguration() -> Bool {
|
||||
@@ -49,7 +49,7 @@ func _isFastAssertConfiguration() -> Bool {
|
||||
return Int32(Builtin.assert_configuration()) == 2
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _isStdlibInternalChecksEnabled() -> Bool {
|
||||
@@ -181,14 +181,14 @@ func _fatalErrorMessage(prefix: StaticString, _ message: StaticString,
|
||||
|
||||
/// Prints a fatal error message when a unimplemented initializer gets
|
||||
/// called by the Objective-C runtime.
|
||||
@_transparent @noreturn
|
||||
@transparent @noreturn
|
||||
public // COMPILER_INTRINSIC
|
||||
func _unimplemented_initializer(className: StaticString,
|
||||
initName: StaticString = __FUNCTION__,
|
||||
file: StaticString = __FILE__,
|
||||
line: UInt = __LINE__,
|
||||
column: UInt = __COLUMN__) {
|
||||
// This function is marked @_transparent so that it is inlined into the caller
|
||||
// This function is marked @transparent so that it is inlined into the caller
|
||||
// (the initializer stub), and, depending on the build configuration,
|
||||
// redundant parameter values (__FILE__ etc.) are eliminated, and don't leak
|
||||
// information about the user's source.
|
||||
|
||||
@@ -17,38 +17,38 @@ public struct Bool {
|
||||
internal var _value: Builtin.Int1
|
||||
|
||||
/// Default-initialize Boolean value to `false`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init() {
|
||||
let zero: Int8 = 0
|
||||
self._value = Builtin.trunc_Int8_Int1(zero._value)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal init(_ v: Builtin.Int1) { self._value = v }
|
||||
}
|
||||
|
||||
extension Bool : _BuiltinBooleanLiteralConvertible, BooleanLiteralConvertible {
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(_builtinBooleanLiteral value: Builtin.Int1) {
|
||||
self._value = value
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(booleanLiteral value: Bool) {
|
||||
self = value
|
||||
}
|
||||
}
|
||||
|
||||
extension Bool : BooleanType {
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func _getBuiltinLogicValue() -> Builtin.Int1 {
|
||||
return _value
|
||||
}
|
||||
|
||||
/// Identical to `self`.
|
||||
@_transparent public var boolValue: Bool { return self }
|
||||
@transparent public var boolValue: Bool { return self }
|
||||
|
||||
/// Construct an instance representing the same logical value as
|
||||
/// `value`.
|
||||
@@ -65,11 +65,11 @@ extension Bool : CustomStringConvertible {
|
||||
}
|
||||
|
||||
// This is a magic entrypoint known to the compiler.
|
||||
@_transparent
|
||||
@transparent
|
||||
public // COMPILER_INTRINSIC
|
||||
func _getBool(v: Builtin.Int1) -> Bool { return Bool(v) }
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
extension Bool : Equatable, Hashable {
|
||||
/// The hash value.
|
||||
///
|
||||
@@ -88,13 +88,13 @@ extension Bool : Equatable, Hashable {
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Unary logical complement.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public prefix func !(a: Bool) -> Bool {
|
||||
return Bool(Builtin.xor_Int1(a._value, true._value))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ==(lhs: Bool, rhs: Bool) -> Bool {
|
||||
return Bool(Builtin.cmp_eq_Int1(lhs._value, rhs._value))
|
||||
|
||||
@@ -38,10 +38,10 @@ public func || <T : BooleanType, U : BooleanType>(
|
||||
return lhs.boolValue ? true : try rhs().boolValue
|
||||
}
|
||||
|
||||
// FIXME: We can't make the above @_transparent due to
|
||||
// rdar://problem/19418937, so here are some @_transparent overloads
|
||||
// FIXME: We can't make the above @transparent due to
|
||||
// rdar://problem/19418937, so here are some @transparent overloads
|
||||
// for Bool. We've done the same for ObjCBool
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func && <T : BooleanType>(
|
||||
lhs: T, @autoclosure rhs: () throws -> Bool
|
||||
@@ -49,7 +49,7 @@ public func && <T : BooleanType>(
|
||||
return lhs.boolValue ? try rhs().boolValue : false
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func || <T : BooleanType>(
|
||||
lhs: T, @autoclosure rhs: () throws -> Bool
|
||||
|
||||
@@ -313,7 +313,7 @@ func _getBridgedNonVerbatimObjectiveCType<T>(_: T.Type) -> Any.Type?
|
||||
|
||||
// -- Pointer argument bridging
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal var _nilNativeObject: AnyObject? {
|
||||
return nil
|
||||
}
|
||||
@@ -346,13 +346,13 @@ public struct AutoreleasingUnsafeMutablePointer<Memory /* TODO : class */>
|
||||
|
||||
public let _rawValue: Builtin.RawPointer
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public // COMPILER_INTRINSIC
|
||||
init(_ _rawValue: Builtin.RawPointer) {
|
||||
self._rawValue = _rawValue
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
var _isNull : Bool {
|
||||
return UnsafeMutablePointer<Memory>(self)._isNull
|
||||
}
|
||||
@@ -361,7 +361,7 @@ public struct AutoreleasingUnsafeMutablePointer<Memory /* TODO : class */>
|
||||
/// setting values.
|
||||
public var memory: Memory {
|
||||
/// Retrieve the value the pointer points to.
|
||||
@_transparent get {
|
||||
@transparent get {
|
||||
_debugPrecondition(!_isNull)
|
||||
// We can do a strong load normally.
|
||||
return UnsafeMutablePointer<Memory>(self).memory
|
||||
@@ -372,7 +372,7 @@ public struct AutoreleasingUnsafeMutablePointer<Memory /* TODO : class */>
|
||||
/// value with __autoreleasing ownership semantics, like 'NSFoo**'
|
||||
/// in ARC. This autoreleases the argument before trivially
|
||||
/// storing it to the referenced memory.
|
||||
@_transparent nonmutating set {
|
||||
@transparent nonmutating set {
|
||||
_debugPrecondition(!_isNull)
|
||||
// Autorelease the object reference.
|
||||
typealias OptionalAnyObject = AnyObject?
|
||||
@@ -392,7 +392,7 @@ public struct AutoreleasingUnsafeMutablePointer<Memory /* TODO : class */>
|
||||
///
|
||||
/// - Requires: `self != nil`.
|
||||
public subscript(i: Int) -> Memory {
|
||||
@_transparent
|
||||
@transparent
|
||||
get {
|
||||
_debugPrecondition(!_isNull)
|
||||
// We can do a strong load normally.
|
||||
@@ -401,13 +401,13 @@ public struct AutoreleasingUnsafeMutablePointer<Memory /* TODO : class */>
|
||||
}
|
||||
|
||||
/// Create an instance initialized with `nil`.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init(nilLiteral: ()) {
|
||||
_rawValue = _nilRawPointer
|
||||
}
|
||||
|
||||
/// Initialize to a null pointer.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init() {
|
||||
self._rawValue = _nilRawPointer
|
||||
}
|
||||
@@ -417,7 +417,7 @@ public struct AutoreleasingUnsafeMutablePointer<Memory /* TODO : class */>
|
||||
/// This is inherently unsafe; UnsafeMutablePointer assumes the
|
||||
/// referenced memory has +1 strong ownership semantics, whereas
|
||||
/// AutoreleasingUnsafeMutablePointer implies +0 semantics.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init<U>(_ ptr: UnsafeMutablePointer<U>) {
|
||||
self._rawValue = ptr._rawValue
|
||||
}
|
||||
@@ -426,7 +426,7 @@ public struct AutoreleasingUnsafeMutablePointer<Memory /* TODO : class */>
|
||||
///
|
||||
/// This is inherently unsafe because UnsafePointers do not imply
|
||||
/// mutability.
|
||||
@_transparent
|
||||
@transparent
|
||||
init<U>(_ ptr: UnsafePointer<U>) {
|
||||
self._rawValue = ptr._rawValue
|
||||
}
|
||||
@@ -439,7 +439,7 @@ extension AutoreleasingUnsafeMutablePointer : CustomDebugStringConvertible {
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func == <Memory> (
|
||||
lhs: AutoreleasingUnsafeMutablePointer<Memory>,
|
||||
@@ -467,7 +467,7 @@ internal struct _CocoaFastEnumerationStackBuf {
|
||||
var item14: Builtin.RawPointer
|
||||
var item15: Builtin.RawPointer
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
var length: Int {
|
||||
return 16
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import SwiftShims
|
||||
// without gobs of boilerplate.
|
||||
|
||||
/// An initialized raw pointer to use as a NULL value.
|
||||
@_transparent
|
||||
@transparent
|
||||
internal var _nilRawPointer: Builtin.RawPointer {
|
||||
let zero: Int8 = 0
|
||||
return Builtin.inttoptr_Int8(zero._value)
|
||||
@@ -27,7 +27,7 @@ internal var _nilRawPointer: Builtin.RawPointer {
|
||||
/// Does not include any dynamically-allocated or "remote" storage.
|
||||
/// In particular, `sizeof(X.self)`, when `X` is a class type, is the
|
||||
/// same regardless of how many stored properties `X` has.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func sizeof<T>(_:T.Type) -> Int {
|
||||
return Int(Builtin.sizeof(T.self))
|
||||
@@ -38,21 +38,21 @@ public func sizeof<T>(_:T.Type) -> Int {
|
||||
/// Does not include any dynamically-allocated or "remote" storage.
|
||||
/// In particular, `sizeof(a)`, when `a` is a class instance, is the
|
||||
/// same regardless of how many stored properties `a` has.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func sizeofValue<T>(_:T) -> Int {
|
||||
return sizeof(T.self)
|
||||
}
|
||||
|
||||
/// Returns the minimum memory alignment of `T`.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func alignof<T>(_:T.Type) -> Int {
|
||||
return Int(Builtin.alignof(T.self))
|
||||
}
|
||||
|
||||
/// Returns the minimum memory alignment of `T`.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func alignofValue<T>(_:T) -> Int {
|
||||
return alignof(T.self)
|
||||
@@ -60,7 +60,7 @@ public func alignofValue<T>(_:T) -> Int {
|
||||
|
||||
/// Returns the least possible interval between distinct instances of
|
||||
/// `T` in memory. The result is always positive.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func strideof<T>(_:T.Type) -> Int {
|
||||
return Int(Builtin.strideof_nonzero(T.self))
|
||||
@@ -68,7 +68,7 @@ public func strideof<T>(_:T.Type) -> Int {
|
||||
|
||||
/// Returns the least possible interval between distinct instances of
|
||||
/// `T` in memory. The result is always positive.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func strideofValue<T>(_:T) -> Int {
|
||||
return strideof(T.self)
|
||||
@@ -88,7 +88,7 @@ func _roundUpToAlignment(offset: Int, _ alignment: Int) -> Int {
|
||||
}
|
||||
|
||||
/// Returns a tri-state of 0 = no, 1 = yes, 2 = maybe.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _canBeClass<T>(_: T.Type) -> Int8 {
|
||||
@@ -101,7 +101,7 @@ func _canBeClass<T>(_: T.Type) -> Int8 {
|
||||
/// with extreme care. There's almost always a better way to do
|
||||
/// anything.
|
||||
///
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func unsafeBitCast<T, U>(x: T, _: U.Type) -> U {
|
||||
_precondition(sizeof(T.self) == sizeof(U.self),
|
||||
@@ -110,31 +110,31 @@ public func unsafeBitCast<T, U>(x: T, _: U.Type) -> U {
|
||||
}
|
||||
|
||||
/// `unsafeBitCast` something to `AnyObject`.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func _reinterpretCastToAnyObject<T>(x: T) -> AnyObject {
|
||||
return unsafeBitCast(x, AnyObject.self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
func ==(lhs: Builtin.NativeObject, rhs: Builtin.NativeObject) -> Bool {
|
||||
return unsafeBitCast(lhs, Int.self) == unsafeBitCast(rhs, Int.self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
func !=(lhs: Builtin.NativeObject, rhs: Builtin.NativeObject) -> Bool {
|
||||
return !(lhs == rhs)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
func ==(lhs: Builtin.RawPointer, rhs: Builtin.RawPointer) -> Bool {
|
||||
return unsafeBitCast(lhs, Int.self) == unsafeBitCast(rhs, Int.self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
func !=(lhs: Builtin.RawPointer, rhs: Builtin.RawPointer) -> Bool {
|
||||
return !(lhs == rhs)
|
||||
@@ -158,7 +158,7 @@ public func != (t0: Any.Type?, t1: Any.Type?) -> Bool {
|
||||
/// Tell the optimizer that this code is unreachable if condition is
|
||||
/// known at compile-time to be true. If condition is false, or true
|
||||
/// but not a compile-time constant, this call has no effect.
|
||||
@_transparent
|
||||
@transparent
|
||||
internal func _unreachable(condition: Bool = true) {
|
||||
if condition {
|
||||
// FIXME: use a parameterized version of Builtin.unreachable when
|
||||
@@ -169,7 +169,7 @@ internal func _unreachable(condition: Bool = true) {
|
||||
|
||||
/// Tell the optimizer that this code is unreachable if this builtin is
|
||||
/// reachable after constant folding build configuration builtins.
|
||||
@_transparent @noreturn internal
|
||||
@transparent @noreturn internal
|
||||
func _conditionallyUnreachable() {
|
||||
Builtin.conditionallyUnreachable()
|
||||
}
|
||||
@@ -200,7 +200,7 @@ internal func _isClassOrObjCExistential<T>(x: T.Type) -> Bool {
|
||||
/// Returns an `UnsafePointer` to the storage used for `object`. There's
|
||||
/// not much you can do with this other than use it to identify the
|
||||
/// object.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func unsafeAddressOf(object: AnyObject) -> UnsafePointer<Void> {
|
||||
return UnsafePointer(Builtin.bridgeToRawPointer(object))
|
||||
@@ -212,7 +212,7 @@ public func unsafeAddressOf(object: AnyObject) -> UnsafePointer<Void> {
|
||||
/// Unwrapped `T` and `U` must be convertible to AnyObject. They may
|
||||
/// be either a class or a class protocol. Either T, U, or both may be
|
||||
/// optional references.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func _unsafeReferenceCast<T, U>(x: T, _: U.Type) -> U {
|
||||
return Builtin.castReference(x)
|
||||
@@ -228,7 +228,7 @@ public func _unsafeReferenceCast<T, U>(x: T, _: U.Type) -> U {
|
||||
/// are confident that, always, `x is T`. It is better than an
|
||||
/// `unsafeBitCast` because it's more restrictive, and because
|
||||
/// checking is still performed in debug builds.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func unsafeDowncast<T : AnyObject>(x: AnyObject) -> T {
|
||||
_debugPrecondition(x is T, "invalid unsafeDowncast")
|
||||
@@ -286,7 +286,7 @@ public func _getUnsafePointerToStoredProperties(x: AnyObject)
|
||||
// semantics of these function calls. This won't be necessary with
|
||||
// mandatory generic inlining.
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@_semantics("branchhint")
|
||||
@warn_unused_result
|
||||
internal func _branchHint<C : BooleanType>(actual: C, _ expected: Bool)
|
||||
@@ -295,7 +295,7 @@ internal func _branchHint<C : BooleanType>(actual: C, _ expected: Bool)
|
||||
}
|
||||
|
||||
/// Optimizer hint that `x` is expected to be `true`.
|
||||
@_transparent
|
||||
@transparent
|
||||
@_semantics("fastpath")
|
||||
@warn_unused_result
|
||||
public func _fastPath<C: BooleanType>(x: C) -> Bool {
|
||||
@@ -303,7 +303,7 @@ public func _fastPath<C: BooleanType>(x: C) -> Bool {
|
||||
}
|
||||
|
||||
/// Optimizer hint that `x` is expected to be `false`.
|
||||
@_transparent
|
||||
@transparent
|
||||
@_semantics("slowpath")
|
||||
@warn_unused_result
|
||||
public func _slowPath<C : BooleanType>(x: C) -> Bool {
|
||||
@@ -514,14 +514,14 @@ func _getSuperclass(t: Any.Type) -> AnyClass? {
|
||||
// and type checking will fail.
|
||||
|
||||
/// Return true if `object` is uniquely referenced.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
internal func _isUnique<T>(inout object: T) -> Bool {
|
||||
return Bool(Builtin.isUnique(&object))
|
||||
}
|
||||
|
||||
/// Return true if `object` is uniquely referenced or pinned.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
internal func _isUniqueOrPinned<T>(inout object: T) -> Bool {
|
||||
return Bool(Builtin.isUniqueOrPinned(&object))
|
||||
@@ -529,7 +529,7 @@ internal func _isUniqueOrPinned<T>(inout object: T) -> Bool {
|
||||
|
||||
/// Return true if `object` is uniquely referenced.
|
||||
/// This provides sanity checks on top of the Builtin.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _isUnique_native<T>(inout object: T) -> Bool {
|
||||
@@ -546,7 +546,7 @@ func _isUnique_native<T>(inout object: T) -> Bool {
|
||||
|
||||
/// Return true if `object` is uniquely referenced or pinned.
|
||||
/// This provides sanity checks on top of the Builtin.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _isUniqueOrPinned_native<T>(inout object: T) -> Bool {
|
||||
@@ -562,7 +562,7 @@ func _isUniqueOrPinned_native<T>(inout object: T) -> Bool {
|
||||
|
||||
/// Return true if type is a POD type. A POD type is a type that does not
|
||||
/// require any special handling on copying or destruction.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _isPOD<T>(type: T.Type) -> Bool {
|
||||
|
||||
@@ -62,7 +62,7 @@ def TypedUnaryIntrinsicFunctions():
|
||||
// Unary intrinsic functions
|
||||
// Note these have a corresponding LLVM intrinsic
|
||||
% for T, CT, bits, ufunc in TypedUnaryIntrinsicFunctions():
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func _${ufunc}(x: ${T}) -> ${T} {
|
||||
return ${T}(_bits: Builtin.int_${ufunc}_FPIEEE${bits}(x._value))
|
||||
|
||||
@@ -80,12 +80,12 @@ public struct COpaquePointer : Equatable, Hashable, NilLiteralConvertible {
|
||||
var _rawValue: Builtin.RawPointer
|
||||
|
||||
/// Construct a `nil` instance.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init() {
|
||||
_rawValue = _nilRawPointer
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
init(_ v: Builtin.RawPointer) {
|
||||
_rawValue = v
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public struct COpaquePointer : Equatable, Hashable, NilLiteralConvertible {
|
||||
/// Construct a `COpaquePointer` from a given address in memory.
|
||||
///
|
||||
/// This is a fundamentally unsafe conversion.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(bitPattern: Int) {
|
||||
_rawValue = Builtin.inttoptr_Word(bitPattern._builtinWordValue)
|
||||
}
|
||||
@@ -101,25 +101,25 @@ public struct COpaquePointer : Equatable, Hashable, NilLiteralConvertible {
|
||||
/// Construct a `COpaquePointer` from a given address in memory.
|
||||
///
|
||||
/// This is a fundamentally unsafe conversion.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(bitPattern: UInt) {
|
||||
_rawValue = Builtin.inttoptr_Word(bitPattern._builtinWordValue)
|
||||
}
|
||||
|
||||
/// Convert a typed `UnsafePointer` to an opaque C pointer.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init<T>(_ source: UnsafePointer<T>) {
|
||||
self._rawValue = source._rawValue
|
||||
}
|
||||
|
||||
/// Convert a typed `UnsafeMutablePointer` to an opaque C pointer.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init<T>(_ source: UnsafeMutablePointer<T>) {
|
||||
self._rawValue = source._rawValue
|
||||
}
|
||||
|
||||
/// Determine whether the given pointer is null.
|
||||
@_transparent
|
||||
@transparent
|
||||
var _isNull : Bool {
|
||||
return self == nil
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public struct COpaquePointer : Equatable, Hashable, NilLiteralConvertible {
|
||||
}
|
||||
|
||||
/// Create an instance initialized with `nil`.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init(nilLiteral: ()) {
|
||||
_rawValue = _nilRawPointer
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ internal struct _CocoaArrayWrapper : CollectionType {
|
||||
: nil
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
init(_ buffer: _NSArrayCoreType) {
|
||||
self.buffer = buffer
|
||||
}
|
||||
|
||||
@@ -196,25 +196,25 @@ public struct ${Self}
|
||||
public typealias Distance = Int
|
||||
|
||||
/// Create an instance initialized to zero.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init() {
|
||||
let maxWidthZero: IntMax = 0
|
||||
self._value = Builtin.truncOrBitCast_Int${int_max_bits}_${BuiltinName}(
|
||||
maxWidthZero._value)
|
||||
}
|
||||
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init(_ _v: Builtin.${BuiltinName}) {
|
||||
self._value = _v
|
||||
}
|
||||
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init(_bits: Builtin.${BuiltinName}) {
|
||||
self._value = _bits
|
||||
}
|
||||
|
||||
% if self_ty.is_word:
|
||||
@_transparent
|
||||
@transparent
|
||||
public // @testable
|
||||
init(_ v: Builtin.Word) {
|
||||
% if BuiltinName == 'Int32':
|
||||
@@ -224,7 +224,7 @@ public struct ${Self}
|
||||
% end
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public // @testable
|
||||
var _builtinWordValue: Builtin.Word {
|
||||
% if BuiltinName == 'Int32':
|
||||
@@ -236,13 +236,13 @@ public struct ${Self}
|
||||
% end
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init(_ value: ${Self}) { self = value }
|
||||
|
||||
% if bits > 8:
|
||||
/// Creates an integer from its big-endian representation, changing the
|
||||
/// byte order if necessary.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init(bigEndian value: ${Self}) {
|
||||
#if arch(i386) || arch(x86_64) || arch(arm) || arch(arm64)
|
||||
self = ${Self}(Builtin.int_bswap_${BuiltinName}(value._value) )
|
||||
@@ -253,7 +253,7 @@ public struct ${Self}
|
||||
|
||||
/// Creates an integer from its little-endian representation, changing the
|
||||
/// byte order if necessary.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init(littleEndian value: ${Self}) {
|
||||
#if arch(i386) || arch(x86_64) || arch(arm) || arch(arm64)
|
||||
self = value
|
||||
@@ -263,13 +263,13 @@ public struct ${Self}
|
||||
}
|
||||
% end
|
||||
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init(_builtinIntegerLiteral value: Builtin.Int${builtinIntLiteralBits}) {
|
||||
self = ${Self}(Builtin.s_to_${sign}_checked_trunc_Int${builtinIntLiteralBits}_${BuiltinName}(value).0)
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init(integerLiteral value: ${Self}) {
|
||||
self = value
|
||||
}
|
||||
@@ -303,11 +303,11 @@ public struct ${Self}
|
||||
% end
|
||||
|
||||
% max = maskBits((bits - 1) if signed else bits)
|
||||
@_transparent public
|
||||
@transparent public
|
||||
static var max: ${Self} { return ${max} }
|
||||
@_transparent public
|
||||
@transparent public
|
||||
static var min: ${Self} { return ${'-%s-1' % max if signed else '0'} }
|
||||
@_transparent
|
||||
@transparent
|
||||
public static var _sizeInBits: ${Self} { return ${bits} }
|
||||
public static var _sizeInBytes: ${Self} { return ${bits}/8 }
|
||||
}
|
||||
@@ -357,7 +357,7 @@ extension ${Self} : CustomStringConvertible {
|
||||
// generic implementations of the arithmetic operators for
|
||||
// RandomAccessIndexType's are all shadowed by more-specific
|
||||
// implementations that *do* check for overflows.
|
||||
@_transparent
|
||||
@transparent
|
||||
extension ${Self} : RandomAccessIndexType {
|
||||
// HACK: Disable indexing and slicing Ranges of IntegerType types
|
||||
// outside of a generic context. See the implementation of Range
|
||||
@@ -367,24 +367,24 @@ extension ${Self} : RandomAccessIndexType {
|
||||
/// Returns the next consecutive value after `self`.
|
||||
///
|
||||
/// - Requires: The next value is representable.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
func successor() -> ${Self} {
|
||||
return self &+ 1
|
||||
}
|
||||
/// Returns the previous consecutive value before `self`.
|
||||
///
|
||||
/// - Requires: The previous value is representable.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
func predecessor() -> ${Self} {
|
||||
return self &- 1
|
||||
}
|
||||
|
||||
@_transparent public
|
||||
@transparent public
|
||||
func distanceTo(other: ${Self}) -> ${Self}.Distance {
|
||||
return numericCast((numericCast(other) as IntMax) &- numericCast(self))
|
||||
}
|
||||
|
||||
@_transparent public
|
||||
@transparent public
|
||||
func advancedBy(n: ${Self}.Distance) -> ${Self} {
|
||||
return numericCast((numericCast(self) as IntMax) &+ numericCast(n))
|
||||
}
|
||||
@@ -397,7 +397,7 @@ extension ${Self} {
|
||||
/// ${Method.capitalize()} `lhs` and `rhs`, returning a result and a
|
||||
/// `Bool` that is true iff the operation caused an arithmetic
|
||||
/// overflow.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
static func ${Method}WithOverflow(lhs: ${Self}, _ rhs: ${Self}) -> (${Self}, overflow: Bool) {
|
||||
let tmp = Builtin.${sign}${op}_with_overflow_${BuiltinName}(lhs._value, rhs._value, false._value)
|
||||
return (${Self}(tmp.0), Bool(tmp.1))
|
||||
@@ -408,7 +408,7 @@ extension ${Self} {
|
||||
/// Divide `lhs` and `rhs`, returning
|
||||
/// ${'a result' if op == 'div' else 'the remainder'} and a `Bool`
|
||||
/// that is true iff the operation caused an arithmetic overflow.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
static func ${Method}WithOverflow(lhs: ${Self}, _ rhs: ${Self}) -> (${Self}, overflow: Bool) {
|
||||
if rhs == 0 {
|
||||
return (0, true)
|
||||
@@ -428,13 +428,13 @@ extension ${Self} {
|
||||
% (U, un) = ('','') if signed else ('U','un')
|
||||
/// Represent this number using Swift's widest native ${un}signed
|
||||
/// integer type.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
func to${U}IntMax() -> ${U}IntMax {
|
||||
return ${'self' if Self == U+'Int%s'%int_max_bits else U+'IntMax(self)'}
|
||||
}
|
||||
% if not signed:
|
||||
/// Explicitly convert to `IntMax`${', trapping on overflow (except in -Ounchecked builds)' if bits == int_max_bits else ''}.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
func toIntMax() -> IntMax {
|
||||
return IntMax(toUIntMax())
|
||||
}
|
||||
@@ -442,12 +442,12 @@ extension ${Self} {
|
||||
}
|
||||
|
||||
% if signed:
|
||||
@_transparent
|
||||
@transparent
|
||||
extension ${Self} : SignedNumberType {}
|
||||
% end
|
||||
|
||||
// construction from other integer types
|
||||
@_transparent
|
||||
@transparent
|
||||
extension ${Self} {
|
||||
% for src_ty in all_integer_types(word_bits):
|
||||
% srcBits = src_ty.bits
|
||||
@@ -490,7 +490,7 @@ extension ${Self} {
|
||||
/// the least significant bits of the provided bit pattern.
|
||||
///
|
||||
/// No range or overflow checking occurs.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(truncatingBitPattern: ${Src}) {
|
||||
%
|
||||
let srcNotWord = truncatingBitPattern._value
|
||||
@@ -512,7 +512,7 @@ extension ${Self} {
|
||||
/// occurs, and the resulting `${Self}` may not have the same numeric
|
||||
/// value as `bitPattern`--it is only guaranteed to use the same
|
||||
/// pattern of bits.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(bitPattern: ${OtherSelf}) {
|
||||
self._value = bitPattern._value
|
||||
}
|
||||
@@ -524,7 +524,7 @@ extension ${Self} {
|
||||
// overflowChecked, pending <rdar://problem/16271923> so that we don't
|
||||
// foil static checking for numeric overflows.
|
||||
% for op,method in ('+','add'), ('*','mul'), ('-','sub'):
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${op} (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
|
||||
let (result, error) = Builtin.${sign}${method}_with_overflow_${BuiltinName}(
|
||||
lhs._value, rhs._value, true._value)
|
||||
@@ -535,7 +535,7 @@ public func ${op} (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
|
||||
% end
|
||||
|
||||
% for op,inst in [('/', 'div'), ('%', 'rem')]:
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${op}(lhs: ${Self}, rhs: ${Self}) -> ${Self} {
|
||||
Builtin.condfail((rhs == 0)._value)
|
||||
% if signed:
|
||||
@@ -549,7 +549,7 @@ public func ${op}(lhs: ${Self}, rhs: ${Self}) -> ${Self} {
|
||||
%end
|
||||
|
||||
// Bitwise negate
|
||||
@_transparent
|
||||
@transparent
|
||||
public prefix func ~(rhs: ${Self}) -> ${Self} {
|
||||
let mask = ${Self}.subtractWithOverflow(0, 1).0
|
||||
return ${Self}(Builtin.xor_${BuiltinName}(rhs._value, mask._value))
|
||||
@@ -559,14 +559,14 @@ public prefix func ~(rhs: ${Self}) -> ${Self} {
|
||||
% ('==','eq'), ('!=','ne'),
|
||||
% ('<',sign+'lt'), ('<=',sign+'le'),
|
||||
% ('>',sign+'gt'), ('>=',sign+'ge')):
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${op} (lhs: ${Self}, rhs: ${Self}) -> Bool {
|
||||
return Bool(Builtin.cmp_${name}_${BuiltinName}(lhs._value, rhs._value))
|
||||
}
|
||||
% end
|
||||
|
||||
% for op, name in (('<<','shl'), ('>>','ashr' if signed else 'lshr')):
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${op} (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
|
||||
% if signed:
|
||||
_precondition(U${Self}(rhs) < U${Self}._sizeInBits,
|
||||
@@ -580,14 +580,14 @@ public func ${op} (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
|
||||
% end
|
||||
|
||||
% for op, name in (('&','and'), ('^','xor'), ('|','or')):
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${op} (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
|
||||
return ${Self}(Builtin.${name}_${BuiltinName}(lhs._value, rhs._value))
|
||||
}
|
||||
% end
|
||||
|
||||
// bitwise operations
|
||||
@_transparent
|
||||
@transparent
|
||||
extension ${Self} : BitwiseOperationsType {
|
||||
/// The empty bitset of type ${Self}.
|
||||
public static var allZeros: ${Self} { return 0 }
|
||||
@@ -595,7 +595,7 @@ extension ${Self} : BitwiseOperationsType {
|
||||
|
||||
// Compound assignments
|
||||
% for op in '+', '-', '*', '<<', '>>', '&', '|', '^':
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${op}=(inout lhs: ${Self}, rhs: ${Self}) {
|
||||
lhs = lhs ${op} rhs
|
||||
}
|
||||
@@ -605,26 +605,26 @@ public func ${op}=(inout lhs: ${Self}, rhs: ${Self}) {
|
||||
|
||||
// FIXME: After <rdar://problem/20226526> is fixed, we should be able
|
||||
// to remove these.
|
||||
@_transparent
|
||||
@transparent
|
||||
public prefix func ++ (inout x: ${Self}) -> ${Self} {
|
||||
x = x + 1
|
||||
return x
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public postfix func ++ (inout x: ${Self}) -> ${Self} {
|
||||
let ret = x
|
||||
x = x + 1
|
||||
return ret
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public prefix func -- (inout x: ${Self}) -> ${Self} {
|
||||
x = x - 1
|
||||
return x
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public postfix func -- (inout x: ${Self}) -> ${Self} {
|
||||
let ret = x
|
||||
x = x - 1
|
||||
@@ -635,7 +635,7 @@ public postfix func -- (inout x: ${Self}) -> ${Self} {
|
||||
// TODO: Consider removing the underscore.
|
||||
/// Returns the argument and specifies that the value is not negative.
|
||||
/// It has only an effect if the argument is a load or call.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func _assumeNonNegative(x: ${Self}) -> ${Self} {
|
||||
_sanityCheck(x >= 0)
|
||||
@@ -647,7 +647,7 @@ public func _assumeNonNegative(x: ${Self}) -> ${Self} {
|
||||
|
||||
% fixedBitWidths = [2**x for x in range(3, 8) if 2**x <= 2 * word_bits]
|
||||
% for bits in fixedBitWidths:
|
||||
@_transparent
|
||||
@transparent
|
||||
public func _leadingZeros(x: Builtin.Int${bits}) -> Builtin.Int${bits} {
|
||||
return Builtin.int_ctlz_Int${bits}(x, true._value)
|
||||
}
|
||||
|
||||
@@ -178,20 +178,20 @@ public struct ${Self} {
|
||||
var _value: Builtin.FPIEEE${bits}
|
||||
|
||||
/// Create an instance initialized to zero.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init() {
|
||||
let zero: Int64 = 0
|
||||
self._value = Builtin.uitofp_Int64_FPIEEE${bits}(zero._value)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public // @testable
|
||||
init(_bits v: Builtin.FPIEEE${bits}) {
|
||||
self._value = v
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init(_ value: ${Self}) { self = value }
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ extension ${Self} : CustomStringConvertible {
|
||||
|
||||
% if bits in allIntBits:
|
||||
// Not transparent because the compiler crashes in that case.
|
||||
//@_transparent
|
||||
//@transparent
|
||||
extension ${Self} : FloatingPointType {
|
||||
public typealias _BitsType = UInt${bits}
|
||||
|
||||
@@ -328,7 +328,7 @@ extension ${Self} : FloatingPointType {
|
||||
}
|
||||
}
|
||||
|
||||
// Not @_transparent because the function is too complex.
|
||||
// Not @transparent because the function is too complex.
|
||||
extension ${Self} /* : FloatingPointType */ {
|
||||
/// The IEEE 754 "class" of this type.
|
||||
public var floatingPointClass: FloatingPointClassification {
|
||||
@@ -360,7 +360,7 @@ extension ${Self} /* : FloatingPointType */ {
|
||||
}
|
||||
% end
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
extension ${Self} : _BuiltinIntegerLiteralConvertible, IntegerLiteralConvertible {
|
||||
public
|
||||
init(_builtinIntegerLiteral value: Builtin.Int${builtinIntLiteralBits}){
|
||||
@@ -376,7 +376,7 @@ extension ${Self} : _BuiltinIntegerLiteralConvertible, IntegerLiteralConvertible
|
||||
#if arch(i386) || arch(x86_64)
|
||||
|
||||
% builtinFloatLiteralBits = 80
|
||||
@_transparent
|
||||
@transparent
|
||||
extension ${Self} : _BuiltinFloatLiteralConvertible {
|
||||
public
|
||||
init(_builtinFloatLiteral value: Builtin.FPIEEE${builtinFloatLiteralBits}) {
|
||||
@@ -394,7 +394,7 @@ extension ${Self} : _BuiltinFloatLiteralConvertible {
|
||||
#else
|
||||
|
||||
% builtinFloatLiteralBits = 64
|
||||
@_transparent
|
||||
@transparent
|
||||
extension ${Self} : _BuiltinFloatLiteralConvertible {
|
||||
public
|
||||
init(_builtinFloatLiteral value: Builtin.FPIEEE${builtinFloatLiteralBits}) {
|
||||
@@ -411,7 +411,7 @@ extension ${Self} : _BuiltinFloatLiteralConvertible {
|
||||
|
||||
#endif
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
extension ${Self} : FloatLiteralConvertible {
|
||||
/// Create an instance initialized to `value`.
|
||||
public init(floatLiteral value: ${Self}) {
|
||||
@@ -419,43 +419,43 @@ extension ${Self} : FloatLiteralConvertible {
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ==(lhs: ${Self}, rhs: ${Self}) -> Bool {
|
||||
return Bool(Builtin.fcmp_oeq_FPIEEE${bits}(lhs._value, rhs._value))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func != (lhs: ${Self}, rhs: ${Self}) -> Bool {
|
||||
return Bool(Builtin.fcmp_une_FPIEEE${bits}(lhs._value, rhs._value))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func <(lhs: ${Self}, rhs: ${Self}) -> Bool {
|
||||
return Bool(Builtin.fcmp_olt_FPIEEE${bits}(lhs._value, rhs._value))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func > (lhs: ${Self}, rhs: ${Self}) -> Bool {
|
||||
return Bool(Builtin.fcmp_ogt_FPIEEE${bits}(lhs._value, rhs._value))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func <= (lhs: ${Self}, rhs: ${Self}) -> Bool {
|
||||
return Bool(Builtin.fcmp_ole_FPIEEE${bits}(lhs._value, rhs._value))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func >= (lhs: ${Self}, rhs: ${Self}) -> Bool {
|
||||
return Bool(Builtin.fcmp_oge_FPIEEE${bits}(lhs._value, rhs._value))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
extension ${Self} : Comparable, Equatable {
|
||||
}
|
||||
|
||||
@@ -495,23 +495,23 @@ extension ${Self} : Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
extension ${Self} : AbsoluteValuable {
|
||||
/// Returns the absolute value of `x`.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public static func abs(x: ${Self}) -> ${Self} {
|
||||
return ${Self}(_bits: Builtin.int_fabs_FPIEEE${bits}(x._value))
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public prefix func +(x: ${Self}) -> ${Self} {
|
||||
return x
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public prefix func -(x: ${Self}) -> ${Self} {
|
||||
return ${Self}(_bits: Builtin.fneg_FPIEEE${bits}(x._value))
|
||||
@@ -522,7 +522,7 @@ public prefix func -(x: ${Self}) -> ${Self} {
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Construction from integers.
|
||||
@_transparent
|
||||
@transparent
|
||||
extension ${Self} {
|
||||
% for (srcBits, srcSigned) in allInts():
|
||||
% That = intName(srcBits, srcSigned)
|
||||
@@ -535,7 +535,7 @@ extension ${Self} {
|
||||
}
|
||||
|
||||
// Construction from other floating point numbers.
|
||||
@_transparent
|
||||
@transparent
|
||||
extension ${Self} {
|
||||
% for srcBits in allFloatBits:
|
||||
% That = floatName(srcBits)
|
||||
@@ -566,24 +566,24 @@ extension ${Self} {
|
||||
// Standard Operator Table
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public prefix func ++ (inout rhs: ${Self}) -> ${Self} { rhs += 1.0; return rhs }
|
||||
@_transparent
|
||||
@transparent
|
||||
public prefix func -- (inout rhs: ${Self}) -> ${Self} { rhs -= 1.0; return rhs }
|
||||
@_transparent
|
||||
@transparent
|
||||
public postfix func ++ (inout lhs: ${Self}) -> ${Self} { let tmp = lhs; lhs += 1.0; return tmp }
|
||||
@_transparent
|
||||
@transparent
|
||||
public postfix func -- (inout lhs: ${Self}) -> ${Self} { let tmp = lhs; lhs -= 1.0; return tmp }
|
||||
|
||||
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
extension ${Self} : Strideable {
|
||||
/// Returns a stride `x` such that `self.advancedBy(x)` approximates
|
||||
/// `other`.
|
||||
///
|
||||
/// - Complexity: O(1).
|
||||
@_transparent public
|
||||
@transparent public
|
||||
func distanceTo(other: ${Self}) -> ${Self} {
|
||||
return other - self
|
||||
}
|
||||
@@ -592,14 +592,14 @@ extension ${Self} : Strideable {
|
||||
/// `n`.
|
||||
///
|
||||
/// - Complexity: O(1).
|
||||
@_transparent public
|
||||
@transparent public
|
||||
func advancedBy(amount: ${Self}) -> ${Self} {
|
||||
return self + amount
|
||||
}
|
||||
}
|
||||
|
||||
% for op, name in ('+','fadd'), ('-','fsub'),('*','fmul'), ('/','fdiv'):
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ${op} (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
|
||||
return ${Self}(_bits: Builtin.${name}_FPIEEE${bits}(lhs._value, rhs._value))
|
||||
@@ -623,7 +623,7 @@ public func % (lhs: ${Self}, rhs: ${Self}) -> ${Self}
|
||||
// In C, 90 is =, *=, += etc.
|
||||
|
||||
% for op in '+', '-', '*', '/', '%':
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${op}= (inout lhs: ${Self}, rhs: ${Self}) { lhs = lhs ${op} rhs }
|
||||
% end
|
||||
|
||||
@@ -638,7 +638,7 @@ public func ${op}= (inout lhs: ${Self}, rhs: ${Self}) { lhs = lhs ${op} rhs }
|
||||
% sign = 's' if signed else 'u'
|
||||
% Self = intName(bits, signed)
|
||||
% BuiltinName = builtinIntName(bits)
|
||||
@_transparent
|
||||
@transparent
|
||||
extension ${Self} {
|
||||
% for srcBits in allFloatBits:
|
||||
% That = floatName(srcBits)
|
||||
|
||||
@@ -233,7 +233,7 @@ internal protocol _HashStorageType {
|
||||
/// The inverse of the default hash table load factor. Factored out so that it
|
||||
/// can be used in multiple places in the implementation and stay consistent.
|
||||
/// Should not be used outside `Dictionary` implementation.
|
||||
@_transparent
|
||||
@transparent
|
||||
internal var _hashContainerDefaultMaxLoadFactorInverse: Double {
|
||||
return 1.0 / 0.75
|
||||
}
|
||||
@@ -1893,7 +1893,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
|
||||
self = _Native${Self}Storage(capacity: capacity)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public // @testable
|
||||
var capacity: Int {
|
||||
@warn_unused_result
|
||||
@@ -1904,7 +1904,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal var count: Int {
|
||||
@warn_unused_result
|
||||
get {
|
||||
@@ -1918,7 +1918,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal var maxLoadFactorInverse: Double {
|
||||
@warn_unused_result
|
||||
get {
|
||||
@@ -1944,7 +1944,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
|
||||
return initializedEntries[i]
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal func destroyEntryAt(i: Int) {
|
||||
_sanityCheck(isInitializedEntry(i))
|
||||
(keys + i).destroy()
|
||||
@@ -1956,7 +1956,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
|
||||
}
|
||||
|
||||
%if Self == 'Set':
|
||||
@_transparent
|
||||
@transparent
|
||||
internal func initializeKey(k: Key, at i: Int) {
|
||||
_sanityCheck(!isInitializedEntry(i))
|
||||
|
||||
@@ -1965,7 +1965,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
|
||||
_fixLifetime(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal func moveInitializeFrom(from: Storage, at: Int, toEntryAt: Int) {
|
||||
_sanityCheck(!isInitializedEntry(toEntryAt))
|
||||
(keys + toEntryAt).initialize((from.keys + at).move())
|
||||
@@ -1982,7 +1982,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
|
||||
}
|
||||
|
||||
%elif Self == 'Dictionary':
|
||||
@_transparent
|
||||
@transparent
|
||||
internal func initializeKey(k: Key, value v: Value, at i: Int) {
|
||||
_sanityCheck(!isInitializedEntry(i))
|
||||
|
||||
@@ -1992,7 +1992,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
|
||||
_fixLifetime(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal func moveInitializeFrom(from: Storage, at: Int, toEntryAt: Int) {
|
||||
_sanityCheck(!isInitializedEntry(toEntryAt))
|
||||
(keys + toEntryAt).initialize((from.keys + at).move())
|
||||
@@ -2001,7 +2001,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
|
||||
initializedEntries[toEntryAt] = true
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
internal func valueAt(i: Int) -> Value {
|
||||
_sanityCheck(isInitializedEntry(i))
|
||||
@@ -2011,7 +2011,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
|
||||
return res
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal func setKey(key: Key, value: Value, at i: Int) {
|
||||
_sanityCheck(isInitializedEntry(i))
|
||||
(keys + i).memory = key
|
||||
@@ -2070,7 +2070,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
internal static func getMinCapacity(
|
||||
requestedCount: Int, _ maxLoadFactorInverse: Double) -> Int {
|
||||
@@ -2274,7 +2274,7 @@ internal struct _BridgedNative${Self}Storage {
|
||||
_fixLifetime(buffer)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal var capacity: Int {
|
||||
get {
|
||||
let c = buffer._capacity
|
||||
@@ -2305,7 +2305,7 @@ internal struct _BridgedNative${Self}Storage {
|
||||
}
|
||||
|
||||
%if Self == 'Set':
|
||||
@_transparent
|
||||
@transparent
|
||||
internal func initializeKey(k: AnyObject, at i: Int) {
|
||||
_sanityCheck(!isInitializedEntry(i))
|
||||
|
||||
@@ -2314,7 +2314,7 @@ internal struct _BridgedNative${Self}Storage {
|
||||
_fixLifetime(self)
|
||||
}
|
||||
%elif Self == 'Dictionary':
|
||||
@_transparent
|
||||
@transparent
|
||||
internal func initializeKey(k: AnyObject, value v: AnyObject, at i: Int
|
||||
) {
|
||||
_sanityCheck(!isInitializedEntry(i))
|
||||
@@ -2325,7 +2325,7 @@ internal struct _BridgedNative${Self}Storage {
|
||||
_fixLifetime(self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
internal func valueAt(i: Int) -> AnyObject {
|
||||
_sanityCheck(isInitializedEntry(i))
|
||||
@@ -2903,7 +2903,7 @@ internal enum _Variant${Self}Storage<${TypeParametersDecl}> : _HashStorageType {
|
||||
case Native(NativeStorageOwner)
|
||||
case Cocoa(CocoaStorage)
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal var guaranteedNative: Bool {
|
||||
return _canBeClass(Key.self) == 0 && _canBeClass(Value.self) == 0
|
||||
}
|
||||
@@ -3668,12 +3668,12 @@ public struct ${Self}Index<${TypeParametersDecl}> :
|
||||
}
|
||||
#endif
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal var _guaranteedNative: Bool {
|
||||
return _canBeClass(Key.self) == 0 && _canBeClass(Value.self) == 0
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal var _nativeIndex: _NativeIndex {
|
||||
switch _value {
|
||||
case ._Native(let nativeIndex):
|
||||
@@ -3684,7 +3684,7 @@ public struct ${Self}Index<${TypeParametersDecl}> :
|
||||
}
|
||||
|
||||
#if _runtime(_ObjC)
|
||||
@_transparent
|
||||
@transparent
|
||||
internal var _cocoaIndex: _CocoaIndex {
|
||||
switch _value {
|
||||
case ._Native:
|
||||
@@ -3895,7 +3895,7 @@ public struct ${Self}Generator<${TypeParametersDecl}> : GeneratorType {
|
||||
}
|
||||
#endif
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal var _guaranteedNative: Bool {
|
||||
%if Self == 'Set':
|
||||
return _canBeClass(Element.self) == 0
|
||||
|
||||
@@ -39,7 +39,7 @@ struct _HashingDetail {
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
static func getExecutionSeed() -> UInt64 {
|
||||
// FIXME: This needs to be a per-execution seed. This is just a placeholder
|
||||
@@ -48,7 +48,7 @@ struct _HashingDetail {
|
||||
return _HashingDetail.fixedSeedOverride == 0 ? seed : fixedSeedOverride
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
static func hash16Bytes(low: UInt64, _ high: UInt64) -> UInt64 {
|
||||
// Murmur-inspired hashing.
|
||||
@@ -71,7 +71,7 @@ struct _HashingDetail {
|
||||
// their inputs and just exhibit avalance effect.
|
||||
//
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _mixUInt32(value: UInt32) -> UInt32 {
|
||||
@@ -85,14 +85,14 @@ func _mixUInt32(value: UInt32) -> UInt32 {
|
||||
return UInt32((extendedResult >> 3) & 0xffff_ffff)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _mixInt32(value: Int32) -> Int32 {
|
||||
return Int32(bitPattern: _mixUInt32(UInt32(bitPattern: value)))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _mixUInt64(value: UInt64) -> UInt64 {
|
||||
@@ -103,14 +103,14 @@ func _mixUInt64(value: UInt64) -> UInt64 {
|
||||
return _HashingDetail.hash16Bytes(seed &+ (low << 3), high)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _mixInt64(value: Int64) -> Int64 {
|
||||
return Int64(bitPattern: _mixUInt64(UInt64(bitPattern: value)))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _mixUInt(value: UInt) -> UInt {
|
||||
@@ -121,7 +121,7 @@ func _mixUInt(value: UInt) -> UInt {
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _mixInt(value: Int) -> Int {
|
||||
|
||||
@@ -42,7 +42,7 @@ public enum ImplicitlyUnwrappedOptional<Wrapped>
|
||||
}
|
||||
|
||||
/// Create an instance initialized with `nil`.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init(nilLiteral: ()) {
|
||||
self = .None
|
||||
}
|
||||
@@ -95,7 +95,7 @@ extension ImplicitlyUnwrappedOptional : CustomStringConvertible {
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // COMPILER_INTRINSIC
|
||||
func _getImplicitlyUnwrappedOptionalValue<Wrapped>(v: Wrapped!) -> Wrapped {
|
||||
@@ -108,7 +108,7 @@ func _getImplicitlyUnwrappedOptionalValue<Wrapped>(v: Wrapped!) -> Wrapped {
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // COMPILER_INTRINSIC
|
||||
func _injectValueIntoImplicitlyUnwrappedOptional<Wrapped>(
|
||||
@@ -117,7 +117,7 @@ func _injectValueIntoImplicitlyUnwrappedOptional<Wrapped>(
|
||||
return .Some(v)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // COMPILER_INTRINSIC
|
||||
func _injectNothingIntoImplicitlyUnwrappedOptional<Wrapped>() -> Wrapped! {
|
||||
|
||||
@@ -72,7 +72,7 @@ public struct _DisabledRangeIndex_ {
|
||||
|
||||
/// Replace `i` with its `successor()` and return the updated value of
|
||||
/// `i`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public prefix func ++ <T : _Incrementable> (inout i: T) -> T {
|
||||
i._successorInPlace()
|
||||
return i
|
||||
@@ -80,7 +80,7 @@ public prefix func ++ <T : _Incrementable> (inout i: T) -> T {
|
||||
|
||||
/// Replace `i` with its `successor()` and return the original
|
||||
/// value of `i`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public postfix func ++ <T : _Incrementable> (inout i: T) -> T {
|
||||
let ret = i
|
||||
i._successorInPlace()
|
||||
@@ -208,7 +208,7 @@ extension ForwardIndexType {
|
||||
}
|
||||
|
||||
/// Do not use this method directly; call advancedBy(n) instead.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
internal func _advanceForward(n: Distance) -> Self {
|
||||
_precondition(n >= 0,
|
||||
@@ -221,7 +221,7 @@ extension ForwardIndexType {
|
||||
}
|
||||
|
||||
/// Do not use this method directly; call advancedBy(n, limit) instead.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
internal func _advanceForward(n: Distance, _ limit: Self) -> Self {
|
||||
_precondition(n >= 0,
|
||||
@@ -309,7 +309,7 @@ extension BidirectionalIndexType {
|
||||
|
||||
/// Replace `i` with its `predecessor()` and return the updated value
|
||||
/// of `i`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public prefix func -- <T : BidirectionalIndexType> (inout i: T) -> T {
|
||||
i._predecessorInPlace()
|
||||
return i
|
||||
@@ -318,7 +318,7 @@ public prefix func -- <T : BidirectionalIndexType> (inout i: T) -> T {
|
||||
|
||||
/// Replace `i` with its `predecessor()` and return the original
|
||||
/// value of `i`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public postfix func -- <T : BidirectionalIndexType> (inout i: T) -> T {
|
||||
let ret = i
|
||||
i._predecessorInPlace()
|
||||
@@ -386,7 +386,7 @@ extension RandomAccessIndexType {
|
||||
"range.startIndex is out of bounds: index designates a position after bounds.endIndex")
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func advancedBy(n: Distance, limit: Self) -> Self {
|
||||
let d = self.distanceTo(limit)
|
||||
|
||||
@@ -54,7 +54,7 @@ public protocol IntegerArithmeticType : _IntegerArithmeticType, Comparable {
|
||||
% for name,op,Action,result in integerBinaryOps:
|
||||
/// ${Action} `lhs` and `rhs`, returning ${result} and trapping in case of
|
||||
/// arithmetic overflow (except in -Ounchecked builds).
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ${op} <T : _IntegerArithmeticType>(lhs: T, rhs: T) -> T {
|
||||
return _overflowChecked(T.${name}WithOverflow(lhs, rhs))
|
||||
@@ -62,7 +62,7 @@ public func ${op} <T : _IntegerArithmeticType>(lhs: T, rhs: T) -> T {
|
||||
|
||||
% if (op != '/') and (op != '%'):
|
||||
/// ${name} `lhs` and `rhs`, silently discarding any overflow.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func &${op} <T : _IntegerArithmeticType>(lhs: T, rhs: T) -> T {
|
||||
return T.${name}WithOverflow(lhs, rhs).0
|
||||
@@ -71,7 +71,7 @@ public func &${op} <T : _IntegerArithmeticType>(lhs: T, rhs: T) -> T {
|
||||
|
||||
/// ${name} `lhs` and `rhs` and store the result in `lhs`, trapping in
|
||||
/// case of arithmetic overflow (except in -Ounchecked builds).
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${op}= <T : _IntegerArithmeticType>(inout lhs: T, rhs: T) {
|
||||
lhs = lhs ${op} rhs
|
||||
}
|
||||
@@ -107,13 +107,13 @@ public protocol SignedNumberType : Comparable, IntegerLiteralConvertible {
|
||||
// Unary negation in terms of subtraction. This is a default
|
||||
// implementation; models of SignedNumberType can provide their own
|
||||
// implementations.
|
||||
@_transparent
|
||||
@transparent
|
||||
public prefix func - <T : SignedNumberType>(x: T) -> T {
|
||||
return 0 - x
|
||||
}
|
||||
|
||||
// Unary +
|
||||
@_transparent
|
||||
@transparent
|
||||
public prefix func + <T : SignedNumberType>(x: T) -> T {
|
||||
return x
|
||||
}
|
||||
@@ -125,7 +125,7 @@ internal func _abs<Args>(args: Args) -> (_Abs, Args) {
|
||||
}
|
||||
|
||||
// Do not use this operator directly; call abs(x) instead
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ~> <T : SignedNumberType>(x:T,_:(_Abs, ())) -> T {
|
||||
return x < 0 ? -x : x
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public protocol AbsoluteValuable : SignedNumberType {
|
||||
}
|
||||
|
||||
// Do not use this operator directly; call abs(x) instead
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ~> <T : AbsoluteValuable>(x:T,_:(_Abs, ())) -> T {
|
||||
return T.abs(x)
|
||||
}
|
||||
@@ -148,7 +148,7 @@ public func ~> <T : AbsoluteValuable>(x:T,_:(_Abs, ())) -> T {
|
||||
///
|
||||
/// Concrete instances of `SignedNumberType` can specialize this
|
||||
/// function by conforming to `AbsoluteValuable`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public func abs<T : SignedNumberType>(x: T) -> T {
|
||||
return x~>_abs()
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ extension String {
|
||||
|
||||
// Fix the lifetime of the given instruction so that the ARC optimizer does not
|
||||
// shorten the lifetime of x to be before this point.
|
||||
@_transparent
|
||||
@transparent
|
||||
public func _fixLifetime<T>(x: T) {
|
||||
Builtin.fixLifetime(x)
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
// FIXME: Once we have an FFI interface, make these have proper function bodies
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _countLeadingZeros(value: Int64) -> Int64 {
|
||||
@@ -22,7 +22,7 @@ func _countLeadingZeros(value: Int64) -> Int64 {
|
||||
}
|
||||
|
||||
/// Returns if `x` is a power of 2.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _isPowerOf2(x: UInt) -> Bool {
|
||||
@@ -35,7 +35,7 @@ func _isPowerOf2(x: UInt) -> Bool {
|
||||
}
|
||||
|
||||
/// Returns if `x` is a power of 2.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _isPowerOf2(x: Int) -> Bool {
|
||||
@@ -48,7 +48,7 @@ func _isPowerOf2(x: Int) -> Bool {
|
||||
}
|
||||
|
||||
#if _runtime(_ObjC)
|
||||
@_transparent
|
||||
@transparent
|
||||
public func _autorelease(x: AnyObject) {
|
||||
Builtin.retain(x)
|
||||
Builtin.autorelease(x)
|
||||
@@ -97,7 +97,7 @@ func _typeName(type: Any.Type, qualified: Bool = true) -> String {
|
||||
///
|
||||
/// TODO: Implement version working on Int instead of Int64.
|
||||
@warn_unused_result
|
||||
@_transparent
|
||||
@transparent
|
||||
public // @testable
|
||||
func _floorLog2(x: Int64) -> Int {
|
||||
_sanityCheck(x > 0, "_floorLog2 operates only on non-negative integers")
|
||||
|
||||
@@ -20,11 +20,11 @@ public enum Optional<Wrapped> : _Reflectable, NilLiteralConvertible {
|
||||
public typealias T = Wrapped
|
||||
|
||||
/// Construct a `nil` instance.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init() { self = .None }
|
||||
|
||||
/// Construct a non-`nil` instance that stores `some`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(_ some: Wrapped) { self = .Some(some) }
|
||||
|
||||
/// If `self == nil`, returns `nil`. Otherwise, returns `f(self!)`.
|
||||
@@ -56,7 +56,7 @@ public enum Optional<Wrapped> : _Reflectable, NilLiteralConvertible {
|
||||
}
|
||||
|
||||
/// Create an instance initialized with `nil`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(nilLiteral: ()) {
|
||||
self = .None
|
||||
}
|
||||
@@ -98,20 +98,20 @@ public func flatMap<T, U>(x: T?, @noescape _ f: (T)->U?) -> U? {
|
||||
}
|
||||
|
||||
// Intrinsics for use by language features.
|
||||
@_transparent
|
||||
@transparent
|
||||
public // COMPILER_INTRINSIC
|
||||
func _doesOptionalHaveValueAsBool<Wrapped>(v: Wrapped?) -> Bool {
|
||||
return v != nil
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public // COMPILER_INTRINSIC
|
||||
func _diagnoseUnexpectedNilOptional() {
|
||||
_preconditionFailure(
|
||||
"unexpectedly found nil while unwrapping an Optional value")
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public // COMPILER_INTRINSIC
|
||||
func _getOptionalValue<Wrapped>(v: Wrapped?) -> Wrapped {
|
||||
switch v {
|
||||
@@ -123,13 +123,13 @@ func _getOptionalValue<Wrapped>(v: Wrapped?) -> Wrapped {
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public // COMPILER_INTRINSIC
|
||||
func _injectValueIntoOptional<Wrapped>(v: Wrapped) -> Wrapped? {
|
||||
return .Some(v)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public // COMPILER_INTRINSIC
|
||||
func _injectNothingIntoOptional<Wrapped>() -> Wrapped? {
|
||||
return .None
|
||||
@@ -157,11 +157,11 @@ public func != <T : Equatable> (lhs: T?, rhs: T?) -> Bool {
|
||||
// isn't equatable.
|
||||
public struct _OptionalNilComparisonType : NilLiteralConvertible {
|
||||
/// Create an instance initialized with `nil`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(nilLiteral: ()) {
|
||||
}
|
||||
}
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ~= <T>(lhs: _OptionalNilComparisonType, rhs: T?) -> Bool {
|
||||
switch rhs {
|
||||
@@ -291,7 +291,7 @@ public func >= <T : Comparable>(lhs: T?, rhs: T?) -> Bool {
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ?? <T> (optional: T?, @autoclosure defaultValue: () throws -> T)
|
||||
rethrows -> T {
|
||||
@@ -303,7 +303,7 @@ public func ?? <T> (optional: T?, @autoclosure defaultValue: () throws -> T)
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ?? <T> (optional: T?, @autoclosure defaultValue: () throws -> T?)
|
||||
rethrows -> T? {
|
||||
|
||||
@@ -22,7 +22,7 @@ public protocol _PointerType {
|
||||
}
|
||||
|
||||
/// Derive a pointer argument from a convertible pointer type.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // COMPILER_INTRINSIC
|
||||
func _convertPointerToPointerArgument<
|
||||
@@ -33,7 +33,7 @@ func _convertPointerToPointerArgument<
|
||||
}
|
||||
|
||||
/// Derive a pointer argument from the address of an inout parameter.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // COMPILER_INTRINSIC
|
||||
func _convertInOutToPointerArgument<
|
||||
@@ -43,7 +43,7 @@ func _convertInOutToPointerArgument<
|
||||
}
|
||||
|
||||
/// Derive a pointer argument from an inout array parameter.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // COMPILER_INTRINSIC
|
||||
func _convertMutableArrayToPointerArgument<
|
||||
@@ -61,7 +61,7 @@ func _convertMutableArrayToPointerArgument<
|
||||
}
|
||||
|
||||
/// Derive a pointer argument from a value array parameter.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // COMPILER_INTRINSIC
|
||||
func _convertConstArrayToPointerArgument<
|
||||
@@ -73,7 +73,7 @@ func _convertConstArrayToPointerArgument<
|
||||
}
|
||||
|
||||
/// Derive a UTF-8 pointer argument from a value string parameter.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // COMPILER_INTRINSIC
|
||||
func _convertConstStringToUTF8PointerArgument<
|
||||
|
||||
@@ -335,7 +335,7 @@ public typealias SinkType = _SinkType
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Equatable types can be matched in patterns by value equality.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ~= <T : Equatable> (a: T, b: T) -> Bool {
|
||||
return a == b
|
||||
|
||||
@@ -40,7 +40,7 @@ public enum Process {
|
||||
}
|
||||
|
||||
/// Intrinsic entry point invoked on entry to a standalone program's "main".
|
||||
@_transparent
|
||||
@transparent
|
||||
public // COMPILER_INTRINSIC
|
||||
func _didEnterMain(
|
||||
argc: Int32, argv: UnsafeMutablePointer<UnsafeMutablePointer<Int8>>
|
||||
|
||||
@@ -19,7 +19,7 @@ public struct RangeGenerator<
|
||||
public typealias T = Element
|
||||
|
||||
/// Construct an instance that traverses the elements of `bounds`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(_ bounds: Range<Element>) {
|
||||
self.startIndex = bounds.startIndex
|
||||
self.endIndex = bounds.endIndex
|
||||
@@ -88,7 +88,7 @@ public struct Range<
|
||||
|
||||
/// Construct a range with `startIndex == start` and `endIndex ==
|
||||
/// end`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(start: Element, end: Element) {
|
||||
self.startIndex = start
|
||||
self.endIndex = end
|
||||
@@ -155,7 +155,7 @@ public func == <Element>(lhs: Range<Element>, rhs: Range<Element>) -> Bool {
|
||||
|
||||
/// Forms a half-open range that contains `minimum`, but not
|
||||
/// `maximum`.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ..< <Pos : ForwardIndexType> (minimum: Pos, maximum: Pos)
|
||||
-> Range<Pos> {
|
||||
@@ -163,7 +163,7 @@ public func ..< <Pos : ForwardIndexType> (minimum: Pos, maximum: Pos)
|
||||
}
|
||||
|
||||
/// Forms a closed range that contains both `minimum` and `maximum`.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ... <Pos : ForwardIndexType> (
|
||||
minimum: Pos, maximum: Pos
|
||||
@@ -176,7 +176,7 @@ public func ... <Pos : ForwardIndexType> (
|
||||
/// Forms a half-open range that contains `start`, but not `end`.
|
||||
///
|
||||
/// - Requires: `start <= end`.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ..< <Pos : ForwardIndexType where Pos : Comparable> (
|
||||
start: Pos, end: Pos
|
||||
@@ -187,7 +187,7 @@ public func ..< <Pos : ForwardIndexType where Pos : Comparable> (
|
||||
|
||||
/// Forms a closed range that contains both `start` and `end`.
|
||||
/// - Requires: `start <= end`.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ... <Pos : ForwardIndexType where Pos : Comparable> (
|
||||
start: Pos, end: Pos
|
||||
|
||||
@@ -20,7 +20,7 @@ import SwiftShims
|
||||
// Atomics
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _stdlib_atomicCompareExchangeStrongPtrImpl(
|
||||
@@ -61,7 +61,7 @@ func _stdlib_atomicCompareExchangeStrongPtrImpl(
|
||||
/// If the conditions above are not met, the code will still compile, but the
|
||||
/// compare-and-exchange instruction will operate on the writeback buffer, and
|
||||
/// you will get a *race* while doing writeback into shared memory.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _stdlib_atomicCompareExchangeStrongPtr<T>(
|
||||
@@ -74,7 +74,7 @@ func _stdlib_atomicCompareExchangeStrongPtr<T>(
|
||||
desired: COpaquePointer(desired))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public // @testable
|
||||
func _stdlib_atomicInitializeARCRef(
|
||||
object target: UnsafeMutablePointer<AnyObject?>,
|
||||
@@ -96,7 +96,7 @@ func _stdlib_atomicInitializeARCRef(
|
||||
% for bits in [ 32, 64 ]:
|
||||
|
||||
@warn_unused_result
|
||||
@_transparent
|
||||
@transparent
|
||||
public // @testable
|
||||
func _stdlib_atomicCompareExchangeStrongUInt${bits}(
|
||||
object target: UnsafeMutablePointer<UInt${bits}>,
|
||||
@@ -110,7 +110,7 @@ func _stdlib_atomicCompareExchangeStrongUInt${bits}(
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
@_transparent
|
||||
@transparent
|
||||
public // @testable
|
||||
func _stdlib_atomicCompareExchangeStrongInt${bits}(
|
||||
object target: UnsafeMutablePointer<Int${bits}>,
|
||||
@@ -122,7 +122,7 @@ func _stdlib_atomicCompareExchangeStrongInt${bits}(
|
||||
desired: UInt${bits}(bitPattern: desired))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public // @testable
|
||||
func _swift_stdlib_atomicStoreUInt${bits}(
|
||||
object target: UnsafeMutablePointer<UInt${bits}>,
|
||||
@@ -158,7 +158,7 @@ func _swift_stdlib_atomicLoadInt${bits}(
|
||||
|
||||
% for operation in [ 'Add', 'And', 'Or', 'Xor' ]:
|
||||
// Warning: no overflow checking.
|
||||
@_transparent
|
||||
@transparent
|
||||
public // @testable
|
||||
func _swift_stdlib_atomicFetch${operation}UInt${bits}(
|
||||
object target: UnsafeMutablePointer<UInt${bits}>,
|
||||
@@ -216,7 +216,7 @@ func _swift_stdlib_atomicStoreInt(
|
||||
#endif
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func _swift_stdlib_atomicLoadInt(
|
||||
object target: UnsafeMutablePointer<Int>) -> Int {
|
||||
@@ -232,7 +232,7 @@ public func _swift_stdlib_atomicLoadInt(
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
@_transparent
|
||||
@transparent
|
||||
public // @testable
|
||||
func _swift_stdlib_atomicLoadPtrImpl(
|
||||
object target: UnsafeMutablePointer<COpaquePointer>
|
||||
@@ -241,7 +241,7 @@ func _swift_stdlib_atomicLoadPtrImpl(
|
||||
return COpaquePointer(value)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public // @testable
|
||||
func _stdlib_atomicLoadARCRef(
|
||||
|
||||
@@ -59,7 +59,7 @@ public struct StaticString
|
||||
///
|
||||
/// - Requires: `self` stores a pointer to either ASCII or UTF-8 code
|
||||
/// units.
|
||||
@_transparent
|
||||
@transparent
|
||||
public var utf8Start: UnsafePointer<UInt8> {
|
||||
_precondition(
|
||||
hasPointerRepresentation,
|
||||
@@ -70,7 +70,7 @@ public struct StaticString
|
||||
/// The stored Unicode scalar value.
|
||||
///
|
||||
/// - Requires: `self` stores a single Unicode scalar value.
|
||||
@_transparent
|
||||
@transparent
|
||||
public var unicodeScalar: UnicodeScalar {
|
||||
_precondition(
|
||||
!hasPointerRepresentation,
|
||||
@@ -83,7 +83,7 @@ public struct StaticString
|
||||
///
|
||||
/// If `self` stores a single Unicode scalar value, the value of
|
||||
/// `byteSize` is unspecified.
|
||||
@_transparent
|
||||
@transparent
|
||||
public var byteSize: Int {
|
||||
_precondition(
|
||||
hasPointerRepresentation,
|
||||
@@ -92,7 +92,7 @@ public struct StaticString
|
||||
}
|
||||
|
||||
/// `true` iff `self` stores a pointer to ASCII or UTF-8 code units.
|
||||
@_transparent
|
||||
@transparent
|
||||
public var hasPointerRepresentation: Bool {
|
||||
return (UInt8(_flags) & 0x1) == 0
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public struct StaticString
|
||||
///
|
||||
/// If `self` stores a single Unicode scalar value, the value of
|
||||
/// `isASCII` is unspecified.
|
||||
@_transparent
|
||||
@transparent
|
||||
public var isASCII: Bool {
|
||||
return (UInt8(_flags) & 0x2) != 0
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public struct StaticString
|
||||
|
||||
/// Return a `String` representing the same sequence of Unicode
|
||||
/// scalar values as `self` does.
|
||||
@_transparent
|
||||
@transparent
|
||||
public var stringValue: String {
|
||||
return withUTF8Buffer {
|
||||
(buffer) in
|
||||
@@ -139,12 +139,12 @@ public struct StaticString
|
||||
}
|
||||
|
||||
/// Create an empty instance.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init() {
|
||||
self = ""
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal init(
|
||||
start: Builtin.RawPointer, byteSize: Builtin.Word, isASCII: Builtin.Int1
|
||||
) {
|
||||
@@ -153,7 +153,7 @@ public struct StaticString
|
||||
self._flags = Bool(isASCII) ? (0x2 as UInt8)._value : (0x0 as UInt8)._value
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal init(
|
||||
unicodeScalar: Builtin.Int32
|
||||
) {
|
||||
@@ -166,20 +166,20 @@ public struct StaticString
|
||||
}
|
||||
|
||||
@effects(readonly)
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(_builtinUnicodeScalarLiteral value: Builtin.Int32) {
|
||||
self = StaticString(unicodeScalar: value)
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@effects(readonly)
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(unicodeScalarLiteral value: StaticString) {
|
||||
self = value
|
||||
}
|
||||
|
||||
@effects(readonly)
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(
|
||||
_builtinExtendedGraphemeClusterLiteral start: Builtin.RawPointer,
|
||||
byteSize: Builtin.Word,
|
||||
@@ -194,13 +194,13 @@ public struct StaticString
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@effects(readonly)
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(extendedGraphemeClusterLiteral value: StaticString) {
|
||||
self = value
|
||||
}
|
||||
|
||||
@effects(readonly)
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(
|
||||
_builtinStringLiteral start: Builtin.RawPointer,
|
||||
byteSize: Builtin.Word,
|
||||
@@ -211,7 +211,7 @@ public struct StaticString
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@effects(readonly)
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(stringLiteral value: StaticString) {
|
||||
self = value
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@ import SwiftShims
|
||||
|
||||
/// Returns `true` iff the given `index` is valid as a position, i.e. `0
|
||||
/// ≤ index ≤ count`.
|
||||
@_transparent
|
||||
@transparent
|
||||
internal func _isValidArrayIndex(index: Int, _ count: Int) -> Bool {
|
||||
return (index >= 0) && (index <= count)
|
||||
}
|
||||
|
||||
/// Returns `true` iff the given `index` is valid for subscripting, i.e.
|
||||
/// `0 ≤ index < count`.
|
||||
@_transparent
|
||||
@transparent
|
||||
internal func _isValidArraySubscript(index: Int, _ count: Int) -> Bool {
|
||||
return (index >= 0) && (index < count)
|
||||
}
|
||||
|
||||
@@ -26,13 +26,13 @@ public struct UnicodeScalar :
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(_builtinUnicodeScalarLiteral value: Builtin.Int32) {
|
||||
self._value = UInt32(value)
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(unicodeScalarLiteral value: UnicodeScalar) {
|
||||
self = value
|
||||
}
|
||||
|
||||
@@ -140,31 +140,31 @@ struct _UnicodeGraphemeClusterBreakPropertyTrie {
|
||||
let _trieData: UnsafePointer<UInt8>
|
||||
|
||||
% if BMPLookupBytesPerEntry == 1:
|
||||
@_transparent var _BMPLookup: UnsafePointer<UInt8> {
|
||||
@transparent var _BMPLookup: UnsafePointer<UInt8> {
|
||||
return _trieData + ${BMPLookupBytesOffset}
|
||||
}
|
||||
% end
|
||||
|
||||
% if BMPDataBytesPerEntry == 1:
|
||||
@_transparent var _BMPData: UnsafePointer<UInt8> {
|
||||
@transparent var _BMPData: UnsafePointer<UInt8> {
|
||||
return _trieData + ${BMPDataBytesOffset}
|
||||
}
|
||||
% end
|
||||
|
||||
% if SuppLookup1BytesPerEntry == 1:
|
||||
@_transparent var _SuppLookup1: UnsafePointer<UInt8> {
|
||||
@transparent var _SuppLookup1: UnsafePointer<UInt8> {
|
||||
return _trieData + ${SuppLookup1BytesOffset}
|
||||
}
|
||||
% end
|
||||
|
||||
% if SuppLookup2BytesPerEntry == 1:
|
||||
@_transparent var _SuppLookup2: UnsafePointer<UInt8> {
|
||||
@transparent var _SuppLookup2: UnsafePointer<UInt8> {
|
||||
return _trieData + ${SuppLookup2BytesOffset}
|
||||
}
|
||||
% end
|
||||
|
||||
% if SuppDataBytesPerEntry == 1:
|
||||
@_transparent var _SuppData: UnsafePointer<UInt8> {
|
||||
@transparent var _SuppData: UnsafePointer<UInt8> {
|
||||
return _trieData + ${SuppDataBytesOffset}
|
||||
}
|
||||
% end
|
||||
@@ -175,32 +175,32 @@ struct _UnicodeGraphemeClusterBreakPropertyTrie {
|
||||
_trieData = _swift_stdlib_GraphemeClusterBreakPropertyTrie
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
func _getBMPFirstLevelIndex(cp: UInt32) -> Int {
|
||||
return Int(cp >> ${BMPFirstLevelIndexBits})
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
func _getBMPDataOffset(cp: UInt32) -> Int {
|
||||
return Int(cp & ((1 << ${BMPDataOffsetBits}) - 1))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
func _getSuppFirstLevelIndex(cp: UInt32) -> Int {
|
||||
return Int(cp >> (${SuppSecondLevelIndexBits} + ${SuppDataOffsetBits}))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
func _getSuppSecondLevelIndex(cp: UInt32) -> Int {
|
||||
return Int((cp >> ${SuppDataOffsetBits}) &
|
||||
((1 << ${SuppSecondLevelIndexBits}) - 1))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
func _getSuppDataOffset(cp: UInt32) -> Int {
|
||||
return Int(cp & ((1 << ${SuppDataOffsetBits}) - 1))
|
||||
|
||||
@@ -20,7 +20,7 @@ public struct Unmanaged<Instance : AnyObject> {
|
||||
|
||||
internal unowned(unsafe) var _value: Instance
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
internal init(_private: Instance) { _value = _private }
|
||||
|
||||
/// Unsafely turn an opaque C pointer into an unmanaged
|
||||
@@ -29,7 +29,7 @@ public struct Unmanaged<Instance : AnyObject> {
|
||||
/// This operation does not change reference counts.
|
||||
///
|
||||
/// let str: CFString = Unmanaged.fromOpaque(ptr).takeUnretainedValue()
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public static func fromOpaque(value: COpaquePointer) -> Unmanaged {
|
||||
// Null pointer check is a debug check, because it guards only against one
|
||||
@@ -47,7 +47,7 @@ public struct Unmanaged<Instance : AnyObject> {
|
||||
/// This operation does not change reference counts.
|
||||
///
|
||||
/// let str: CFString = Unmanaged.fromOpaque(ptr).takeUnretainedValue()
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func toOpaque() -> COpaquePointer {
|
||||
return unsafeBitCast(_value, COpaquePointer.self)
|
||||
@@ -59,7 +59,7 @@ public struct Unmanaged<Instance : AnyObject> {
|
||||
/// This is useful when passing an object to an API which Swift
|
||||
/// does not know the ownership rules for, but you know that the
|
||||
/// API expects you to pass the object at +1.
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public static func passRetained(value: Instance) -> Unmanaged {
|
||||
return Unmanaged(_private: value).retain()
|
||||
@@ -74,7 +74,7 @@ public struct Unmanaged<Instance : AnyObject> {
|
||||
///
|
||||
/// CFArraySetValueAtIndex(.passUnretained(array), i,
|
||||
/// .passUnretained(object))
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public static func passUnretained(value: Instance) -> Unmanaged {
|
||||
return Unmanaged(_private: value)
|
||||
@@ -103,21 +103,21 @@ public struct Unmanaged<Instance : AnyObject> {
|
||||
}
|
||||
|
||||
/// Perform an unbalanced retain of the object.
|
||||
@_transparent
|
||||
@transparent
|
||||
public func retain() -> Unmanaged {
|
||||
Builtin.retain(_value)
|
||||
return self
|
||||
}
|
||||
|
||||
/// Perform an unbalanced release of the object.
|
||||
@_transparent
|
||||
@transparent
|
||||
public func release() {
|
||||
Builtin.release(_value)
|
||||
}
|
||||
|
||||
#if _runtime(_ObjC)
|
||||
/// Perform an unbalanced autorelease of the object.
|
||||
@_transparent
|
||||
@transparent
|
||||
public func autorelease() -> Unmanaged {
|
||||
Builtin.autorelease(_value)
|
||||
return self
|
||||
|
||||
@@ -49,13 +49,13 @@ public struct ${Self}<Memory>
|
||||
public var _rawValue : Builtin.RawPointer
|
||||
|
||||
/// Construct a null pointer.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init() {
|
||||
self._rawValue = _nilRawPointer
|
||||
}
|
||||
|
||||
/// Construct ${a_Self} from a builtin raw pointer.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(_ _rawValue : Builtin.RawPointer) {
|
||||
self._rawValue = _rawValue
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public struct ${Self}<Memory>
|
||||
/// Convert from an opaque C pointer to a typed pointer.
|
||||
///
|
||||
/// This is a fundamentally unsafe conversion.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(_ other : COpaquePointer) {
|
||||
_rawValue = other._rawValue
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public struct ${Self}<Memory>
|
||||
/// Construct ${a_Self} from a given address in memory.
|
||||
///
|
||||
/// This is a fundamentally unsafe conversion.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(bitPattern: Int) {
|
||||
self._rawValue = Builtin.inttoptr_Word(bitPattern._builtinWordValue)
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public struct ${Self}<Memory>
|
||||
/// Construct ${a_Self} from a given address in memory.
|
||||
///
|
||||
/// This is a fundamentally unsafe conversion.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(bitPattern: UInt) {
|
||||
self._rawValue = Builtin.inttoptr_Word(bitPattern._builtinWordValue)
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public struct ${Self}<Memory>
|
||||
/// Convert from an `UnsafeMutablePointer` of a different type.
|
||||
///
|
||||
/// This is a fundamentally unsafe conversion.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init<U>(_ from : UnsafeMutablePointer<U>) {
|
||||
_rawValue = from._rawValue
|
||||
}
|
||||
@@ -95,13 +95,13 @@ public struct ${Self}<Memory>
|
||||
/// Convert from a `UnsafePointer` of a different type.
|
||||
///
|
||||
/// This is a fundamentally unsafe conversion.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init<U>(_ from : UnsafePointer<U>) {
|
||||
_rawValue = from._rawValue
|
||||
}
|
||||
|
||||
/// Create an instance initialized with `nil`.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init(nilLiteral: ()) {
|
||||
self = ${Self}()
|
||||
}
|
||||
@@ -145,14 +145,14 @@ else:
|
||||
${comment}
|
||||
public var memory: Memory {
|
||||
% if mutable:
|
||||
@_transparent unsafeAddress {
|
||||
@transparent unsafeAddress {
|
||||
return UnsafePointer(self)
|
||||
}
|
||||
@_transparent nonmutating unsafeMutableAddress {
|
||||
@transparent nonmutating unsafeMutableAddress {
|
||||
return self
|
||||
}
|
||||
% else:
|
||||
@_transparent unsafeAddress {
|
||||
@transparent unsafeAddress {
|
||||
return self
|
||||
}
|
||||
% end
|
||||
@@ -321,7 +321,7 @@ ${comment}
|
||||
}
|
||||
% end
|
||||
|
||||
@_transparent public
|
||||
@transparent public
|
||||
var _isNull : Bool {
|
||||
return self == nil
|
||||
}
|
||||
@@ -329,16 +329,16 @@ ${comment}
|
||||
/// Access the `i`th element of the raw array starting at `self`.
|
||||
public subscript(i: Int) -> Memory {
|
||||
% if mutable:
|
||||
@_transparent
|
||||
@transparent
|
||||
unsafeAddress {
|
||||
return UnsafePointer(self + i)
|
||||
}
|
||||
@_transparent
|
||||
@transparent
|
||||
nonmutating unsafeMutableAddress {
|
||||
return self + i
|
||||
}
|
||||
% else:
|
||||
@_transparent
|
||||
@transparent
|
||||
unsafeAddress {
|
||||
return self + i
|
||||
}
|
||||
@@ -359,7 +359,7 @@ ${comment}
|
||||
/// Return the result of invoking body. If self was converted from
|
||||
/// nil, passes nil as the argument. Otherwise, passes the address
|
||||
/// of a `Memory` which is written into buffer before this method returns.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
func _withBridgeObject<U : AnyObject, R>(
|
||||
inout buffer: U?, @noescape body: AutoreleasingUnsafeMutablePointer<U?> -> R
|
||||
) -> R {
|
||||
@@ -370,7 +370,7 @@ ${comment}
|
||||
/// Return the result of invoking body. If self was converted from
|
||||
/// `nil`, passes `nil` as the argument. Otherwise, passes the address
|
||||
/// of buffer.
|
||||
@_transparent public
|
||||
@transparent public
|
||||
func _withBridgeValue<U, R>(
|
||||
inout buffer: U, @noescape body: UnsafeMutablePointer<U> -> R
|
||||
) -> R {
|
||||
@@ -449,7 +449,7 @@ ${MirrorDecl} {
|
||||
|
||||
${MirrorConformance}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func == <Memory>(
|
||||
lhs: ${Self}<Memory>, rhs: ${Self}<Memory>
|
||||
@@ -457,33 +457,33 @@ public func == <Memory>(
|
||||
return Bool(Builtin.cmp_eq_RawPointer(lhs._rawValue, rhs._rawValue))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func < <Memory>(lhs: ${Self}<Memory>, rhs: ${Self}<Memory>) -> Bool {
|
||||
return Bool(Builtin.cmp_ult_RawPointer(lhs._rawValue, rhs._rawValue))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func + <Memory>(lhs: ${Self}<Memory>, rhs: Int) -> ${Self}<Memory> {
|
||||
return ${Self}(Builtin.gep_Word(
|
||||
lhs._rawValue, (rhs &* strideof(Memory.self))._builtinWordValue))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func + <Memory>(lhs: Int,
|
||||
rhs: ${Self}<Memory>) -> ${Self}<Memory> {
|
||||
return rhs + lhs
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func - <Memory>(lhs: ${Self}<Memory>, rhs: Int) -> ${Self}<Memory> {
|
||||
return lhs + -rhs
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func - <Memory>(lhs: ${Self}<Memory>, rhs: ${Self}<Memory>) -> Int {
|
||||
return
|
||||
@@ -492,12 +492,12 @@ public func - <Memory>(lhs: ${Self}<Memory>, rhs: ${Self}<Memory>) -> Int {
|
||||
/ strideof(Memory.self)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func += <Memory>(inout lhs: ${Self}<Memory>, rhs: Int) {
|
||||
lhs = lhs + rhs
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func -= <Memory>(inout lhs: ${Self}<Memory>, rhs: Int) {
|
||||
lhs = lhs - rhs
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@_transparent public func maybeTrans(i: Int16) {}
|
||||
@transparent public func maybeTrans(i: Int16) {}
|
||||
public func maybeTrans(i: Int32) {}
|
||||
|
||||
@@ -160,7 +160,7 @@ public let doubleClosure: () -> () = {
|
||||
singleClosure()
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func transparentFunc() {
|
||||
// CHECK-DAG: VF10LocalTypes15transparentFuncFT_T_L_21TransparentFuncStruct
|
||||
struct TransparentFuncStruct {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@_transparent public func test() {
|
||||
@transparent public func test() {
|
||||
struct S { var x: Int }
|
||||
print(S.self)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public struct DarwinBoolean : BooleanType, BooleanLiteralConvertible {
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(booleanLiteral value: Bool) {
|
||||
self.init(value)
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public struct Selector : StringLiteralConvertible {
|
||||
public struct NSZone: NilLiteralConvertible {
|
||||
public var pointer : COpaquePointer
|
||||
|
||||
@_transparent public
|
||||
@transparent public
|
||||
init(nilLiteral: ()) {
|
||||
pointer = COpaquePointer()
|
||||
}
|
||||
|
||||
@@ -73,12 +73,12 @@ maskingShifts = [
|
||||
//===--- Bits for the Stdlib ----------------------------------------------===//
|
||||
|
||||
extension Bool {
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(_ value: Builtin.Int1) {
|
||||
self.init(_builtinBooleanLiteral: value)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public var _value: Builtin.Int1 {
|
||||
return Builtin.trunc_Int${word_bits}_Int1((self ? 1 : 0)._value)
|
||||
}
|
||||
@@ -88,7 +88,7 @@ extension Bool {
|
||||
extension IntegerLiteralConvertible
|
||||
where Self : _BuiltinIntegerLiteralConvertible {
|
||||
/// Create an instance initialized to `value`.
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(integerLiteral value: Self) {
|
||||
self = value
|
||||
}
|
||||
@@ -107,7 +107,7 @@ infix operator |% { associativity left precedence 150 }
|
||||
infix operator |+ { associativity left precedence 140 }
|
||||
infix operator |- { associativity left precedence 140 }
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func _assertCond(
|
||||
@autoclosure condition: () -> Bool,
|
||||
@autoclosure _ message: ()->String,
|
||||
@@ -145,7 +145,7 @@ public protocol ArithmeticType {
|
||||
}
|
||||
|
||||
% for x in binaryArithmetic:
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func ${x.operator} <T: ArithmeticType>(lhs: T, rhs: T) -> T {
|
||||
var lhs = lhs
|
||||
@@ -153,13 +153,13 @@ public func ${x.operator} <T: ArithmeticType>(lhs: T, rhs: T) -> T {
|
||||
return lhs
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${x.operator}= <T: ArithmeticType>(inout lhs: T, rhs: T) {
|
||||
lhs.${x.name}InPlace(rhs)
|
||||
}
|
||||
% end
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public prefix func -<T: ArithmeticType>(x: T) -> T {
|
||||
return T() - x
|
||||
@@ -213,20 +213,20 @@ public protocol IntegerType
|
||||
}
|
||||
|
||||
//===--- Homogeneous comparison -------------------------------------------===//
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func == <T : IntegerType>(lhs:T, rhs: T) -> Bool {
|
||||
return lhs.isEqualTo(rhs)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func < <T : IntegerType>(lhs: T, rhs: T) -> Bool {
|
||||
return lhs.isLessThan(rhs)
|
||||
}
|
||||
|
||||
//===--- Heterogeneous comparison -----------------------------------------===//
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func == <T : IntegerType, U : IntegerType>(lhs:T, rhs: U) -> Bool {
|
||||
return (lhs > 0) == (rhs > 0)
|
||||
@@ -234,13 +234,13 @@ public func == <T : IntegerType, U : IntegerType>(lhs:T, rhs: U) -> Bool {
|
||||
&& U(extendingOrTruncating: lhs) == rhs
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func != <T : IntegerType, U : IntegerType>(lhs:T, rhs: U) -> Bool {
|
||||
return !(lhs == rhs)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func < <T : IntegerType, U : IntegerType>(lhs: T, rhs: U) -> Bool {
|
||||
let lhsSign = lhs < 0 ? -1 : lhs > 0 ? 1 : 0
|
||||
@@ -355,12 +355,12 @@ ${comment}
|
||||
|
||||
% for x in binaryBitwise:
|
||||
@warn_unused_result
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${x.operator} <T: FixedWidthIntegerType>(lhs: T, rhs: T) -> T {
|
||||
return lhs.${x.name}(rhs)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${x.operator}= <T: FixedWidthIntegerType>(inout lhs: T, rhs: T) {
|
||||
lhs = lhs.${x.name}(rhs)
|
||||
}
|
||||
@@ -368,25 +368,25 @@ public func ${x.operator}= <T: FixedWidthIntegerType>(inout lhs: T, rhs: T) {
|
||||
|
||||
% for x in maskingShifts:
|
||||
@warn_unused_result
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${x.operator} <T: FixedWidthIntegerType>(lhs: T, rhs: T) -> T {
|
||||
return lhs.${x.name}(rhs)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${x.operator}= <T: FixedWidthIntegerType>(inout lhs: T, rhs: T) {
|
||||
lhs = lhs ${x.operator} rhs
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${x.operator} <
|
||||
T: FixedWidthIntegerType, U: IntegerType
|
||||
>(lhs: T, rhs: U) -> T {
|
||||
return lhs.${x.name}(T(extendingOrTruncating: rhs))
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${x.operator}= <
|
||||
T: FixedWidthIntegerType, U: IntegerType
|
||||
>(inout lhs: T, rhs: U) {
|
||||
@@ -394,7 +394,7 @@ public func ${x.operator}= <
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${x.nonMaskingOperator} <
|
||||
T: FixedWidthIntegerType, U: IntegerType
|
||||
>(lhs: T, rhs: U) -> T {
|
||||
@@ -407,7 +407,7 @@ public func ${x.nonMaskingOperator} <
|
||||
// "Smart shift", supporting overshifts and negative shifts
|
||||
|
||||
@warn_unused_result
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${x.nonMaskingOperator} <
|
||||
T: FixedWidthIntegerType
|
||||
>(lhs: T, rhs: Word) -> T {
|
||||
@@ -426,14 +426,14 @@ public func ${x.nonMaskingOperator} <
|
||||
return lhs ${x.operator.translate(maketrans('<>', '><'))} -rhs
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${x.nonMaskingOperator}= <
|
||||
T: FixedWidthIntegerType
|
||||
>(inout lhs: T, rhs: T) {
|
||||
lhs = lhs ${x.nonMaskingOperator} rhs
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${x.nonMaskingOperator}= <
|
||||
T: FixedWidthIntegerType, U: IntegerType
|
||||
>(inout lhs: T, rhs: U) {
|
||||
@@ -459,7 +459,7 @@ extension FixedWidthIntegerType {
|
||||
}
|
||||
|
||||
% for x in binaryArithmetic:
|
||||
@_transparent
|
||||
@transparent
|
||||
public mutating func ${x.name}InPlace(rhs: Self) {
|
||||
let (result, overflow) = self.${x.name}WithOverflow(rhs)
|
||||
_assertCond(overflow == .None, "overflow in ${x.name}")
|
||||
@@ -472,7 +472,7 @@ extension FixedWidthIntegerType {
|
||||
/// Note: use this function to avoid the cost of overflow checking
|
||||
/// when you are sure that the operation won't overflow.
|
||||
@warn_unused_result
|
||||
@_transparent
|
||||
@transparent
|
||||
public func unsafe${capitalize(x.name)}(rhs: Self) -> Self {
|
||||
let (result, overflow) = self.${x.name}WithOverflow(rhs)
|
||||
|
||||
@@ -488,12 +488,12 @@ extension FixedWidthIntegerType {
|
||||
}
|
||||
% end
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public init() {
|
||||
self = 0
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public init<T : IntegerType>(extendingOrTruncating source: T) {
|
||||
if Self.bitWidth <= ${word_bits} {
|
||||
self = Self.init(_truncatingBits: source.word(0))
|
||||
@@ -515,7 +515,7 @@ extension FixedWidthIntegerType {
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func word(n: Word) -> Word {
|
||||
var n = n
|
||||
_precondition(n >= 0, "Negative word index")
|
||||
@@ -531,7 +531,7 @@ extension FixedWidthIntegerType {
|
||||
return x._lowWord
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public // transparent
|
||||
static var _highBitIndex: Self {
|
||||
return Self.init(_truncatingBits: Self.bitWidth - 1)
|
||||
@@ -575,7 +575,7 @@ extension UnsignedIntegerType {
|
||||
}
|
||||
|
||||
extension UnsignedIntegerType where Self : FixedWidthIntegerType {
|
||||
@_transparent
|
||||
@transparent
|
||||
public init<T : IntegerType>(_ source: T) {
|
||||
_assertCond(
|
||||
source >= 0, "negative value \(source) not representable by \(Self.self)")
|
||||
@@ -587,17 +587,17 @@ extension UnsignedIntegerType where Self : FixedWidthIntegerType {
|
||||
self.init(extendingOrTruncating: source)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public static var max: Self {
|
||||
return ~0
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public static var min: Self {
|
||||
return 0
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public var mostSignificantBit: Word {
|
||||
return Self.bitWidth - 1 - self.countLeadingZeros()
|
||||
}
|
||||
@@ -620,7 +620,7 @@ extension SignedIntegerType {
|
||||
}
|
||||
|
||||
extension SignedIntegerType where Self : FixedWidthIntegerType {
|
||||
@_transparent
|
||||
@transparent
|
||||
public init<T : IntegerType>(_ source: T) {
|
||||
let requiredBits = source.mostSignificantBit + (source >= 0 ? 2 : 1)
|
||||
_assertCond(
|
||||
@@ -630,17 +630,17 @@ extension SignedIntegerType where Self : FixedWidthIntegerType {
|
||||
self.init(extendingOrTruncating: source)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public static var max: Self {
|
||||
return ~min
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public static var min: Self {
|
||||
return -1 &<< Self._highBitIndex
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public var mostSignificantBit: Word {
|
||||
let x = self < 0 ? ~self : self
|
||||
return Self.bitWidth - 1 - x.countLeadingZeros()
|
||||
@@ -687,7 +687,7 @@ public struct ${Self}
|
||||
= ${'' if signed else 'U'}Int${max(bits, otherBits)}
|
||||
% end
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(_builtinIntegerLiteral x: _MaxBuiltinIntegerType) {
|
||||
_storage = Builtin.truncOrBitCast_${IntLiteral}_Int${bits}(x)
|
||||
Builtin.condfail(
|
||||
@@ -711,7 +711,7 @@ public struct ${Self}
|
||||
/// truncated to fit if necessary, and a flag indicating whether an
|
||||
/// arithmetic overflow occurred.
|
||||
@warn_unused_result
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${x.name}WithOverflow(
|
||||
rhs: ${Self}
|
||||
) -> (partialValue: ${Self}, overflow: ArithmeticOverflow) {
|
||||
@@ -743,14 +743,14 @@ public struct ${Self}
|
||||
}
|
||||
% end
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public init(_ _storage: Builtin.Int${bits}) {
|
||||
self._storage = _storage
|
||||
}
|
||||
|
||||
% for x in binaryBitwise:
|
||||
@warn_unused_result
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${x.name}(rhs: ${Self}) -> ${Self} {
|
||||
return ${Self}(
|
||||
Builtin.${x.name}_Int${bits}(self._storage, rhs._storage))
|
||||
@@ -759,7 +759,7 @@ public struct ${Self}
|
||||
|
||||
% for x in maskingShifts:
|
||||
@warn_unused_result
|
||||
@_transparent
|
||||
@transparent
|
||||
public func ${x.name}(rhs: ${Self}) -> ${Self} {
|
||||
let rhs_ = rhs & ${Self}._highBitIndex
|
||||
return ${Self}(
|
||||
@@ -767,17 +767,17 @@ public struct ${Self}
|
||||
}
|
||||
% end
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public static var bitWidth : Word { return ${bits} }
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
@warn_unused_result
|
||||
public func countLeadingZeros() -> Word {
|
||||
return ${Self}(
|
||||
Builtin.int_ctlz_Int${bits}(self._storage, false._value))._lowWord
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public // transparent
|
||||
var _lowWord: Word {
|
||||
% truncOrExt = z + 'ext' if bits <= word_bits else 'trunc'
|
||||
@@ -786,7 +786,7 @@ public struct ${Self}
|
||||
)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public // transparent
|
||||
var _lowUnsignedWord: Word {
|
||||
% truncOrExt = z + 'ext' if bits <= word_bits else 'trunc'
|
||||
@@ -795,7 +795,7 @@ public struct ${Self}
|
||||
)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public // transparent
|
||||
init(_truncatingBits bits: Word) {
|
||||
% truncOrExt = 'zext' if bits > word_bits else 'trunc'
|
||||
@@ -804,7 +804,7 @@ public struct ${Self}
|
||||
}
|
||||
|
||||
% if signed:
|
||||
@_transparent
|
||||
@transparent
|
||||
public var absoluteValue: U${Self} {
|
||||
let base = U${Self}(_storage)
|
||||
return self < 0 ? ~base + 1 : base
|
||||
|
||||
@@ -509,7 +509,7 @@ func return_generic_tuple()
|
||||
func testNoReturnAttrParam(fptr: @noreturn ()->()) -> () {}
|
||||
|
||||
// CHECK-LABEL: sil hidden [transparent] @_TF9functions15testTransparent{{.*}} : $@convention(thin) (Builtin.Int1) -> Builtin.Int1
|
||||
@_transparent func testTransparent(x: Bool) -> Bool {
|
||||
@transparent func testTransparent(x: Bool) -> Bool {
|
||||
return x
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Test if 'transparent' atribute gets propagated correctly to apply instructions.
|
||||
|
||||
// Test that the attribute gets set on default argument generators.
|
||||
@_transparent func transparentFuncWithDefaultArgument (x: Int = 1) -> Int {
|
||||
@transparent func transparentFuncWithDefaultArgument (x: Int = 1) -> Int {
|
||||
return x
|
||||
}
|
||||
func useTransparentFuncWithDefaultArgument() ->Int {
|
||||
@@ -32,7 +32,7 @@ func useTransparentFuncWithoutDefaultArgument() -> Int {
|
||||
|
||||
// Make sure the transparent attribute is set on constructors (allocating and initializing).
|
||||
struct StructWithTranspConstructor {
|
||||
@_transparent init () {}
|
||||
@transparent init () {}
|
||||
}
|
||||
func testStructWithTranspConstructor() -> StructWithTranspConstructor {
|
||||
return StructWithTranspConstructor()
|
||||
@@ -49,21 +49,21 @@ func testStructWithTranspConstructor() -> StructWithTranspConstructor {
|
||||
struct MySt {}
|
||||
var _x = MySt()
|
||||
var x1 : MySt {
|
||||
@_transparent
|
||||
@transparent
|
||||
get {
|
||||
return _x
|
||||
}
|
||||
@_transparent
|
||||
@transparent
|
||||
set {
|
||||
_x = newValue
|
||||
}
|
||||
}
|
||||
var x2 : MySt {
|
||||
@_transparent
|
||||
@transparent
|
||||
set(v) {
|
||||
_x = v
|
||||
}
|
||||
@_transparent
|
||||
@transparent
|
||||
get {
|
||||
return _x
|
||||
}
|
||||
@@ -87,7 +87,7 @@ func testProperty(z: MySt) {
|
||||
var _tr2 = MySt()
|
||||
var _tr3 = MySt()
|
||||
struct MyTranspStruct {}
|
||||
@_transparent extension MyTranspStruct {
|
||||
@transparent extension MyTranspStruct {
|
||||
init(input : MySt) {}
|
||||
mutating
|
||||
func tr1() {}
|
||||
@@ -102,7 +102,7 @@ struct MyTranspStruct {}
|
||||
}
|
||||
|
||||
extension MyTranspStruct {
|
||||
@_transparent
|
||||
@transparent
|
||||
var tr3: MySt {
|
||||
get {
|
||||
return _tr3
|
||||
@@ -134,7 +134,7 @@ enum MyEnum {
|
||||
case twotransp
|
||||
}
|
||||
|
||||
@_transparent extension MyEnum {
|
||||
@transparent extension MyEnum {
|
||||
func tr3() {}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ func testEnumExtension() {
|
||||
}
|
||||
|
||||
struct testVarDecl {
|
||||
@_transparent var max: Int {
|
||||
@transparent var max: Int {
|
||||
get {
|
||||
return 0xFF
|
||||
}
|
||||
@@ -166,7 +166,7 @@ struct testVarDecl {
|
||||
}
|
||||
|
||||
struct testVarDeclShortenedSyntax {
|
||||
@_transparent static var max: Int { return 0xFF };
|
||||
@transparent static var max: Int { return 0xFF };
|
||||
func testVarDeclShortenedSyntaxfoo () {
|
||||
var z: Int = testVarDeclShortenedSyntax.max
|
||||
// CHECK-APPLY: sil hidden @_TFV21transparent_attribute26testVarDeclShortenedSyntax29testVarDeclShortenedSyntaxfoo
|
||||
@@ -175,7 +175,7 @@ struct testVarDeclShortenedSyntax {
|
||||
}
|
||||
};
|
||||
|
||||
@_transparent var transparentOnGlobalVar: Int {
|
||||
@transparent var transparentOnGlobalVar: Int {
|
||||
get {
|
||||
return 0xFF
|
||||
}
|
||||
@@ -183,7 +183,7 @@ struct testVarDeclShortenedSyntax {
|
||||
// CHECK: sil hidden [transparent] @_TF21transparent_attributeg22transparentOnGlobalVarSi
|
||||
|
||||
// Local functions in transparent context have public linkage.
|
||||
@_transparent func foo() {
|
||||
@transparent func foo() {
|
||||
// CHECK-LABEL: sil @_TFF21transparent_attribute3fooFT_T_L_3barFT_T_ : $@convention(thin) () -> ()
|
||||
func bar() {}
|
||||
bar()
|
||||
|
||||
@@ -15,7 +15,7 @@ public struct MyStruct : Proto {
|
||||
private func callit(p: Proto) {
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func testit(n: MyStruct) {
|
||||
callit(n)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ class InternalClass {
|
||||
return InternalClass()
|
||||
}
|
||||
|
||||
@_transparent func invokeFoo(obj: InternalClass) {
|
||||
@transparent func invokeFoo(obj: InternalClass) {
|
||||
obj.foo()
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ public func getExternalClass() -> ExternalClass {
|
||||
return ExternalClass()
|
||||
}
|
||||
|
||||
// Note: This will eventually be illegal (to have a public @_transparent function
|
||||
// Note: This will eventually be illegal (to have a public @transparent function
|
||||
// referring to a private method), but for now it lets us test what can and
|
||||
// can't be optimized.
|
||||
@_transparent public func invokeFoo(obj: ExternalClass) {
|
||||
@transparent public func invokeFoo(obj: ExternalClass) {
|
||||
obj.foo()
|
||||
}
|
||||
|
||||
|
||||
@@ -731,7 +731,7 @@ extension r17233681Lazy {
|
||||
}
|
||||
|
||||
|
||||
// <rdar://problem/17556858> delegating init that delegates to @_transparent init fails
|
||||
// <rdar://problem/17556858> delegating init that delegates to @transparent init fails
|
||||
struct FortyTwo { }
|
||||
|
||||
extension Double {
|
||||
@@ -1041,7 +1041,7 @@ struct StructMutatingMethodTest {
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
func myTransparentFunction(inout x : Int) {}
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public func getExternalClass() -> ExternalClass {
|
||||
return ExternalClass()
|
||||
}
|
||||
|
||||
// Note: This will eventually be illegal (to have a public @_transparent function
|
||||
// Note: This will eventually be illegal (to have a public @transparent function
|
||||
// referring to a private method), but for now it lets us test what can and
|
||||
// can't be optimized.
|
||||
// CHECK-LABEL: sil [transparent] [fragile] @_TF26devirt_access_other_module9invokeFooFCS_13ExternalClassT_
|
||||
@@ -27,7 +27,7 @@ public func getExternalClass() -> ExternalClass {
|
||||
// CHECK-NOT: checked_cast_br
|
||||
// CHECK-NOT: bb1
|
||||
// CHECK: return
|
||||
@_transparent public func invokeFoo(obj: ExternalClass) {
|
||||
@transparent public func invokeFoo(obj: ExternalClass) {
|
||||
obj.foo()
|
||||
}
|
||||
|
||||
|
||||
@@ -21,17 +21,17 @@ public class C : Foo {
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
func callfoo(f: Foo)->Int {
|
||||
return f.foo(2) + f.foo(2)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
func callboo(f: Foo)->Int32 {
|
||||
return f.boo(2) + f.boo(2)
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
func callGetSelf(f: Foo)->Foo {
|
||||
return f.getSelf()
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@ func testArithmeticOverflow() {
|
||||
// var csh2: Int8 = (-1 & ~(1<<7))+1 // expected - error {{arithmetic operation '127 + 1' (on type 'Int8') results in an overflow}}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
func myaddSigned(x: Int8, _ y: Int8, _ z: Int8) -> Int8 {
|
||||
return x + y
|
||||
}
|
||||
@_transparent
|
||||
@transparent
|
||||
func myaddUnsigned(x: UInt8, _ y: UInt8, _ z: UInt8) -> UInt8 {
|
||||
return x + y
|
||||
}
|
||||
@@ -207,11 +207,11 @@ func testConvertOverflow() {
|
||||
var _/*float64_min_definitely_overflow*/ : Float64 = (-179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216) // expected-error {{integer literal '-179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216' overflows when stored into 'Double'}}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
func intConversionWrapperForUSCheckedConversion(x: UInt8, _ unused: UInt8) -> Int8 {
|
||||
return Int8(x)
|
||||
}
|
||||
@_transparent
|
||||
@transparent
|
||||
func intConversionWrapperForLiteral() -> Int8 {
|
||||
return 255 // expected-error {{integer literal '255' overflows when stored into 'Int8'}}
|
||||
}
|
||||
@@ -376,23 +376,23 @@ func testAssumeNonNegative() {
|
||||
protocol Num { func Double() -> Self }
|
||||
|
||||
extension Int8 : Num {
|
||||
@_transparent
|
||||
@transparent
|
||||
func Double() -> Int8 { return self * 2 }
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
func Double<T : Num>(x: T) -> T { return x.Double() }
|
||||
|
||||
func tryDouble() -> Int8 {
|
||||
return Double(Int8.max) // expected-error {{arithmetic operation '127 * 2' (on signed 8-bit integer type) results in an overflow}}
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
func add<T : SignedIntegerType>(left: T, _ right: T) -> T {
|
||||
return left + right
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
func applyBinary<T : SignedIntegerType>(fn: (T, T)->(T), _ left: T, _ right: T) -> T {
|
||||
return fn(left, right)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ func foo(x: Float) -> Float {
|
||||
// CHECK-NEXT: debug_value %0 : $Float // let x
|
||||
// CHECK-NEXT: return %0
|
||||
|
||||
@_transparent func bar(x: Float) -> Float {
|
||||
@transparent func bar(x: Float) -> Float {
|
||||
return baz(x)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ func foo(x: Float) -> Float {
|
||||
// CHECK-NOT: apply
|
||||
// CHECK: return
|
||||
|
||||
@_transparent func baz(x: Float) -> Float {
|
||||
@transparent func baz(x: Float) -> Float {
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func spam(x: Int) -> Int {
|
||||
|
||||
// CHECK-LABEL: sil hidden @_TF18mandatory_inlining4spam
|
||||
|
||||
@_transparent func ham(x: Int) -> Int {
|
||||
@transparent func ham(x: Int) -> Int {
|
||||
return spam(x)
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func eggs(x: Int) -> Int {
|
||||
// CHECK: apply
|
||||
// CHECK: return
|
||||
|
||||
@_transparent func call_auto_closure(@autoclosure x: () -> Bool) -> Bool {
|
||||
@transparent func call_auto_closure(@autoclosure x: () -> Bool) -> Bool {
|
||||
return x()
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ func test_auto_closure_without_capture() -> Bool {
|
||||
// CHECK: [[FALSE:%.*]] = struct $Bool ([[FV:%.*]] : $Builtin.Int1)
|
||||
// CHECK: return [[FALSE]]
|
||||
|
||||
@_transparent func test_curried(x: Int)(y: Int) -> Int { // expected-warning{{curried function declaration syntax will be removed in a future version of Swift}}
|
||||
@transparent func test_curried(x: Int)(y: Int) -> Int { // expected-warning{{curried function declaration syntax will be removed in a future version of Swift}}
|
||||
return y
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ infix operator ||| {
|
||||
precedence 110
|
||||
}
|
||||
|
||||
@_transparent func &&& (lhs: Bool, @autoclosure rhs: ()->Bool) -> Bool {
|
||||
@transparent func &&& (lhs: Bool, @autoclosure rhs: ()->Bool) -> Bool {
|
||||
if lhs {
|
||||
return rhs()
|
||||
}
|
||||
@@ -120,7 +120,7 @@ infix operator ||| {
|
||||
return false
|
||||
}
|
||||
|
||||
@_transparent func ||| (lhs: Bool, @autoclosure rhs: ()->Bool) -> Bool {
|
||||
@transparent func ||| (lhs: Bool, @autoclosure rhs: ()->Bool) -> Bool {
|
||||
if lhs {
|
||||
return true
|
||||
}
|
||||
@@ -157,7 +157,7 @@ func testInlineUnionElement() -> X {
|
||||
|
||||
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
func call_let_auto_closure(@autoclosure x: () -> Bool) -> Bool {
|
||||
return x()
|
||||
}
|
||||
@@ -175,7 +175,7 @@ func test_let_auto_closure_with_value_capture(x: Bool) -> Bool {
|
||||
class C {}
|
||||
|
||||
// CHECK-LABEL: sil hidden [transparent] @_TF18mandatory_inlining25class_constrained_generic
|
||||
@_transparent
|
||||
@transparent
|
||||
func class_constrained_generic<T : C>(o: T) -> AnyClass? {
|
||||
// CHECK: return
|
||||
return T.self
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// RUN: %target-swift-frontend -emit-sil %s -o /dev/null -verify
|
||||
|
||||
@_transparent func waldo(x: Double) -> Double {
|
||||
@transparent func waldo(x: Double) -> Double {
|
||||
return fred(x); // expected-error {{inlining 'transparent' functions forms circular loop}} expected-note 1 {{while inlining here}}
|
||||
}
|
||||
|
||||
@_transparent func fred(x: Double) -> Double {
|
||||
@transparent func fred(x: Double) -> Double {
|
||||
return waldo(x); // expected-error {{inlining 'transparent' functions forms circular loop}} expected-note 1 {{while inlining here}}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ func searchForMe(x: Float) -> Float {
|
||||
return x
|
||||
}
|
||||
|
||||
@_transparent func baz(x: Float) -> Float {
|
||||
@transparent func baz(x: Float) -> Float {
|
||||
return searchForMe(x);
|
||||
}
|
||||
|
||||
@_transparent func bar(x: Float, _ b: Bool) -> Float {
|
||||
@transparent func bar(x: Float, _ b: Bool) -> Float {
|
||||
if b {
|
||||
return baz(x)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ class CA: PA { }
|
||||
class CB: PB { typealias B = CA }
|
||||
|
||||
struct S<A: PB> {
|
||||
@_transparent
|
||||
@transparent
|
||||
func crash() -> Bool {
|
||||
let a: A.B? = nil
|
||||
return a === a
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// Make sure that we are able to inline try-apply instructions.
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
public func foo() throws -> Int32 {
|
||||
return 999
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ func unreachableBranch() -> Int {
|
||||
}
|
||||
|
||||
// We should not report unreachable user code inside inlined transparent function.
|
||||
@_transparent
|
||||
@transparent
|
||||
func ifTrueTransparent(b: Bool) -> Int {
|
||||
_ = 0
|
||||
if b {
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
@_transparent public func testTransparent(x x: Bool) -> Bool {
|
||||
@transparent public func testTransparent(x x: Bool) -> Bool {
|
||||
return x
|
||||
}
|
||||
|
||||
@_transparent public func testBuiltin() -> Int32 {
|
||||
@transparent public func testBuiltin() -> Int32 {
|
||||
var y: Int32 = 300;
|
||||
var z = "foo"
|
||||
return y
|
||||
}
|
||||
|
||||
@_transparent public func standalone_function(x x: Int32, y: Int32) -> Int32 {
|
||||
@transparent public func standalone_function(x x: Int32, y: Int32) -> Int32 {
|
||||
return x
|
||||
}
|
||||
@_transparent public func curried_function(x x: Int32)(y: Int32) -> Int32 {
|
||||
@transparent public func curried_function(x x: Int32)(y: Int32) -> Int32 {
|
||||
return standalone_function(x: x, y: y)
|
||||
}
|
||||
@_transparent public func calls(i i: Int32, j: Int32) {
|
||||
@transparent public func calls(i i: Int32, j: Int32) {
|
||||
var f1 = curried_function(x: i)
|
||||
f1(y: j);
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public func c() {}
|
||||
public func d() {}
|
||||
public func e() {}
|
||||
|
||||
@_transparent public func test_br() {
|
||||
@transparent public func test_br() {
|
||||
switch foo() {
|
||||
case _ where runced():
|
||||
a()
|
||||
@@ -60,23 +60,23 @@ public func do_switch(u u: MaybePair) {
|
||||
public struct Wrapper {
|
||||
public var value: Int32
|
||||
|
||||
@_transparent public init(Val: Int32) {
|
||||
@transparent public init(Val: Int32) {
|
||||
value = Val
|
||||
}
|
||||
|
||||
@_transparent public func getValue() -> Int32 {
|
||||
@transparent public func getValue() -> Int32 {
|
||||
return value
|
||||
}
|
||||
|
||||
public var valueAgain: Int32 {
|
||||
@_transparent
|
||||
@transparent
|
||||
get {
|
||||
return value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@_transparent public extension Wrapper {
|
||||
@transparent public extension Wrapper {
|
||||
func getValueAgain() -> Int32 {
|
||||
return self.value
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public protocol CP : class {
|
||||
func f() -> Self
|
||||
}
|
||||
|
||||
@_transparent public
|
||||
@transparent public
|
||||
func open_existentials(p p: P, cp: CP) {
|
||||
p.f()
|
||||
cp.f()
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
public class C {}
|
||||
|
||||
@_transparent public func foo(x x: Builtin.Int1, y: Builtin.Int1) -> Builtin.Int1 {
|
||||
@transparent public func foo(x x: Builtin.Int1, y: Builtin.Int1) -> Builtin.Int1 {
|
||||
return Builtin.cmp_eq_Int1(x, y)
|
||||
}
|
||||
|
||||
@_transparent public func destroy_obj(x x: Builtin.RawPointer) {
|
||||
@transparent public func destroy_obj(x x: Builtin.RawPointer) {
|
||||
return Builtin.destroy(Builtin.NativeObject, x)
|
||||
}
|
||||
|
||||
@_transparent public func assign_tuple(x x: (Builtin.Int64, Builtin.NativeObject),
|
||||
@transparent public func assign_tuple(x x: (Builtin.Int64, Builtin.NativeObject),
|
||||
y: Builtin.RawPointer) {
|
||||
Builtin.assign(x, y)
|
||||
}
|
||||
|
||||
@_transparent public func class_to_native_object(c c: C) -> Builtin.NativeObject {
|
||||
@transparent public func class_to_native_object(c c: C) -> Builtin.NativeObject {
|
||||
return Builtin.castToNativeObject(c)
|
||||
}
|
||||
|
||||
@_transparent public func class_from_native_object(p p: Builtin.NativeObject) -> C {
|
||||
@transparent public func class_from_native_object(p p: Builtin.NativeObject) -> C {
|
||||
return Builtin.castFromNativeObject(p)
|
||||
}
|
||||
|
||||
@_transparent public func class_to_raw_pointer(c c: C) -> Builtin.RawPointer {
|
||||
@transparent public func class_to_raw_pointer(c c: C) -> Builtin.RawPointer {
|
||||
return Builtin.bridgeToRawPointer(c)
|
||||
}
|
||||
|
||||
@_transparent public func class_from_raw_pointer(p p: Builtin.RawPointer) -> C {
|
||||
@transparent public func class_from_raw_pointer(p p: Builtin.RawPointer) -> C {
|
||||
return Builtin.bridgeFromRawPointer(p)
|
||||
}
|
||||
|
||||
@_transparent public func gep32(p p: Builtin.RawPointer, i: Builtin.Int32) -> Builtin.RawPointer {
|
||||
@transparent public func gep32(p p: Builtin.RawPointer, i: Builtin.Int32) -> Builtin.RawPointer {
|
||||
return Builtin.gep_Int32(p, i)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
@_transparent public func negate_bad(x: Int) -> Int {
|
||||
@transparent public func negate_bad(x: Int) -> Int {
|
||||
return !x
|
||||
}
|
||||
|
||||
|
||||
@@ -46,58 +46,58 @@ func foo() {}
|
||||
func foo(x: @convention(block) Int) {} // expected-error {{attribute only applies to syntactic function types}}
|
||||
func foo(x: @convention(block) (Int) -> Int) {}
|
||||
|
||||
@_transparent
|
||||
@transparent
|
||||
func zim() {}
|
||||
@_transparent
|
||||
@transparent
|
||||
func zang()() {} // expected-warning{{curried function declaration syntax will be removed in a future version of Swift}}
|
||||
@_transparent
|
||||
@transparent
|
||||
func zung<T>(_: T) {}
|
||||
@_transparent // expected-error{{@_transparent cannot be applied to stored properties}} {{1-15=}}
|
||||
@transparent // expected-error{{@transparent cannot be applied to stored properties}} {{1-14=}}
|
||||
var zippity : Int
|
||||
func zoom(x: @_transparent () -> ()) { } // expected-error{{attribute can only be applied to declarations, not types}} {{1-1=@_transparent }} {{14-28=}}
|
||||
func zoom(x: @transparent () -> ()) { } // expected-error{{attribute can only be applied to declarations, not types}} {{1-1=@transparent }} {{14-27=}}
|
||||
protocol ProtoWithTransparent {
|
||||
@_transparent// expected-error{{@_transparent is not supported on declarations within protocols}} {{3-16=}}
|
||||
@transparent// expected-error{{@transparent is not supported on declarations within protocols}} {{3-15=}}
|
||||
func transInProto()
|
||||
}
|
||||
class TestTranspClass : ProtoWithTransparent {
|
||||
@_transparent // expected-error{{@_transparent is not supported on declarations within classes}} {{3-17=}}
|
||||
@transparent // expected-error{{@transparent is not supported on declarations within classes}} {{3-16=}}
|
||||
init () {}
|
||||
@_transparent // expected-error{{@_transparent cannot be applied to this declaration}} {{3-17=}}
|
||||
@transparent // expected-error{{@transparent cannot be applied to this declaration}} {{3-16=}}
|
||||
deinit {}
|
||||
@_transparent // expected-error{{@_transparent is not supported on declarations within classes}} {{3-17=}}
|
||||
@transparent // expected-error{{@transparent is not supported on declarations within classes}} {{3-16=}}
|
||||
class func transStatic() {}
|
||||
@_transparent// expected-error{{@_transparent is not supported on declarations within classes}} {{3-16=}}
|
||||
@transparent// expected-error{{@transparent is not supported on declarations within classes}} {{3-15=}}
|
||||
func transInProto() {}
|
||||
}
|
||||
struct TestTranspStruct : ProtoWithTransparent{
|
||||
@_transparent
|
||||
@transparent
|
||||
init () {}
|
||||
@_transparent
|
||||
@transparent
|
||||
init <T> (x : T) { }
|
||||
@_transparent
|
||||
@transparent
|
||||
static func transStatic() {}
|
||||
@_transparent
|
||||
@transparent
|
||||
func transInProto() {}
|
||||
}
|
||||
@_transparent // expected-error{{@_transparent cannot be applied to this declaration}} {{1-15=}}
|
||||
@transparent // expected-error{{@transparent cannot be applied to this declaration}} {{1-14=}}
|
||||
struct CannotHaveTransparentStruct {
|
||||
func m1() {}
|
||||
}
|
||||
@_transparent // expected-error{{@_transparent is only supported on struct and enum extensions}} {{1-15=}}
|
||||
@transparent // expected-error{{@transparent is only supported on struct and enum extensions}} {{1-14=}}
|
||||
extension TestTranspClass {
|
||||
func tr1() {}
|
||||
}
|
||||
@_transparent
|
||||
@transparent
|
||||
extension TestTranspStruct {
|
||||
func tr1() {}
|
||||
}
|
||||
@_transparent
|
||||
@transparent
|
||||
extension binary {
|
||||
func tr1() {}
|
||||
}
|
||||
|
||||
class transparentOnCalssVar {
|
||||
@_transparent var max: Int { return 0xFF }; // expected-error {{@_transparent is not supported on declarations within classes}} {{3-17=}}
|
||||
@transparent var max: Int { return 0xFF }; // expected-error {{@transparent is not supported on declarations within classes}} {{3-16=}}
|
||||
func blah () {
|
||||
var _: Int = max
|
||||
}
|
||||
@@ -105,7 +105,7 @@ class transparentOnCalssVar {
|
||||
|
||||
class transparentOnCalssVar2 {
|
||||
var max: Int {
|
||||
@_transparent // expected-error {{@_transparent is not supported on declarations within classes}} {{5-19=}}
|
||||
@transparent // expected-error {{@transparent is not supported on declarations within classes}} {{5-18=}}
|
||||
get {
|
||||
return 0xFF
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user