blob: 93568efebc02aa2a2f5679601626c3f55b8c5ced [file] [log] [blame]
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +00001//===--- ParseCXXInlineMethods.cpp - C++ class inline methods parsing------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements parsing for C++ class inline methods.
11//
12//===----------------------------------------------------------------------===//
13
Chris Lattner60f36222009-01-29 05:15:15 +000014#include "clang/Parse/ParseDiagnostic.h"
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +000015#include "clang/Parse/Parser.h"
John McCall8b0666c2010-08-20 18:27:03 +000016#include "clang/Sema/DeclSpec.h"
17#include "clang/Sema/Scope.h"
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +000018using namespace clang;
19
Sebastian Redla7b98a72009-04-26 20:35:05 +000020/// ParseCXXInlineMethodDef - We parsed and verified that the specified
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +000021/// Declarator is a well formed C++ inline method definition. Now lex its body
22/// and store its tokens for parsing after the C++ class is complete.
John McCallc1465822011-02-14 07:13:47 +000023Decl *Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, ParsingDeclarator &D,
Nico Weber24b2a822011-01-28 06:07:34 +000024 const ParsedTemplateInfo &TemplateInfo,
25 const VirtSpecifiers& VS) {
Abramo Bagnara924a8f32010-12-10 16:29:40 +000026 assert(D.isFunctionDeclarator() && "This isn't a function declarator!");
Sebastian Redla7b98a72009-04-26 20:35:05 +000027 assert((Tok.is(tok::l_brace) || Tok.is(tok::colon) || Tok.is(tok::kw_try)) &&
28 "Current token not a '{', ':' or 'try'!");
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +000029
John McCallfaf5fb42010-08-26 23:41:50 +000030 MultiTemplateParamsArg TemplateParams(Actions,
Alexis Hunt1deb9722010-04-14 23:07:37 +000031 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data() : 0,
32 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
33
John McCall48871652010-08-21 09:40:31 +000034 Decl *FnD;
John McCall07e91c02009-08-06 02:15:43 +000035 if (D.getDeclSpec().isFriendSpecified())
Douglas Gregor3447e762009-08-20 22:52:58 +000036 // FIXME: Friend templates
Douglas Gregor0be31a22010-07-02 17:43:08 +000037 FnD = Actions.ActOnFriendFunctionDecl(getCurScope(), D, true,
Alexis Hunt1deb9722010-04-14 23:07:37 +000038 move(TemplateParams));
Nico Weber24b2a822011-01-28 06:07:34 +000039 else { // FIXME: pass template information through
Douglas Gregor0be31a22010-07-02 17:43:08 +000040 FnD = Actions.ActOnCXXMemberDeclarator(getCurScope(), AS, D,
Anders Carlssondb36b802011-01-20 03:57:25 +000041 move(TemplateParams), 0,
Nico Weber24b2a822011-01-28 06:07:34 +000042 VS, 0, /*IsDefinition*/true);
43 }
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +000044
Eli Friedman3af2a772009-07-22 21:45:50 +000045 HandleMemberFunctionDefaultArgs(D, FnD);
46
John McCallc1465822011-02-14 07:13:47 +000047 D.complete(FnD);
48
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +000049 // Consume the tokens and store them for later parsing.
50
Douglas Gregorefc46952010-10-12 16:25:54 +000051 LexedMethod* LM = new LexedMethod(this, FnD);
52 getCurrentClass().LateParsedDeclarations.push_back(LM);
53 LM->TemplateScope = getCurScope()->isTemplateParamScope();
54 CachedTokens &Toks = LM->Toks;
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +000055
Sebastian Redla7b98a72009-04-26 20:35:05 +000056 tok::TokenKind kind = Tok.getKind();
57 // We may have a constructor initializer or function-try-block here.
58 if (kind == tok::colon || kind == tok::kw_try) {
Douglas Gregore8381c02008-11-05 04:29:56 +000059 // Consume everything up to (and including) the left brace.
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +000060 if (!ConsumeAndStoreUntil(tok::l_brace, Toks)) {
Douglas Gregor49de5342008-11-10 16:59:40 +000061 // We didn't find the left-brace we expected after the
Mike Stump11289f42009-09-09 15:08:12 +000062 // constructor initializer.
Douglas Gregor49de5342008-11-10 16:59:40 +000063 if (Tok.is(tok::semi)) {
64 // We found a semicolon; complain, consume the semicolon, and
65 // don't try to parse this method later.
66 Diag(Tok.getLocation(), diag::err_expected_lbrace);
67 ConsumeAnyToken();
Douglas Gregorefc46952010-10-12 16:25:54 +000068 delete getCurrentClass().LateParsedDeclarations.back();
69 getCurrentClass().LateParsedDeclarations.pop_back();
Douglas Gregor49de5342008-11-10 16:59:40 +000070 return FnD;
71 }
72 }
73
Douglas Gregore8381c02008-11-05 04:29:56 +000074 } else {
Mike Stump11289f42009-09-09 15:08:12 +000075 // Begin by storing the '{' token.
Douglas Gregore8381c02008-11-05 04:29:56 +000076 Toks.push_back(Tok);
77 ConsumeBrace();
78 }
79 // Consume everything up to (and including) the matching right brace.
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +000080 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +000081
Sebastian Redla7b98a72009-04-26 20:35:05 +000082 // If we're in a function-try-block, we need to store all the catch blocks.
83 if (kind == tok::kw_try) {
84 while (Tok.is(tok::kw_catch)) {
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +000085 ConsumeAndStoreUntil(tok::l_brace, Toks, /*StopAtSemi=*/false);
86 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
Sebastian Redla7b98a72009-04-26 20:35:05 +000087 }
88 }
89
Douglas Gregor6ca64102011-04-14 23:19:27 +000090
91 if (!FnD) {
92 // If semantic analysis could not build a function declaration,
93 // just throw away the late-parsed declaration.
94 delete getCurrentClass().LateParsedDeclarations.back();
95 getCurrentClass().LateParsedDeclarations.pop_back();
96 }
97
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +000098 return FnD;
99}
100
Douglas Gregorefc46952010-10-12 16:25:54 +0000101Parser::LateParsedDeclaration::~LateParsedDeclaration() {}
102void Parser::LateParsedDeclaration::ParseLexedMethodDeclarations() {}
103void Parser::LateParsedDeclaration::ParseLexedMethodDefs() {}
104
105Parser::LateParsedClass::LateParsedClass(Parser *P, ParsingClass *C)
106 : Self(P), Class(C) {}
107
108Parser::LateParsedClass::~LateParsedClass() {
109 Self->DeallocateParsedClasses(Class);
110}
111
112void Parser::LateParsedClass::ParseLexedMethodDeclarations() {
113 Self->ParseLexedMethodDeclarations(*Class);
114}
115
116void Parser::LateParsedClass::ParseLexedMethodDefs() {
117 Self->ParseLexedMethodDefs(*Class);
118}
119
120void Parser::LateParsedMethodDeclaration::ParseLexedMethodDeclarations() {
121 Self->ParseLexedMethodDeclaration(*this);
122}
123
124void Parser::LexedMethod::ParseLexedMethodDefs() {
125 Self->ParseLexedMethodDef(*this);
126}
127
Douglas Gregor4d87df52008-12-16 21:30:33 +0000128/// ParseLexedMethodDeclarations - We finished parsing the member
129/// specification of a top (non-nested) C++ class. Now go over the
130/// stack of method declarations with some parts for which parsing was
131/// delayed (such as default arguments) and parse them.
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000132void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) {
133 bool HasTemplateScope = !Class.TopLevelClass && Class.TemplateScope;
Douglas Gregorefc46952010-10-12 16:25:54 +0000134 ParseScope ClassTemplateScope(this, Scope::TemplateParamScope, HasTemplateScope);
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000135 if (HasTemplateScope)
Douglas Gregor0be31a22010-07-02 17:43:08 +0000136 Actions.ActOnReenterTemplateScope(getCurScope(), Class.TagOrTemplate);
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000137
John McCall6df5fef2009-12-19 10:49:29 +0000138 // The current scope is still active if we're the top-level class.
139 // Otherwise we'll need to push and enter a new scope.
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000140 bool HasClassScope = !Class.TopLevelClass;
Alexis Hunt1deb9722010-04-14 23:07:37 +0000141 ParseScope ClassScope(this, Scope::ClassScope|Scope::DeclScope,
142 HasClassScope);
John McCall6df5fef2009-12-19 10:49:29 +0000143 if (HasClassScope)
Douglas Gregor0be31a22010-07-02 17:43:08 +0000144 Actions.ActOnStartDelayedMemberDeclarations(getCurScope(), Class.TagOrTemplate);
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000145
Douglas Gregorefc46952010-10-12 16:25:54 +0000146 for (size_t i = 0; i < Class.LateParsedDeclarations.size(); ++i) {
147 Class.LateParsedDeclarations[i]->ParseLexedMethodDeclarations();
Douglas Gregor4d87df52008-12-16 21:30:33 +0000148 }
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000149
John McCall6df5fef2009-12-19 10:49:29 +0000150 if (HasClassScope)
Douglas Gregor0be31a22010-07-02 17:43:08 +0000151 Actions.ActOnFinishDelayedMemberDeclarations(getCurScope(), Class.TagOrTemplate);
Douglas Gregor4d87df52008-12-16 21:30:33 +0000152}
153
Douglas Gregorefc46952010-10-12 16:25:54 +0000154void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
155 // If this is a member template, introduce the template parameter scope.
156 ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
157 if (LM.TemplateScope)
158 Actions.ActOnReenterTemplateScope(getCurScope(), LM.Method);
159
160 // Start the delayed C++ method declaration
161 Actions.ActOnStartDelayedCXXMethodDeclaration(getCurScope(), LM.Method);
162
163 // Introduce the parameters into scope and parse their default
164 // arguments.
165 ParseScope PrototypeScope(this,
166 Scope::FunctionPrototypeScope|Scope::DeclScope);
167 for (unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
168 // Introduce the parameter into scope.
169 Actions.ActOnDelayedCXXMethodParameter(getCurScope(), LM.DefaultArgs[I].Param);
170
171 if (CachedTokens *Toks = LM.DefaultArgs[I].Toks) {
172 // Save the current token position.
173 SourceLocation origLoc = Tok.getLocation();
174
175 // Parse the default argument from its saved token stream.
176 Toks->push_back(Tok); // So that the current token doesn't get lost
177 PP.EnterTokenStream(&Toks->front(), Toks->size(), true, false);
178
179 // Consume the previously-pushed token.
180 ConsumeAnyToken();
181
182 // Consume the '='.
183 assert(Tok.is(tok::equal) && "Default argument not starting with '='");
184 SourceLocation EqualLoc = ConsumeToken();
185
186 // The argument isn't actually potentially evaluated unless it is
187 // used.
188 EnterExpressionEvaluationContext Eval(Actions,
189 Sema::PotentiallyEvaluatedIfUsed);
190
191 ExprResult DefArgResult(ParseAssignmentExpression());
192 if (DefArgResult.isInvalid())
193 Actions.ActOnParamDefaultArgumentError(LM.DefaultArgs[I].Param);
194 else {
195 if (Tok.is(tok::cxx_defaultarg_end))
196 ConsumeToken();
197 else
198 Diag(Tok.getLocation(), diag::err_default_arg_unparsed);
199 Actions.ActOnParamDefaultArgument(LM.DefaultArgs[I].Param, EqualLoc,
200 DefArgResult.take());
201 }
202
203 assert(!PP.getSourceManager().isBeforeInTranslationUnit(origLoc,
204 Tok.getLocation()) &&
205 "ParseAssignmentExpression went over the default arg tokens!");
206 // There could be leftover tokens (e.g. because of an error).
207 // Skip through until we reach the original token position.
208 while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof))
209 ConsumeAnyToken();
210
211 delete Toks;
212 LM.DefaultArgs[I].Toks = 0;
213 }
214 }
215 PrototypeScope.Exit();
216
217 // Finish the delayed C++ method declaration.
218 Actions.ActOnFinishDelayedCXXMethodDeclaration(getCurScope(), LM.Method);
219}
220
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000221/// ParseLexedMethodDefs - We finished parsing the member specification of a top
222/// (non-nested) C++ class. Now go over the stack of lexed methods that were
223/// collected during its parsing and parse them all.
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000224void Parser::ParseLexedMethodDefs(ParsingClass &Class) {
225 bool HasTemplateScope = !Class.TopLevelClass && Class.TemplateScope;
Douglas Gregorefc46952010-10-12 16:25:54 +0000226 ParseScope ClassTemplateScope(this, Scope::TemplateParamScope, HasTemplateScope);
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000227 if (HasTemplateScope)
Douglas Gregor0be31a22010-07-02 17:43:08 +0000228 Actions.ActOnReenterTemplateScope(getCurScope(), Class.TagOrTemplate);
Douglas Gregore44a2ad2009-05-27 23:11:45 +0000229
230 bool HasClassScope = !Class.TopLevelClass;
231 ParseScope ClassScope(this, Scope::ClassScope|Scope::DeclScope,
232 HasClassScope);
233
Douglas Gregorefc46952010-10-12 16:25:54 +0000234 for (size_t i = 0; i < Class.LateParsedDeclarations.size(); ++i) {
235 Class.LateParsedDeclarations[i]->ParseLexedMethodDefs();
236 }
237}
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000238
Douglas Gregorefc46952010-10-12 16:25:54 +0000239void Parser::ParseLexedMethodDef(LexedMethod &LM) {
240 // If this is a member template, introduce the template parameter scope.
241 ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
242 if (LM.TemplateScope)
243 Actions.ActOnReenterTemplateScope(getCurScope(), LM.D);
Mike Stump11289f42009-09-09 15:08:12 +0000244
Douglas Gregorefc46952010-10-12 16:25:54 +0000245 // Save the current token position.
246 SourceLocation origLoc = Tok.getLocation();
Argyrios Kyrtzidis02041972010-03-31 00:38:09 +0000247
Douglas Gregorefc46952010-10-12 16:25:54 +0000248 assert(!LM.Toks.empty() && "Empty body!");
249 // Append the current token at the end of the new token stream so that it
250 // doesn't get lost.
251 LM.Toks.push_back(Tok);
252 PP.EnterTokenStream(LM.Toks.data(), LM.Toks.size(), true, false);
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000253
Douglas Gregorefc46952010-10-12 16:25:54 +0000254 // Consume the previously pushed token.
255 ConsumeAnyToken();
256 assert((Tok.is(tok::l_brace) || Tok.is(tok::colon) || Tok.is(tok::kw_try))
257 && "Inline method not starting with '{', ':' or 'try'");
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000258
Douglas Gregorefc46952010-10-12 16:25:54 +0000259 // Parse the method body. Function body parsing code is similar enough
260 // to be re-used for method bodies as well.
261 ParseScope FnScope(this, Scope::FnScope|Scope::DeclScope);
262 Actions.ActOnStartOfFunctionDef(getCurScope(), LM.D);
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000263
Douglas Gregorefc46952010-10-12 16:25:54 +0000264 if (Tok.is(tok::kw_try)) {
Douglas Gregora0ff0c32011-03-16 17:05:57 +0000265 ParseFunctionTryBlock(LM.D, FnScope);
Douglas Gregorefc46952010-10-12 16:25:54 +0000266 assert(!PP.getSourceManager().isBeforeInTranslationUnit(origLoc,
267 Tok.getLocation()) &&
268 "ParseFunctionTryBlock went over the cached tokens!");
269 // There could be leftover tokens (e.g. because of an error).
270 // Skip through until we reach the original token position.
271 while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof))
272 ConsumeAnyToken();
273 return;
274 }
275 if (Tok.is(tok::colon)) {
276 ParseConstructorInitializer(LM.D);
277
278 // Error recovery.
279 if (!Tok.is(tok::l_brace)) {
Douglas Gregora0ff0c32011-03-16 17:05:57 +0000280 FnScope.Exit();
Douglas Gregorefc46952010-10-12 16:25:54 +0000281 Actions.ActOnFinishFunctionBody(LM.D, 0);
282 return;
283 }
284 } else
285 Actions.ActOnDefaultCtorInitializers(LM.D);
286
Douglas Gregora0ff0c32011-03-16 17:05:57 +0000287 ParseFunctionStatementBody(LM.D, FnScope);
Douglas Gregorefc46952010-10-12 16:25:54 +0000288
289 if (Tok.getLocation() != origLoc) {
290 // Due to parsing error, we either went over the cached tokens or
291 // there are still cached tokens left. If it's the latter case skip the
292 // leftover tokens.
293 // Since this is an uncommon situation that should be avoided, use the
294 // expensive isBeforeInTranslationUnit call.
295 if (PP.getSourceManager().isBeforeInTranslationUnit(Tok.getLocation(),
296 origLoc))
Argyrios Kyrtzidise1224c82010-06-19 19:58:34 +0000297 while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof))
Argyrios Kyrtzidise9b76af2010-06-17 10:52:22 +0000298 ConsumeAnyToken();
John McCallbb7b6582010-04-10 07:37:23 +0000299
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000300 }
301}
302
303/// ConsumeAndStoreUntil - Consume and store the token at the passed token
Douglas Gregor4d87df52008-12-16 21:30:33 +0000304/// container until the token 'T' is reached (which gets
Mike Stump11289f42009-09-09 15:08:12 +0000305/// consumed/stored too, if ConsumeFinalToken).
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +0000306/// If StopAtSemi is true, then we will stop early at a ';' character.
Douglas Gregor4d87df52008-12-16 21:30:33 +0000307/// Returns true if token 'T1' or 'T2' was found.
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000308/// NOTE: This is a specialized version of Parser::SkipUntil.
Douglas Gregor4d87df52008-12-16 21:30:33 +0000309bool Parser::ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2,
310 CachedTokens &Toks,
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +0000311 bool StopAtSemi, bool ConsumeFinalToken) {
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000312 // We always want this function to consume at least one token if the first
313 // token isn't T and if not at EOF.
314 bool isFirstTokenConsumed = true;
315 while (1) {
316 // If we found one of the tokens, stop and return true.
Douglas Gregor4d87df52008-12-16 21:30:33 +0000317 if (Tok.is(T1) || Tok.is(T2)) {
318 if (ConsumeFinalToken) {
319 Toks.push_back(Tok);
320 ConsumeAnyToken();
321 }
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000322 return true;
323 }
324
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000325 switch (Tok.getKind()) {
326 case tok::eof:
327 // Ran out of tokens.
328 return false;
329
330 case tok::l_paren:
331 // Recursively consume properly-nested parens.
332 Toks.push_back(Tok);
333 ConsumeParen();
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +0000334 ConsumeAndStoreUntil(tok::r_paren, Toks, /*StopAtSemi=*/false);
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000335 break;
336 case tok::l_square:
337 // Recursively consume properly-nested square brackets.
338 Toks.push_back(Tok);
339 ConsumeBracket();
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +0000340 ConsumeAndStoreUntil(tok::r_square, Toks, /*StopAtSemi=*/false);
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000341 break;
342 case tok::l_brace:
343 // Recursively consume properly-nested braces.
344 Toks.push_back(Tok);
345 ConsumeBrace();
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +0000346 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000347 break;
348
349 // Okay, we found a ']' or '}' or ')', which we think should be balanced.
350 // Since the user wasn't looking for this token (if they were, it would
351 // already be handled), this isn't balanced. If there is a LHS token at a
352 // higher level, we will assume that this matches the unbalanced token
353 // and return it. Otherwise, this is a spurious RHS token, which we skip.
354 case tok::r_paren:
355 if (ParenCount && !isFirstTokenConsumed)
356 return false; // Matches something.
357 Toks.push_back(Tok);
358 ConsumeParen();
359 break;
360 case tok::r_square:
361 if (BracketCount && !isFirstTokenConsumed)
362 return false; // Matches something.
363 Toks.push_back(Tok);
364 ConsumeBracket();
365 break;
366 case tok::r_brace:
367 if (BraceCount && !isFirstTokenConsumed)
368 return false; // Matches something.
369 Toks.push_back(Tok);
370 ConsumeBrace();
371 break;
372
373 case tok::string_literal:
374 case tok::wide_string_literal:
375 Toks.push_back(Tok);
376 ConsumeStringToken();
377 break;
Argyrios Kyrtzidis8d7bdba2010-04-23 21:20:12 +0000378 case tok::semi:
379 if (StopAtSemi)
380 return false;
381 // FALL THROUGH.
Argyrios Kyrtzidis7bbb20e2008-06-24 22:12:16 +0000382 default:
383 // consume this token.
384 Toks.push_back(Tok);
385 ConsumeToken();
386 break;
387 }
388 isFirstTokenConsumed = false;
389 }
390}