Sema: Build the AST for inout address conversions.

Add two new AST node types:

- InOutConversionExpr, which represents an '&x' expression that involves inout conversion. This will be a signal to SILGen not to introduce a writeback scope for the nested conversion call.

- LValueToPointerExpr, which represents the primitive '@lvalue T' to 'RawPointer' conversion that produces the argument to the inout conversion.

Build an InOutConversionExpr AST when an inout expression is resolved by a conversion to an BuiltinInOutAddressConvertible type.

Swift SVN r15594
This commit is contained in:
Joe Groff
2014-03-29 02:50:25 +00:00
parent 93f319c706
commit 46f77c6181
11 changed files with 189 additions and 24 deletions

View File

@@ -17,6 +17,7 @@
#include "swift/Subsystems.h"
#include "swift/AST/ArchetypeBuilder.h"
#include "swift/AST/AST.h"
#include "swift/AST/ASTContext.h"
#include "swift/AST/ASTWalker.h"
#include "swift/AST/Mangle.h"
#include "swift/Basic/SourceManager.h"
@@ -945,6 +946,28 @@ struct ASTNodeBase {};
verifyCheckedBase(E);
}
void verifyChecked(LValueToPointerExpr *E) {
if (!E->getSubExpr()->getType()->is<LValueType>()) {
Out << "LValueToPointerExpr subexpression must be an lvalue";
abort();
}
if (!E->getType()->isEqual(
E->getType()->getASTContext().TheRawPointerType)) {
Out << "LValueToPointerExpr result type must be RawPointer";
abort();
}
verifyCheckedBase(E);
}
void verifyChecked(InOutConversionExpr *E) {
if (!E->getSubExpr()->getType()->isEqual(E->getType())) {
Out << "InOutConversionExpr must have the same type as its subexpression";
abort();
}
verifyCheckedBase(E);
}
void verifyChecked(MetatypeExpr *E) {
auto metatype = E->getType()->getAs<MetatypeType>();