| OLD | NEW | 
|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "src/ast.h" | 5 #include "src/ast.h" | 
| 6 #include "src/messages.h" | 6 #include "src/messages.h" | 
| 7 #include "src/parser.h" | 7 #include "src/parser.h" | 
| 8 | 8 | 
| 9 namespace v8 { | 9 namespace v8 { | 
| 10 | 10 | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 23   rewriter.descriptor_ = declaration_descriptor; | 23   rewriter.descriptor_ = declaration_descriptor; | 
| 24   rewriter.names_ = names; | 24   rewriter.names_ = names; | 
| 25   rewriter.ok_ = ok; | 25   rewriter.ok_ = ok; | 
| 26 | 26 | 
| 27   rewriter.RecurseIntoSubpattern(rewriter.pattern_, declaration->initializer); | 27   rewriter.RecurseIntoSubpattern(rewriter.pattern_, declaration->initializer); | 
| 28 } | 28 } | 
| 29 | 29 | 
| 30 | 30 | 
| 31 void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) { | 31 void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) { | 
| 32   Expression* value = current_value_; | 32   Expression* value = current_value_; | 
| 33   descriptor_->scope->RemoveUnresolved(pattern->AsVariableProxy()); | 33   descriptor_->scope->RemoveUnresolved(pattern); | 
| 34 | 34 | 
| 35   // Declare variable. | 35   // Declare variable. | 
| 36   // Note that we *always* must treat the initial value via a separate init | 36   // Note that we *always* must treat the initial value via a separate init | 
| 37   // assignment for variables and constants because the value must be assigned | 37   // assignment for variables and constants because the value must be assigned | 
| 38   // when the variable is encountered in the source. But the variable/constant | 38   // when the variable is encountered in the source. But the variable/constant | 
| 39   // is declared (and set to 'undefined') upon entering the function within | 39   // is declared (and set to 'undefined') upon entering the function within | 
| 40   // which the variable or constant is declared. Only function variables have | 40   // which the variable or constant is declared. Only function variables have | 
| 41   // an initial value in the declaration (because they are initialized upon | 41   // an initial value in the declaration (because they are initialized upon | 
| 42   // entering the function). | 42   // entering the function). | 
| 43   // | 43   // | 
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 354       Token::EQ_STRICT, factory()->NewVariableProxy(temp), | 354       Token::EQ_STRICT, factory()->NewVariableProxy(temp), | 
| 355       factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), | 355       factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), | 
| 356       RelocInfo::kNoPosition); | 356       RelocInfo::kNoPosition); | 
| 357   Expression* value = factory()->NewConditional( | 357   Expression* value = factory()->NewConditional( | 
| 358       is_undefined, node->value(), factory()->NewVariableProxy(temp), | 358       is_undefined, node->value(), factory()->NewVariableProxy(temp), | 
| 359       RelocInfo::kNoPosition); | 359       RelocInfo::kNoPosition); | 
| 360   RecurseIntoSubpattern(node->target(), value); | 360   RecurseIntoSubpattern(node->target(), value); | 
| 361 } | 361 } | 
| 362 | 362 | 
| 363 | 363 | 
| 364 void Parser::PatternRewriter::VisitSpread(Spread* node) { |  | 
| 365   UNREACHABLE(); |  | 
| 366 } |  | 
| 367 |  | 
| 368 |  | 
| 369 void Parser::PatternRewriter::VisitEmptyParentheses(EmptyParentheses* node) { |  | 
| 370   UNREACHABLE(); |  | 
| 371 } |  | 
| 372 |  | 
| 373 |  | 
| 374 // =============== UNREACHABLE ============================= | 364 // =============== UNREACHABLE ============================= | 
| 375 | 365 | 
| 376 void Parser::PatternRewriter::Visit(AstNode* node) { UNREACHABLE(); } | 366 void Parser::PatternRewriter::Visit(AstNode* node) { UNREACHABLE(); } | 
| 377 | 367 | 
| 378 #define NOT_A_PATTERN(Node)                                        \ | 368 #define NOT_A_PATTERN(Node)                                        \ | 
| 379   void Parser::PatternRewriter::Visit##Node(v8::internal::Node*) { \ | 369   void Parser::PatternRewriter::Visit##Node(v8::internal::Node*) { \ | 
| 380     UNREACHABLE();                                                 \ | 370     UNREACHABLE();                                                 \ | 
| 381   } | 371   } | 
| 382 | 372 | 
| 383 NOT_A_PATTERN(BinaryOperation) | 373 NOT_A_PATTERN(BinaryOperation) | 
| 384 NOT_A_PATTERN(Block) | 374 NOT_A_PATTERN(Block) | 
| 385 NOT_A_PATTERN(BreakStatement) | 375 NOT_A_PATTERN(BreakStatement) | 
| 386 NOT_A_PATTERN(Call) | 376 NOT_A_PATTERN(Call) | 
| 387 NOT_A_PATTERN(CallNew) | 377 NOT_A_PATTERN(CallNew) | 
| 388 NOT_A_PATTERN(CallRuntime) | 378 NOT_A_PATTERN(CallRuntime) | 
| 389 NOT_A_PATTERN(CaseClause) | 379 NOT_A_PATTERN(CaseClause) | 
| 390 NOT_A_PATTERN(ClassLiteral) | 380 NOT_A_PATTERN(ClassLiteral) | 
| 391 NOT_A_PATTERN(CompareOperation) | 381 NOT_A_PATTERN(CompareOperation) | 
| 392 NOT_A_PATTERN(Conditional) | 382 NOT_A_PATTERN(Conditional) | 
| 393 NOT_A_PATTERN(ContinueStatement) | 383 NOT_A_PATTERN(ContinueStatement) | 
| 394 NOT_A_PATTERN(CountOperation) | 384 NOT_A_PATTERN(CountOperation) | 
| 395 NOT_A_PATTERN(DebuggerStatement) | 385 NOT_A_PATTERN(DebuggerStatement) | 
| 396 NOT_A_PATTERN(DoWhileStatement) | 386 NOT_A_PATTERN(DoWhileStatement) | 
| 397 NOT_A_PATTERN(EmptyStatement) | 387 NOT_A_PATTERN(EmptyStatement) | 
| 398 NOT_A_PATTERN(SloppyBlockFunctionStatement) | 388 NOT_A_PATTERN(EmptyParentheses) | 
| 399 NOT_A_PATTERN(ExportDeclaration) | 389 NOT_A_PATTERN(ExportDeclaration) | 
| 400 NOT_A_PATTERN(ExpressionStatement) | 390 NOT_A_PATTERN(ExpressionStatement) | 
| 401 NOT_A_PATTERN(ForInStatement) | 391 NOT_A_PATTERN(ForInStatement) | 
| 402 NOT_A_PATTERN(ForOfStatement) | 392 NOT_A_PATTERN(ForOfStatement) | 
| 403 NOT_A_PATTERN(ForStatement) | 393 NOT_A_PATTERN(ForStatement) | 
| 404 NOT_A_PATTERN(FunctionDeclaration) | 394 NOT_A_PATTERN(FunctionDeclaration) | 
| 405 NOT_A_PATTERN(FunctionLiteral) | 395 NOT_A_PATTERN(FunctionLiteral) | 
| 406 NOT_A_PATTERN(IfStatement) | 396 NOT_A_PATTERN(IfStatement) | 
| 407 NOT_A_PATTERN(ImportDeclaration) | 397 NOT_A_PATTERN(ImportDeclaration) | 
| 408 NOT_A_PATTERN(Literal) | 398 NOT_A_PATTERN(Literal) | 
| 409 NOT_A_PATTERN(NativeFunctionLiteral) | 399 NOT_A_PATTERN(NativeFunctionLiteral) | 
| 410 NOT_A_PATTERN(Property) | 400 NOT_A_PATTERN(Property) | 
| 411 NOT_A_PATTERN(RegExpLiteral) | 401 NOT_A_PATTERN(RegExpLiteral) | 
| 412 NOT_A_PATTERN(ReturnStatement) | 402 NOT_A_PATTERN(ReturnStatement) | 
|  | 403 NOT_A_PATTERN(SloppyBlockFunctionStatement) | 
|  | 404 NOT_A_PATTERN(Spread) | 
| 413 NOT_A_PATTERN(SuperPropertyReference) | 405 NOT_A_PATTERN(SuperPropertyReference) | 
| 414 NOT_A_PATTERN(SuperCallReference) | 406 NOT_A_PATTERN(SuperCallReference) | 
| 415 NOT_A_PATTERN(SwitchStatement) | 407 NOT_A_PATTERN(SwitchStatement) | 
| 416 NOT_A_PATTERN(ThisFunction) | 408 NOT_A_PATTERN(ThisFunction) | 
| 417 NOT_A_PATTERN(Throw) | 409 NOT_A_PATTERN(Throw) | 
| 418 NOT_A_PATTERN(TryCatchStatement) | 410 NOT_A_PATTERN(TryCatchStatement) | 
| 419 NOT_A_PATTERN(TryFinallyStatement) | 411 NOT_A_PATTERN(TryFinallyStatement) | 
| 420 NOT_A_PATTERN(UnaryOperation) | 412 NOT_A_PATTERN(UnaryOperation) | 
| 421 NOT_A_PATTERN(VariableDeclaration) | 413 NOT_A_PATTERN(VariableDeclaration) | 
| 422 NOT_A_PATTERN(WhileStatement) | 414 NOT_A_PATTERN(WhileStatement) | 
| 423 NOT_A_PATTERN(WithStatement) | 415 NOT_A_PATTERN(WithStatement) | 
| 424 NOT_A_PATTERN(Yield) | 416 NOT_A_PATTERN(Yield) | 
| 425 | 417 | 
| 426 #undef NOT_A_PATTERN | 418 #undef NOT_A_PATTERN | 
| 427 }  // namespace internal | 419 }  // namespace internal | 
| 428 }  // namespace v8 | 420 }  // namespace v8 | 
| OLD | NEW | 
|---|