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

Side by Side Diff: src/parser.h

Issue 7348008: Merge up to 8597 to experimental/gc from the bleeding edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 5 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 | « src/objects-visiting-inl.h ('k') | 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 Vector<const char*> args_; 65 Vector<const char*> args_;
66 }; 66 };
67 67
68 68
69 class FunctionEntry BASE_EMBEDDED { 69 class FunctionEntry BASE_EMBEDDED {
70 public: 70 public:
71 explicit FunctionEntry(Vector<unsigned> backing) : backing_(backing) { } 71 explicit FunctionEntry(Vector<unsigned> backing) : backing_(backing) { }
72 FunctionEntry() : backing_(Vector<unsigned>::empty()) { } 72 FunctionEntry() : backing_(Vector<unsigned>::empty()) { }
73 73
74 int start_pos() { return backing_[kStartPosOffset]; } 74 int start_pos() { return backing_[kStartPosOffset]; }
75 void set_start_pos(int value) { backing_[kStartPosOffset] = value; }
76
77 int end_pos() { return backing_[kEndPosOffset]; } 75 int end_pos() { return backing_[kEndPosOffset]; }
78 void set_end_pos(int value) { backing_[kEndPosOffset] = value; }
79
80 int literal_count() { return backing_[kLiteralCountOffset]; } 76 int literal_count() { return backing_[kLiteralCountOffset]; }
81 void set_literal_count(int value) { backing_[kLiteralCountOffset] = value; }
82
83 int property_count() { return backing_[kPropertyCountOffset]; } 77 int property_count() { return backing_[kPropertyCountOffset]; }
84 void set_property_count(int value) { 78 bool strict_mode() { return backing_[kStrictModeOffset] != 0; }
85 backing_[kPropertyCountOffset] = value;
86 }
87 79
88 bool is_valid() { return backing_.length() > 0; } 80 bool is_valid() { return backing_.length() > 0; }
89 81
90 static const int kSize = 4; 82 static const int kSize = 5;
91 83
92 private: 84 private:
93 Vector<unsigned> backing_; 85 Vector<unsigned> backing_;
94 static const int kStartPosOffset = 0; 86 static const int kStartPosOffset = 0;
95 static const int kEndPosOffset = 1; 87 static const int kEndPosOffset = 1;
96 static const int kLiteralCountOffset = 2; 88 static const int kLiteralCountOffset = 2;
97 static const int kPropertyCountOffset = 3; 89 static const int kPropertyCountOffset = 3;
90 static const int kStrictModeOffset = 4;
98 }; 91 };
99 92
100 93
101 class ScriptDataImpl : public ScriptData { 94 class ScriptDataImpl : public ScriptData {
102 public: 95 public:
103 explicit ScriptDataImpl(Vector<unsigned> store) 96 explicit ScriptDataImpl(Vector<unsigned> store)
104 : store_(store), 97 : store_(store),
105 owns_store_(true) { } 98 owns_store_(true) { }
106 99
107 // Create an empty ScriptDataImpl that is guaranteed to not satisfy 100 // Create an empty ScriptDataImpl that is guaranteed to not satisfy
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 429
437 FunctionLiteral* ParseLazy(CompilationInfo* info); 430 FunctionLiteral* ParseLazy(CompilationInfo* info);
438 431
439 void ReportMessageAt(Scanner::Location loc, 432 void ReportMessageAt(Scanner::Location loc,
440 const char* message, 433 const char* message,
441 Vector<const char*> args); 434 Vector<const char*> args);
442 void ReportMessageAt(Scanner::Location loc, 435 void ReportMessageAt(Scanner::Location loc,
443 const char* message, 436 const char* message,
444 Vector<Handle<String> > args); 437 Vector<Handle<String> > args);
445 438
446 protected: 439 private:
447 // Limit on number of function parameters is chosen arbitrarily. 440 // Limit on number of function parameters is chosen arbitrarily.
448 // Code::Flags uses only the low 17 bits of num-parameters to 441 // Code::Flags uses only the low 17 bits of num-parameters to
449 // construct a hashable id, so if more than 2^17 are allowed, this 442 // construct a hashable id, so if more than 2^17 are allowed, this
450 // should be checked. 443 // should be checked.
451 static const int kMaxNumFunctionParameters = 32766; 444 static const int kMaxNumFunctionParameters = 32766;
452 static const int kMaxNumFunctionLocals = 32767; 445 static const int kMaxNumFunctionLocals = 32767;
453 FunctionLiteral* ParseLazy(CompilationInfo* info, 446 FunctionLiteral* ParseLazy(CompilationInfo* info,
454 UC16CharacterStream* source, 447 UC16CharacterStream* source,
455 ZoneScope* zone_scope); 448 ZoneScope* zone_scope);
456 enum Mode { 449 enum Mode {
457 PARSE_LAZILY, 450 PARSE_LAZILY,
458 PARSE_EAGERLY 451 PARSE_EAGERLY
459 }; 452 };
460 453
461 Isolate* isolate() { return isolate_; } 454 Isolate* isolate() { return isolate_; }
462 Zone* zone() { return isolate_->zone(); } 455 Zone* zone() { return isolate_->zone(); }
463 456
464 // Called by ParseProgram after setting up the scanner. 457 // Called by ParseProgram after setting up the scanner.
465 FunctionLiteral* DoParseProgram(Handle<String> source, 458 FunctionLiteral* DoParseProgram(Handle<String> source,
466 bool in_global_context, 459 bool in_global_context,
467 StrictModeFlag strict_mode, 460 StrictModeFlag strict_mode,
468 ZoneScope* zone_scope); 461 ZoneScope* zone_scope);
469 462
470 // Report syntax error 463 // Report syntax error
471 void ReportUnexpectedToken(Token::Value token); 464 void ReportUnexpectedToken(Token::Value token);
472 void ReportInvalidPreparseData(Handle<String> name, bool* ok); 465 void ReportInvalidPreparseData(Handle<String> name, bool* ok);
473 void ReportMessage(const char* message, Vector<const char*> args); 466 void ReportMessage(const char* message, Vector<const char*> args);
474 467
475 bool inside_with() const { return with_nesting_level_ > 0; } 468 bool inside_with() const { return with_nesting_level_ > 0; }
476 V8JavaScriptScanner& scanner() { return scanner_; } 469 JavaScriptScanner& scanner() { return scanner_; }
477 Mode mode() const { return mode_; } 470 Mode mode() const { return mode_; }
478 ScriptDataImpl* pre_data() const { return pre_data_; } 471 ScriptDataImpl* pre_data() const { return pre_data_; }
479 472
480 // Check if the given string is 'eval' or 'arguments'. 473 // Check if the given string is 'eval' or 'arguments'.
481 bool IsEvalOrArguments(Handle<String> string); 474 bool IsEvalOrArguments(Handle<String> string);
482 475
483 // All ParseXXX functions take as the last argument an *ok parameter 476 // All ParseXXX functions take as the last argument an *ok parameter
484 // which is set to false if parsing failed; it is unchanged otherwise. 477 // which is set to false if parsing failed; it is unchanged otherwise.
485 // By making the 'exception handling' explicit, we are forced to check 478 // By making the 'exception handling' explicit, we are forced to check
486 // for failure at the call sites. 479 // for failure at the call sites.
487 void* ParseSourceElements(ZoneList<Statement*>* processor, 480 void* ParseSourceElements(ZoneList<Statement*>* processor,
488 int end_token, bool* ok); 481 int end_token, bool* ok);
489 Statement* ParseStatement(ZoneStringList* labels, bool* ok); 482 Statement* ParseStatement(ZoneStringList* labels, bool* ok);
490 Statement* ParseFunctionDeclaration(bool* ok); 483 Statement* ParseFunctionDeclaration(bool* ok);
491 Statement* ParseNativeDeclaration(bool* ok); 484 Statement* ParseNativeDeclaration(bool* ok);
492 Block* ParseBlock(ZoneStringList* labels, bool* ok); 485 Block* ParseBlock(ZoneStringList* labels, bool* ok);
493 Block* ParseVariableStatement(bool* ok); 486 Block* ParseVariableStatement(bool* ok);
494 Block* ParseVariableDeclarations(bool accept_IN, Expression** var, bool* ok); 487 Block* ParseVariableDeclarations(bool accept_IN,
488 Handle<String>* out,
489 bool* ok);
495 Statement* ParseExpressionOrLabelledStatement(ZoneStringList* labels, 490 Statement* ParseExpressionOrLabelledStatement(ZoneStringList* labels,
496 bool* ok); 491 bool* ok);
497 IfStatement* ParseIfStatement(ZoneStringList* labels, bool* ok); 492 IfStatement* ParseIfStatement(ZoneStringList* labels, bool* ok);
498 Statement* ParseContinueStatement(bool* ok); 493 Statement* ParseContinueStatement(bool* ok);
499 Statement* ParseBreakStatement(ZoneStringList* labels, bool* ok); 494 Statement* ParseBreakStatement(ZoneStringList* labels, bool* ok);
500 Statement* ParseReturnStatement(bool* ok); 495 Statement* ParseReturnStatement(bool* ok);
501 Block* WithHelper(Expression* obj, 496 Block* WithHelper(Expression* obj, ZoneStringList* labels, bool* ok);
502 ZoneStringList* labels,
503 bool is_catch_block,
504 bool* ok);
505 Statement* ParseWithStatement(ZoneStringList* labels, bool* ok); 497 Statement* ParseWithStatement(ZoneStringList* labels, bool* ok);
506 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); 498 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok);
507 SwitchStatement* ParseSwitchStatement(ZoneStringList* labels, bool* ok); 499 SwitchStatement* ParseSwitchStatement(ZoneStringList* labels, bool* ok);
508 DoWhileStatement* ParseDoWhileStatement(ZoneStringList* labels, bool* ok); 500 DoWhileStatement* ParseDoWhileStatement(ZoneStringList* labels, bool* ok);
509 WhileStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok); 501 WhileStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok);
510 Statement* ParseForStatement(ZoneStringList* labels, bool* ok); 502 Statement* ParseForStatement(ZoneStringList* labels, bool* ok);
511 Statement* ParseThrowStatement(bool* ok); 503 Statement* ParseThrowStatement(bool* ok);
512 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); 504 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value);
513 TryStatement* ParseTryStatement(bool* ok); 505 TryStatement* ParseTryStatement(bool* ok);
514 DebuggerStatement* ParseDebuggerStatement(bool* ok); 506 DebuggerStatement* ParseDebuggerStatement(bool* ok);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 } 618 }
627 619
628 Handle<String> GetSymbol(bool* ok); 620 Handle<String> GetSymbol(bool* ok);
629 621
630 // Get odd-ball literals. 622 // Get odd-ball literals.
631 Literal* GetLiteralUndefined(); 623 Literal* GetLiteralUndefined();
632 Literal* GetLiteralTheHole(); 624 Literal* GetLiteralTheHole();
633 Literal* GetLiteralNumber(double value); 625 Literal* GetLiteralNumber(double value);
634 626
635 Handle<String> ParseIdentifier(bool* ok); 627 Handle<String> ParseIdentifier(bool* ok);
636 Handle<String> ParseIdentifierOrReservedWord(bool* is_reserved, bool* ok); 628 Handle<String> ParseIdentifierOrStrictReservedWord(
629 bool* is_strict_reserved, bool* ok);
637 Handle<String> ParseIdentifierName(bool* ok); 630 Handle<String> ParseIdentifierName(bool* ok);
638 Handle<String> ParseIdentifierOrGetOrSet(bool* is_get, 631 Handle<String> ParseIdentifierNameOrGetOrSet(bool* is_get,
639 bool* is_set, 632 bool* is_set,
640 bool* ok); 633 bool* ok);
641 634
642 // Strict mode validation of LValue expressions 635 // Strict mode validation of LValue expressions
643 void CheckStrictModeLValue(Expression* expression, 636 void CheckStrictModeLValue(Expression* expression,
644 const char* error, 637 const char* error,
645 bool* ok); 638 bool* ok);
646 639
647 // Strict mode octal literal validation. 640 // Strict mode octal literal validation.
648 void CheckOctalLiteral(int beg_pos, int end_pos, bool* ok); 641 void CheckOctalLiteral(int beg_pos, int end_pos, bool* ok);
649 642
650 // Parser support 643 // Parser support
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 691
699 // Generic AST generator for throwing errors from compiled code. 692 // Generic AST generator for throwing errors from compiled code.
700 Expression* NewThrowError(Handle<String> constructor, 693 Expression* NewThrowError(Handle<String> constructor,
701 Handle<String> type, 694 Handle<String> type,
702 Vector< Handle<Object> > arguments); 695 Vector< Handle<Object> > arguments);
703 696
704 Isolate* isolate_; 697 Isolate* isolate_;
705 ZoneList<Handle<String> > symbol_cache_; 698 ZoneList<Handle<String> > symbol_cache_;
706 699
707 Handle<Script> script_; 700 Handle<Script> script_;
708 V8JavaScriptScanner scanner_; 701 JavaScriptScanner scanner_;
709 702
710 Scope* top_scope_; 703 Scope* top_scope_;
711 int with_nesting_level_; 704 int with_nesting_level_;
712 705
713 LexicalScope* lexical_scope_; 706 LexicalScope* lexical_scope_;
714 Mode mode_; 707 Mode mode_;
715 708
716 Target* target_stack_; // for break, continue statements 709 Target* target_stack_; // for break, continue statements
717 bool allow_natives_syntax_; 710 bool allow_natives_syntax_;
718 v8::Extension* extension_; 711 v8::Extension* extension_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 private: 749 private:
757 static const int kTypeSlot = 0; 750 static const int kTypeSlot = 0;
758 static const int kElementsSlot = 1; 751 static const int kElementsSlot = 1;
759 752
760 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 753 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
761 }; 754 };
762 755
763 } } // namespace v8::internal 756 } } // namespace v8::internal
764 757
765 #endif // V8_PARSER_H_ 758 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « src/objects-visiting-inl.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698