Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(812)

Side by Side Diff: src/parser.h

Issue 199233003: Revert "Move ParseAssignmentExpression to ParserBase." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 static void TearDownFunctionState(FunctionState* function_state) { 445 static void TearDownFunctionState(FunctionState* function_state) {
446 if (function_state->outer_function_state_ != NULL) { 446 if (function_state->outer_function_state_ != NULL) {
447 function_state->isolate_->set_ast_node_id( 447 function_state->isolate_->set_ast_node_id(
448 function_state->saved_ast_node_id_); 448 function_state->saved_ast_node_id_);
449 } 449 }
450 } 450 }
451 451
452 // Helper functions for recursive descent. 452 // Helper functions for recursive descent.
453 bool IsEvalOrArguments(Handle<String> identifier) const; 453 bool IsEvalOrArguments(Handle<String> identifier) const;
454 454
455 // Returns true if the expression is of type "this.foo".
456 static bool IsThisProperty(Expression* expression);
457
458 static bool IsBoilerplateProperty(ObjectLiteral::Property* property) { 455 static bool IsBoilerplateProperty(ObjectLiteral::Property* property) {
459 return ObjectLiteral::IsBoilerplateProperty(property); 456 return ObjectLiteral::IsBoilerplateProperty(property);
460 } 457 }
461 458
462 static bool IsArrayIndex(Handle<String> string, uint32_t* index) { 459 static bool IsArrayIndex(Handle<String> string, uint32_t* index) {
463 return !string.is_null() && string->AsArrayIndex(index); 460 return !string.is_null() && string->AsArrayIndex(index);
464 } 461 }
465 462
466 // Functions for encapsulating the differences between parsing and preparsing;
467 // operations interleaved with the recursive descent.
468 static void PushLiteralName(FuncNameInferrer* fni, Handle<String> id) { 463 static void PushLiteralName(FuncNameInferrer* fni, Handle<String> id) {
469 fni->PushLiteralName(id); 464 fni->PushLiteralName(id);
470 } 465 }
471 466
472 static void CheckFunctionLiteralInsideTopLevelObjectLiteral( 467 static void CheckFunctionLiteralInsideTopLevelObjectLiteral(
473 Scope* scope, Expression* value, bool* has_function) { 468 Scope* scope, Expression* value, bool* has_function) {
474 if (scope->DeclarationScope()->is_global_scope() && 469 if (scope->DeclarationScope()->is_global_scope() &&
475 value->AsFunctionLiteral() != NULL) { 470 value->AsFunctionLiteral() != NULL) {
476 *has_function = true; 471 *has_function = true;
477 value->AsFunctionLiteral()->set_pretenure(); 472 value->AsFunctionLiteral()->set_pretenure();
478 } 473 }
479 } 474 }
480 475
481 // If we assign a function literal to a property we pretenure the
482 // literal so it can be added as a constant function property.
483 static void CheckAssigningFunctionLiteralToProperty(Expression* left,
484 Expression* right);
485
486 // Signal a reference error if the expression is an invalid left-hand side
487 // expression. We could report this as a syntax error but for compatibility
488 // with JSC we choose to report the error at runtime.
489 Expression* ValidateAssignmentLeftHandSide(Expression* expression) const;
490
491 // Determine if the expression is a variable proxy and mark it as being used
492 // in an assignment or with a increment/decrement operator. This is currently
493 // used on for the statically checking assignments to harmony const bindings.
494 static Expression* MarkExpressionAsLValue(Expression* expression);
495
496 // Checks LHS expression for assignment and prefix/postfix increment/decrement
497 // in strict mode.
498 void CheckStrictModeLValue(Expression*expression, bool* ok);
499
500 // Reporting errors. 476 // Reporting errors.
501 void ReportMessageAt(Scanner::Location source_location, 477 void ReportMessageAt(Scanner::Location source_location,
502 const char* message, 478 const char* message,
503 Vector<const char*> args); 479 Vector<const char*> args);
504 void ReportMessage(const char* message, Vector<Handle<String> > args); 480 void ReportMessage(const char* message, Vector<Handle<String> > args);
505 void ReportMessageAt(Scanner::Location source_location, 481 void ReportMessageAt(Scanner::Location source_location,
506 const char* message, 482 const char* message,
507 Vector<Handle<String> > args); 483 Vector<Handle<String> > args);
508 484
509 // "null" return type creators. 485 // "null" return type creators.
(...skipping 30 matching lines...) Expand all
540 int pos, Scanner* scanner, 516 int pos, Scanner* scanner,
541 AstNodeFactory<AstConstructionVisitor>* factory); 517 AstNodeFactory<AstConstructionVisitor>* factory);
542 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) { 518 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) {
543 return new(zone) ZoneList<v8::internal::Expression*>(size, zone); 519 return new(zone) ZoneList<v8::internal::Expression*>(size, zone);
544 } 520 }
545 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { 521 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) {
546 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); 522 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone);
547 } 523 }
548 524
549 // Temporary glue; these functions will move to ParserBase. 525 // Temporary glue; these functions will move to ParserBase.
526 Expression* ParseAssignmentExpression(bool accept_IN, bool* ok);
550 Expression* ParseV8Intrinsic(bool* ok); 527 Expression* ParseV8Intrinsic(bool* ok);
551 FunctionLiteral* ParseFunctionLiteral( 528 FunctionLiteral* ParseFunctionLiteral(
552 Handle<String> name, 529 Handle<String> name,
553 Scanner::Location function_name_location, 530 Scanner::Location function_name_location,
554 bool name_is_strict_reserved, 531 bool name_is_strict_reserved,
555 bool is_generator, 532 bool is_generator,
556 int function_token_position, 533 int function_token_position,
557 FunctionLiteral::FunctionType type, 534 FunctionLiteral::FunctionType type,
558 bool* ok); 535 bool* ok);
559 Expression* ParseYieldExpression(bool* ok);
560 Expression* ParseConditionalExpression(bool accept_IN, bool* ok);
561 536
562 private: 537 private:
563 Parser* parser_; 538 Parser* parser_;
564 }; 539 };
565 540
566 541
567 class Parser : public ParserBase<ParserTraits> { 542 class Parser : public ParserBase<ParserTraits> {
568 public: 543 public:
569 explicit Parser(CompilationInfo* info); 544 explicit Parser(CompilationInfo* info);
570 ~Parser() { 545 ~Parser() {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 WhileStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok); 668 WhileStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok);
694 Statement* ParseForStatement(ZoneStringList* labels, bool* ok); 669 Statement* ParseForStatement(ZoneStringList* labels, bool* ok);
695 Statement* ParseThrowStatement(bool* ok); 670 Statement* ParseThrowStatement(bool* ok);
696 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); 671 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value);
697 TryStatement* ParseTryStatement(bool* ok); 672 TryStatement* ParseTryStatement(bool* ok);
698 DebuggerStatement* ParseDebuggerStatement(bool* ok); 673 DebuggerStatement* ParseDebuggerStatement(bool* ok);
699 674
700 // Support for hamony block scoped bindings. 675 // Support for hamony block scoped bindings.
701 Block* ParseScopedBlock(ZoneStringList* labels, bool* ok); 676 Block* ParseScopedBlock(ZoneStringList* labels, bool* ok);
702 677
678 Expression* ParseAssignmentExpression(bool accept_IN, bool* ok);
703 Expression* ParseYieldExpression(bool* ok); 679 Expression* ParseYieldExpression(bool* ok);
704 Expression* ParseConditionalExpression(bool accept_IN, bool* ok); 680 Expression* ParseConditionalExpression(bool accept_IN, bool* ok);
705 Expression* ParseBinaryExpression(int prec, bool accept_IN, bool* ok); 681 Expression* ParseBinaryExpression(int prec, bool accept_IN, bool* ok);
706 Expression* ParseUnaryExpression(bool* ok); 682 Expression* ParseUnaryExpression(bool* ok);
707 Expression* ParsePostfixExpression(bool* ok); 683 Expression* ParsePostfixExpression(bool* ok);
708 Expression* ParseLeftHandSideExpression(bool* ok); 684 Expression* ParseLeftHandSideExpression(bool* ok);
709 Expression* ParseMemberWithNewPrefixesExpression(bool* ok); 685 Expression* ParseMemberWithNewPrefixesExpression(bool* ok);
710 Expression* ParseMemberExpression(bool* ok); 686 Expression* ParseMemberExpression(bool* ok);
711 Expression* ParseMemberExpressionContinuation(Expression* expression, 687 Expression* ParseMemberExpressionContinuation(Expression* expression,
712 bool* ok); 688 bool* ok);
(...skipping 15 matching lines...) Expand all
728 bool* ok); 704 bool* ok);
729 705
730 // Magical syntax support. 706 // Magical syntax support.
731 Expression* ParseV8Intrinsic(bool* ok); 707 Expression* ParseV8Intrinsic(bool* ok);
732 708
733 bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode); 709 bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode);
734 710
735 // Get odd-ball literals. 711 // Get odd-ball literals.
736 Literal* GetLiteralUndefined(int position); 712 Literal* GetLiteralUndefined(int position);
737 713
714 // Determine if the expression is a variable proxy and mark it as being used
715 // in an assignment or with a increment/decrement operator. This is currently
716 // used on for the statically checking assignments to harmony const bindings.
717 void MarkAsLValue(Expression* expression);
718
719 // Strict mode validation of LValue expressions
720 void CheckStrictModeLValue(Expression* expression,
721 bool* ok);
722
738 // For harmony block scoping mode: Check if the scope has conflicting var/let 723 // For harmony block scoping mode: Check if the scope has conflicting var/let
739 // declarations from different scopes. It covers for example 724 // declarations from different scopes. It covers for example
740 // 725 //
741 // function f() { { { var x; } let x; } } 726 // function f() { { { var x; } let x; } }
742 // function g() { { var x; let x; } } 727 // function g() { { var x; let x; } }
743 // 728 //
744 // The var declarations are hoisted to the function scope, but originate from 729 // The var declarations are hoisted to the function scope, but originate from
745 // a scope where the name has also been let bound or the var declaration is 730 // a scope where the name has also been let bound or the var declaration is
746 // hoisted over such a scope. 731 // hoisted over such a scope.
747 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); 732 void CheckConflictingVarDeclarations(Scope* scope, bool* ok);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 private: 813 private:
829 static const int kLiteralTypeSlot = 0; 814 static const int kLiteralTypeSlot = 0;
830 static const int kElementsSlot = 1; 815 static const int kElementsSlot = 1;
831 816
832 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 817 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
833 }; 818 };
834 819
835 } } // namespace v8::internal 820 } } // namespace v8::internal
836 821
837 #endif // V8_PARSER_H_ 822 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698