SILGen: Implement reftype elements and properties.

Generalize a bunch of code that assumed address-of-value-type for the "this" side of properties to accept reftypes as well. Use RefElementAddrInst to extract physical elements of reference types. Fix an off-by-one in the writeback logic in emitStoreToLValue so that writeback chains properly terminate at the deepest value type component below a reference type component.

Swift SVN r3445
This commit is contained in:
Joe Groff
2012-12-12 01:04:31 +00:00
parent 13bb47d070
commit ec86ae9d0e
6 changed files with 83 additions and 37 deletions

View File

@@ -57,6 +57,14 @@ SILConstant::SILConstant(SILConstant::Loc baseLoc) {
id = 0;
}
static Type propertyThisType(Type thisType, ASTContext &C) {
if (thisType->hasReferenceSemantics()) {
return thisType;
} else {
return LValueType::get(thisType, LValueType::Qual::DefaultForType, C);
}
}
Type SILConstant::getType() const {
// FIXME: This should probably be a method on SILModule that caches the
// type information.
@@ -78,9 +86,7 @@ Type SILConstant::getType() const {
}
if (propertyType)
return contextType
? FunctionType::get(LValueType::get(contextType,
LValueType::Qual::DefaultForType,
C),
? FunctionType::get(propertyThisType(contextType, C),
propertyType, C)
: propertyType;