mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Rename the internal compiler lexicon from val -> let.
Swift SVN r14408
This commit is contained in:
@@ -192,7 +192,7 @@ static ParserResult<Pattern> parseArgument(Parser &P, Identifier leadingIdent,
|
||||
|
||||
// If this is a standard tuple, parse it.
|
||||
if (!isImpliedNameArgument)
|
||||
return P.parsePatternTupleAfterLP(/*IsVal*/true, /*IsArgList*/true,
|
||||
return P.parsePatternTupleAfterLP(/*IsLet*/true, /*IsArgList*/true,
|
||||
LPLoc, /*DefArgs=*/defaultArgs);
|
||||
|
||||
SourceLoc ArgStartLoc = P.Tok.getLoc();
|
||||
@@ -202,14 +202,14 @@ static ParserResult<Pattern> parseArgument(Parser &P, Identifier leadingIdent,
|
||||
if (leadingIdent.empty())
|
||||
Name = new (P.Context) AnyPattern(ArgStartLoc, /*Implicit=*/true);
|
||||
else
|
||||
Name = P.createBindingFromPattern(ArgStartLoc, leadingIdent, /*isVal*/true);
|
||||
Name = P.createBindingFromPattern(ArgStartLoc, leadingIdent, /*isLet*/true);
|
||||
Name->setImplicit();
|
||||
|
||||
|
||||
ParserStatus EltStatus;
|
||||
Optional<TuplePatternElt> elto;
|
||||
std::tie(EltStatus, elto) =
|
||||
P.parsePatternTupleElement(/*isVal*/true, /*isArgumentList*/true,
|
||||
P.parsePatternTupleElement(/*isLet*/true, /*isArgumentList*/true,
|
||||
Name, defaultArgs);
|
||||
|
||||
if (EltStatus.hasCodeCompletion())
|
||||
@@ -238,7 +238,7 @@ static ParserResult<Pattern> parseArgument(Parser &P, Identifier leadingIdent,
|
||||
|
||||
P.diagnose(ArgStartLoc, diag::implied_name_multiple_parameters)
|
||||
.fixItInsert(ArgStartLoc, "_: ");
|
||||
return P.parsePatternTupleAfterLP(/*IsVal*/true, /*IsArgList*/true,
|
||||
return P.parsePatternTupleAfterLP(/*IsLet*/true, /*IsArgList*/true,
|
||||
LPLoc, /*DefArgs=*/defaultArgs);
|
||||
}
|
||||
|
||||
@@ -448,7 +448,7 @@ Parser::parseFunctionArguments(Identifier functionName,
|
||||
if (Tok.isNot(tok::l_paren))
|
||||
break;
|
||||
|
||||
ArgPattern = parsePatternTuple(/*IsVal*/true, /*IsArgList*/true, nullptr);
|
||||
ArgPattern = parsePatternTuple(/*IsLet*/true, /*IsArgList*/true, nullptr);
|
||||
|
||||
if (ArgPattern.isNull() || ArgPattern.hasCodeCompletion())
|
||||
return ArgPattern;
|
||||
@@ -534,7 +534,7 @@ Parser::parseConstructorArguments(Pattern *&ArgPattern, Pattern *&BodyPattern,
|
||||
// It's just a pattern. Parse it.
|
||||
if (Tok.is(tok::l_paren)) {
|
||||
ParserResult<Pattern> Params =
|
||||
parsePatternTuple(/*IsVal*/ true, /*IsArgList*/ true, &DefaultArgs);
|
||||
parsePatternTuple(/*IsLet*/ true, /*IsArgList*/ true, &DefaultArgs);
|
||||
|
||||
// If we failed to parse the pattern, create an empty tuple to recover.
|
||||
if (Params.isNull()) {
|
||||
@@ -602,14 +602,14 @@ Parser::parseConstructorArguments(Pattern *&ArgPattern, Pattern *&BodyPattern,
|
||||
/// pattern ::= pattern-atom
|
||||
/// pattern ::= pattern-atom ':' type-annotation
|
||||
/// pattern ::= 'var' pattern
|
||||
/// pattern ::= 'val' pattern
|
||||
ParserResult<Pattern> Parser::parsePattern(bool isVal) {
|
||||
// If this is a val or var pattern parse it.
|
||||
/// pattern ::= 'let' pattern
|
||||
ParserResult<Pattern> Parser::parsePattern(bool isLet) {
|
||||
// If this is a let or var pattern parse it.
|
||||
if (Tok.is(tok::kw_val) || Tok.is(tok::kw_var))
|
||||
return parsePatternVarOrVal();
|
||||
return parsePatternVarOrLet();
|
||||
|
||||
// First, parse the pattern atom.
|
||||
ParserResult<Pattern> Result = parsePatternAtom(isVal);
|
||||
ParserResult<Pattern> Result = parsePatternAtom(isLet);
|
||||
|
||||
// Now parse an optional type annotation.
|
||||
if (consumeIf(tok::colon)) {
|
||||
@@ -632,20 +632,20 @@ ParserResult<Pattern> Parser::parsePattern(bool isVal) {
|
||||
return Result;
|
||||
}
|
||||
|
||||
ParserResult<Pattern> Parser::parsePatternVarOrVal() {
|
||||
assert((Tok.is(tok::kw_val) || Tok.is(tok::kw_var)) && "expects val or var");
|
||||
bool isVal = Tok.is(tok::kw_val);
|
||||
ParserResult<Pattern> Parser::parsePatternVarOrLet() {
|
||||
assert((Tok.is(tok::kw_val) || Tok.is(tok::kw_var)) && "expects let or var");
|
||||
bool isLet = Tok.is(tok::kw_val);
|
||||
SourceLoc varLoc = consumeToken();
|
||||
|
||||
// 'var' and 'val' patterns shouldn't nest.
|
||||
if (InVarOrValPattern)
|
||||
diagnose(varLoc, diag::var_pattern_in_var, unsigned(isVal));
|
||||
// 'var' and 'let' patterns shouldn't nest.
|
||||
if (InVarOrLetPattern)
|
||||
diagnose(varLoc, diag::var_pattern_in_var, unsigned(isLet));
|
||||
|
||||
// In our recursive parse, remember that we're in a var/val pattern.
|
||||
llvm::SaveAndRestore<decltype(InVarOrValPattern)>
|
||||
T(InVarOrValPattern, isVal ? IVOLP_InVal : IVOLP_InVar);
|
||||
// In our recursive parse, remember that we're in a var/let pattern.
|
||||
llvm::SaveAndRestore<decltype(InVarOrLetPattern)>
|
||||
T(InVarOrLetPattern, isLet ? IVOLP_InLet : IVOLP_InVar);
|
||||
|
||||
ParserResult<Pattern> subPattern = parsePattern(isVal);
|
||||
ParserResult<Pattern> subPattern = parsePattern(isLet);
|
||||
if (subPattern.hasCodeCompletion())
|
||||
return makeParserCodeCompletionResult<Pattern>();
|
||||
if (subPattern.isNull())
|
||||
@@ -661,14 +661,14 @@ bool Parser::isAtStartOfBindingName() {
|
||||
}
|
||||
|
||||
Pattern *Parser::createBindingFromPattern(SourceLoc loc, Identifier name,
|
||||
bool isVal) {
|
||||
auto *var = new (Context) VarDecl(/*static*/ false, /*IsVal*/ isVal,
|
||||
bool isLet) {
|
||||
auto *var = new (Context) VarDecl(/*static*/ false, /*IsLet*/ isLet,
|
||||
loc, name, Type(), CurDeclContext);
|
||||
return new (Context) NamedPattern(var);
|
||||
}
|
||||
|
||||
/// Parse an identifier as a pattern.
|
||||
ParserResult<Pattern> Parser::parsePatternIdentifier(bool isVal) {
|
||||
ParserResult<Pattern> Parser::parsePatternIdentifier(bool isLet) {
|
||||
SourceLoc loc = Tok.getLoc();
|
||||
if (consumeIf(tok::kw__)) {
|
||||
return makeParserResult(new (Context) AnyPattern(loc));
|
||||
@@ -677,7 +677,7 @@ ParserResult<Pattern> Parser::parsePatternIdentifier(bool isVal) {
|
||||
StringRef text = Tok.getText();
|
||||
if (consumeIf(tok::identifier)) {
|
||||
Identifier ident = Context.getIdentifier(text);
|
||||
return makeParserResult(createBindingFromPattern(loc, ident, isVal));
|
||||
return makeParserResult(createBindingFromPattern(loc, ident, isLet));
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@@ -689,14 +689,14 @@ ParserResult<Pattern> Parser::parsePatternIdentifier(bool isVal) {
|
||||
/// pattern-atom ::= identifier
|
||||
/// pattern-atom ::= '_'
|
||||
/// pattern-atom ::= pattern-tuple
|
||||
ParserResult<Pattern> Parser::parsePatternAtom(bool isVal) {
|
||||
ParserResult<Pattern> Parser::parsePatternAtom(bool isLet) {
|
||||
switch (Tok.getKind()) {
|
||||
case tok::l_paren:
|
||||
return parsePatternTuple(isVal, /*IsArgList*/false,/*DefaultArgs*/nullptr);
|
||||
return parsePatternTuple(isLet, /*IsArgList*/false,/*DefaultArgs*/nullptr);
|
||||
|
||||
case tok::identifier:
|
||||
case tok::kw__:
|
||||
return parsePatternIdentifier(isVal);
|
||||
return parsePatternIdentifier(isLet);
|
||||
|
||||
case tok::code_complete:
|
||||
// Just eat the token and return an error status, *not* the code completion
|
||||
@@ -719,7 +719,7 @@ ParserResult<Pattern> Parser::parsePatternAtom(bool isVal) {
|
||||
}
|
||||
|
||||
std::pair<ParserStatus, Optional<TuplePatternElt>>
|
||||
Parser::parsePatternTupleElement(bool isVal, bool isArgumentList,
|
||||
Parser::parsePatternTupleElement(bool isLet, bool isArgumentList,
|
||||
Pattern *ImplicitName,
|
||||
DefaultArgumentInfo *defaultArgs) {
|
||||
|
||||
@@ -738,7 +738,7 @@ Parser::parsePatternTupleElement(bool isVal, bool isArgumentList,
|
||||
// only" case (e.g. an implicitly named selector argument) then parse a type
|
||||
// and build the pattern around it.
|
||||
if (!ImplicitName) {
|
||||
pattern = parsePattern(isVal);
|
||||
pattern = parsePattern(isLet);
|
||||
if (pattern.hasCodeCompletion())
|
||||
return std::make_pair(makeParserCodeCompletionStatus(), Nothing);
|
||||
if (pattern.isNull())
|
||||
@@ -781,11 +781,11 @@ Parser::parsePatternTupleElement(bool isVal, bool isArgumentList,
|
||||
TuplePatternElt(pattern.get(), init, getDefaultArgKind(init)));
|
||||
}
|
||||
|
||||
ParserResult<Pattern> Parser::parsePatternTuple(bool isVal, bool isArgumentList,
|
||||
ParserResult<Pattern> Parser::parsePatternTuple(bool isLet, bool isArgumentList,
|
||||
DefaultArgumentInfo *defaults) {
|
||||
StructureMarkerRAII ParsingPatternTuple(*this, Tok);
|
||||
SourceLoc LPLoc = consumeToken(tok::l_paren);
|
||||
return parsePatternTupleAfterLP(isVal, isArgumentList, LPLoc, defaults);
|
||||
return parsePatternTupleAfterLP(isLet, isArgumentList, LPLoc, defaults);
|
||||
}
|
||||
|
||||
/// Parse a tuple pattern. The leading left paren has already been consumed and
|
||||
@@ -796,7 +796,7 @@ ParserResult<Pattern> Parser::parsePatternTuple(bool isVal, bool isArgumentList,
|
||||
/// pattern-tuple-body:
|
||||
/// pattern-tuple-element (',' pattern-tuple-body)*
|
||||
ParserResult<Pattern>
|
||||
Parser::parsePatternTupleAfterLP(bool isVal, bool isArgumentList,
|
||||
Parser::parsePatternTupleAfterLP(bool isLet, bool isArgumentList,
|
||||
SourceLoc LPLoc,
|
||||
DefaultArgumentInfo *defaults) {
|
||||
SourceLoc RPLoc, EllipsisLoc;
|
||||
@@ -812,7 +812,7 @@ Parser::parsePatternTupleAfterLP(bool isVal, bool isArgumentList,
|
||||
// Parse the pattern tuple element.
|
||||
ParserStatus EltStatus;
|
||||
Optional<TuplePatternElt> elt;
|
||||
std::tie(EltStatus, elt) = parsePatternTupleElement(isVal, isArgumentList,
|
||||
std::tie(EltStatus, elt) = parsePatternTupleElement(isLet, isArgumentList,
|
||||
nullptr, defaults);
|
||||
if (EltStatus.hasCodeCompletion())
|
||||
return makeParserCodeCompletionStatus();
|
||||
@@ -896,13 +896,13 @@ ParserResult<Pattern> Parser::parseMatchingPatternVarOrVal() {
|
||||
bool isVal = Tok.is(tok::kw_val);
|
||||
SourceLoc varLoc = consumeToken();
|
||||
|
||||
// 'var' and 'val' patterns shouldn't nest.
|
||||
if (InVarOrValPattern)
|
||||
// 'var' and 'let' patterns shouldn't nest.
|
||||
if (InVarOrLetPattern)
|
||||
diagnose(varLoc, diag::var_pattern_in_var, unsigned(isVal));
|
||||
|
||||
// In our recursive parse, remember that we're in a var/val pattern.
|
||||
llvm::SaveAndRestore<decltype(InVarOrValPattern)>
|
||||
T(InVarOrValPattern, isVal ? IVOLP_InVal : IVOLP_InVar);
|
||||
// In our recursive parse, remember that we're in a var/let pattern.
|
||||
llvm::SaveAndRestore<decltype(InVarOrLetPattern)>
|
||||
T(InVarOrLetPattern, isVal ? IVOLP_InLet : IVOLP_InVar);
|
||||
|
||||
ParserResult<Pattern> subPattern = parseMatchingPattern();
|
||||
if (subPattern.isNull())
|
||||
|
||||
Reference in New Issue
Block a user