AST: Move a few methods from VarDecl down to ParamDecl

This commit is contained in:
Slava Pestov
2019-07-17 21:17:30 -04:00
parent 87199d572e
commit a532a325e1
43 changed files with 457 additions and 431 deletions

View File

@@ -245,23 +245,23 @@ struct ArgumentInitHelper {
/// Create a SILArgument and store its value into the given Initialization,
/// if not null.
void makeArgumentIntoBinding(Type ty, SILBasicBlock *parent, VarDecl *vd) {
SILLocation loc(vd);
void makeArgumentIntoBinding(Type ty, SILBasicBlock *parent, ParamDecl *pd) {
SILLocation loc(pd);
loc.markAsPrologue();
ManagedValue argrv = makeArgument(ty, vd->isInOut(), parent, loc);
ManagedValue argrv = makeArgument(ty, pd->isInOut(), parent, loc);
if (vd->isInOut()) {
if (pd->isInOut()) {
assert(argrv.getType().isAddress() && "expected inout to be address");
} else {
assert(vd->isImmutable() && "expected parameter to be immutable!");
assert(pd->isImmutable() && "expected parameter to be immutable!");
// If the variable is immutable, we can bind the value as is.
// Leave the cleanup on the argument, if any, in place to consume the
// argument if we're responsible for it.
}
SGF.VarLocs[vd] = SILGenFunction::VarLoc::get(argrv.getValue());
SGF.VarLocs[pd] = SILGenFunction::VarLoc::get(argrv.getValue());
SILValue value = argrv.getValue();
SILDebugVariable varinfo(vd->isLet(), ArgNo);
SILDebugVariable varinfo(pd->isImmutable(), ArgNo);
if (!argrv.getType().isAddress()) {
SGF.B.createDebugValue(loc, value, varinfo);
} else {
@@ -496,7 +496,7 @@ static void emitIndirectResultParameters(SILGenFunction &SGF, Type resultType,
return;
}
auto &ctx = SGF.getASTContext();
auto var = new (ctx) ParamDecl(VarDecl::Specifier::InOut,
auto var = new (ctx) ParamDecl(ParamDecl::Specifier::InOut,
SourceLoc(), SourceLoc(),
ctx.getIdentifier("$return_value"), SourceLoc(),
ctx.getIdentifier("$return_value"),