Creating forwarding substitutions is straightforward enough that we don't need to fudge them in the AST, so remove the forwarding substitutions from ConstructorDecl and construct them instead on the fly in SILGen. We're going to need to be able to forward archetypes in other places in SILGen, such as when emitting closures or curried thunks in generic contexts. No functionality change.
Swift SVN r5418
In an LValue GetterSetterComponent, stash the RValue from evaluating the subscript the first time it's accessed, and copy and reuse the value on subsequent accesses to the lvalue.
Swift SVN r5411
When emitting a call chain, wrap the natural uncurry level of the root call and subsequent chained calls in their own writeback scopes. Suppress writeback if a non-settable property is used as the 'this' argument of a method and during codegen of LoadExprs.
This uncovered a bug in SILGen where a subscript LValue reevaluates the subscript expression on every access, which breaks the stdlib implementation of printf(). I've applied a temporary workaround to keep it working; I'll fix it next.
Swift SVN r5410
Define a new WritebackScope RAII object to mark the beginning and end of the lifetime of a set of writebacks. Add a writeback stack to SILGenFunction to keep track of active writebacks. Replace the ad-hoc writeback tracking in emitAssignToLValue with a WritebackScope.
No functionality change just yet; this just sets the stage for handling writebacks in function arguments.
Swift SVN r5402
We can't autorelease a Swift function value to conform to the ObjC convention, we don't urgently need to expose function properties to ObjC, and the ultimate right thing to do is to convert between a Swift function value and an ObjC block value, so for now, we can just drop the property thunks.
Swift SVN r5373
If a method or property on an [objc] class takes String arguments or returns a String result in the Swift world, insert conversions to/from NSString into the ObjC thunk for the method.
Moving the code around in emitObjCThunk here induces a bit of extra retain/release traffic. But the SIL optimizer will take care of that real soon, right?
Swift SVN r5359
type of the callee at the end is unusual but makes it easier to read the
call. We now get something like this, which makes it obvious what is the
callee value and what are the arguments:
%6 = apply %4(%5) : $[thin] ((), Int64.metatype) -> Int64
We may end up needing types for arguments as well, but lets try to get
away without them.
Swift SVN r5358
If -nsstring-is-string is enabled, lower Strings in cc(c) and cc(objc) function types to NSString, and when calling them, insert calls to StringToNSString/NSStringToString to perform the bridging conversion.
This isn't quite ready for prime-time yet, because we still need to emit the inverse bridging for ObjC method thunks, and I haven't tested the IRGen end of things yet.
Swift SVN r5355
operand, producing something like:
%2 = store %0 to %1 : $*Int64
Enhance the sil parser to be able to parse this. We can now
round trip everything required to handle this function:
func foo(a : Int) -> Int {
return a
}
Swift SVN r5354
Generate and cache SILFunctionTypeInfo from Swift types on the fly, and simplify the SILType representation down to a CanType and isAddress bit.
Swift SVN r5298
Remove uncurry level as a property of SILType/SILFunctionTypeInfo. During SIL type lowering, map a (Type, UncurryLevel) pair to a Swift CanType with the uncurried arguments as a Swift tuple. For example, T -> (U, V) -> W at uncurry level 1 becomes ((U, V), T) -> W--in reverse order to match the low-level calling convention. Update SILGen and IRGen all over the place for this representation change.
SILFunctionTypeInfo is still used in the SILType representation, but it's no longer load-bearing. Everything remaining in it can be derived from a Swift type.
This is an ABI break. Be sure to rebuild clean!
Swift SVN r5296
print the element types of struct.
The empty function now prints as:
sil @_T1t5emptyFT_T_ : $[thin] () -> () {
bb0:
%0 = tuple ()
%1 = tuple () // users: %2
%2 = return %1 : $()
}
Swift SVN r5267
- use interleave a bit more
- Inline printAsOperand() away.
- Introduce a "getIDAndType" method that prints both ID and type in the standard form.
Swift SVN r5266
to always prefix a printed SILType with a $. Update SILPrinter to use
this instead of manually adding $ everywhere.
The only behavioral change of this is that BB arguments now have a $ on
their type.
Swift SVN r5263
Add a TypeConverter::uncurryFunctionType method for making an uncurried AnyFunctionType given a nested AnyFunctionType and an uncurry level. Without actually wiring it into anything yet, spot-check that it does the right thing by hacking SILPrinter to print the uncurried types of SILFunctions in a comment before the sil decl.
Swift SVN r5260
This cleans up some wishy-washy control flow that relied on the uncurryLevel of a type to distinguish ObjC methods from freestanding C functions. While we're here, clean up all the places we use ad-hoc comparison logic on the AbstractCC enum to use switches that properly cover the enum.
Swift SVN r5251
We decided we're going to want to surface fine-grained representational control of functions to the user, so move AbstractCC and the calling convention attributes into the Swift type system. Like the [thin] attribute, we don't set this in the type-checker or importer at all yet, and let SILGen set the attribute where it wants it for now.
Swift SVN r5222
This frees up an extra bit in SILType, which we can expose to LLVM through
PointerLikeTypeTraits. Use this bit in a PointerUnion, which allows simplifying
ValueBase, which happened to be the last use of the isInvalid() state.
Swift SVN r5218
Split ExtractInst and ElementAddrInst into separate Tuple and Struct versions, and have the Struct versions reference struct member VarDecls directly instead of integer indices.
Swift SVN r5215
Trailing closure syntax allows one to write a closure following any
other postfix expression, which passes the closure to that postfix
expression as an arguments. For example:
sort(fruits) { |lhs, rhs|
print("Comparing \(lhs) to \(rhs)\n")
return lhs > rhs
}
As a temporary limitation to work around the ambiguity with
if foo { ... } { ... }
we require trailing closures to have an explicit parameter list, e.g.,
if foo { || ... } { ... }
Swift SVN r5210
When we intend an ObjC dispatch, indicate so in the SILConstant. This lets us distinguish Swift from ObjC dispatch for Swift classes with ObjC superclasses.
Swift SVN r5207