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

Side by Side Diff: src/parser.h

Issue 6606006: [Isolates] Merge 6500:6700 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 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 | « src/objects-visiting.cc ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 class Parser { 419 class Parser {
420 public: 420 public:
421 Parser(Handle<Script> script, 421 Parser(Handle<Script> script,
422 bool allow_natives_syntax, 422 bool allow_natives_syntax,
423 v8::Extension* extension, 423 v8::Extension* extension,
424 ScriptDataImpl* pre_data); 424 ScriptDataImpl* pre_data);
425 virtual ~Parser() { } 425 virtual ~Parser() { }
426 426
427 // Returns NULL if parsing failed. 427 // Returns NULL if parsing failed.
428 FunctionLiteral* ParseProgram(Handle<String> source, 428 FunctionLiteral* ParseProgram(Handle<String> source,
429 bool in_global_context); 429 bool in_global_context,
430 StrictModeFlag strict_mode);
430 431
431 FunctionLiteral* ParseLazy(Handle<SharedFunctionInfo> info); 432 FunctionLiteral* ParseLazy(Handle<SharedFunctionInfo> info);
432 433
433 void ReportMessageAt(Scanner::Location loc, 434 void ReportMessageAt(Scanner::Location loc,
434 const char* message, 435 const char* message,
435 Vector<const char*> args); 436 Vector<const char*> args);
436 void ReportMessageAt(Scanner::Location loc, 437 void ReportMessageAt(Scanner::Location loc,
437 const char* message, 438 const char* message,
438 Vector<Handle<String> > args); 439 Vector<Handle<String> > args);
439 440
440 protected: 441 protected:
442 // Limit on number of function parameters is chosen arbitrarily.
443 // Code::Flags uses only the low 17 bits of num-parameters to
444 // construct a hashable id, so if more than 2^17 are allowed, this
445 // should be checked.
446 static const int kMaxNumFunctionParameters = 32766;
441 FunctionLiteral* ParseLazy(Handle<SharedFunctionInfo> info, 447 FunctionLiteral* ParseLazy(Handle<SharedFunctionInfo> info,
442 UC16CharacterStream* source, 448 UC16CharacterStream* source,
443 ZoneScope* zone_scope); 449 ZoneScope* zone_scope);
444 enum Mode { 450 enum Mode {
445 PARSE_LAZILY, 451 PARSE_LAZILY,
446 PARSE_EAGERLY 452 PARSE_EAGERLY
447 }; 453 };
448 454
449 Isolate* isolate() { return isolate_; } 455 Isolate* isolate() { return isolate_; }
450 456
451 // Called by ParseProgram after setting up the scanner. 457 // Called by ParseProgram after setting up the scanner.
452 FunctionLiteral* DoParseProgram(Handle<String> source, 458 FunctionLiteral* DoParseProgram(Handle<String> source,
453 bool in_global_context, 459 bool in_global_context,
460 StrictModeFlag strict_mode,
454 ZoneScope* zone_scope); 461 ZoneScope* zone_scope);
455 462
456 // Report syntax error 463 // Report syntax error
457 void ReportUnexpectedToken(Token::Value token); 464 void ReportUnexpectedToken(Token::Value token);
458 void ReportInvalidPreparseData(Handle<String> name, bool* ok); 465 void ReportInvalidPreparseData(Handle<String> name, bool* ok);
459 void ReportMessage(const char* message, Vector<const char*> args); 466 void ReportMessage(const char* message, Vector<const char*> args);
460 467
461 bool inside_with() const { return with_nesting_level_ > 0; } 468 bool inside_with() const { return with_nesting_level_ > 0; }
462 V8JavaScriptScanner& scanner() { return scanner_; } 469 V8JavaScriptScanner& scanner() { return scanner_; }
463 Mode mode() const { return mode_; } 470 Mode mode() const { return mode_; }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 Handle<Object> GetBoilerplateValue(Expression* expression); 551 Handle<Object> GetBoilerplateValue(Expression* expression);
545 552
546 enum FunctionLiteralType { 553 enum FunctionLiteralType {
547 EXPRESSION, 554 EXPRESSION,
548 DECLARATION, 555 DECLARATION,
549 NESTED 556 NESTED
550 }; 557 };
551 558
552 ZoneList<Expression*>* ParseArguments(bool* ok); 559 ZoneList<Expression*>* ParseArguments(bool* ok);
553 FunctionLiteral* ParseFunctionLiteral(Handle<String> var_name, 560 FunctionLiteral* ParseFunctionLiteral(Handle<String> var_name,
561 bool name_is_reserved,
554 int function_token_position, 562 int function_token_position,
555 FunctionLiteralType type, 563 FunctionLiteralType type,
556 bool* ok); 564 bool* ok);
557 565
558 566
559 // Magical syntax support. 567 // Magical syntax support.
560 Expression* ParseV8Intrinsic(bool* ok); 568 Expression* ParseV8Intrinsic(bool* ok);
561 569
562 INLINE(Token::Value peek()) { 570 INLINE(Token::Value peek()) {
563 if (stack_overflow_) return Token::ILLEGAL; 571 if (stack_overflow_) return Token::ILLEGAL;
564 return scanner().peek(); 572 return scanner().peek();
565 } 573 }
566 574
567 INLINE(Token::Value Next()) { 575 INLINE(Token::Value Next()) {
568 // BUG 1215673: Find a thread safe way to set a stack limit in 576 // BUG 1215673: Find a thread safe way to set a stack limit in
569 // pre-parse mode. Otherwise, we cannot safely pre-parse from other 577 // pre-parse mode. Otherwise, we cannot safely pre-parse from other
570 // threads. 578 // threads.
571 if (stack_overflow_) { 579 if (stack_overflow_) {
572 return Token::ILLEGAL; 580 return Token::ILLEGAL;
573 } 581 }
574 if (StackLimitCheck(isolate()).HasOverflowed()) { 582 if (StackLimitCheck(isolate()).HasOverflowed()) {
575 // Any further calls to Next or peek will return the illegal token. 583 // Any further calls to Next or peek will return the illegal token.
576 // The current call must return the next token, which might already 584 // The current call must return the next token, which might already
577 // have been peek'ed. 585 // have been peek'ed.
578 stack_overflow_ = true; 586 stack_overflow_ = true;
579 } 587 }
580 return scanner().Next(); 588 return scanner().Next();
581 } 589 }
582 590
591 bool peek_any_identifier();
592
583 INLINE(void Consume(Token::Value token)); 593 INLINE(void Consume(Token::Value token));
584 void Expect(Token::Value token, bool* ok); 594 void Expect(Token::Value token, bool* ok);
585 bool Check(Token::Value token); 595 bool Check(Token::Value token);
586 void ExpectSemicolon(bool* ok); 596 void ExpectSemicolon(bool* ok);
587 597
588 Handle<String> LiteralString(PretenureFlag tenured) { 598 Handle<String> LiteralString(PretenureFlag tenured) {
589 if (scanner().is_literal_ascii()) { 599 if (scanner().is_literal_ascii()) {
590 return isolate_->factory()->NewStringFromAscii( 600 return isolate_->factory()->NewStringFromAscii(
591 scanner().literal_ascii_string(), tenured); 601 scanner().literal_ascii_string(), tenured);
592 } else { 602 } else {
(...skipping 13 matching lines...) Expand all
606 } 616 }
607 617
608 Handle<String> GetSymbol(bool* ok); 618 Handle<String> GetSymbol(bool* ok);
609 619
610 // Get odd-ball literals. 620 // Get odd-ball literals.
611 Literal* GetLiteralUndefined(); 621 Literal* GetLiteralUndefined();
612 Literal* GetLiteralTheHole(); 622 Literal* GetLiteralTheHole();
613 Literal* GetLiteralNumber(double value); 623 Literal* GetLiteralNumber(double value);
614 624
615 Handle<String> ParseIdentifier(bool* ok); 625 Handle<String> ParseIdentifier(bool* ok);
626 Handle<String> ParseIdentifierOrReservedWord(bool* is_reserved, bool* ok);
616 Handle<String> ParseIdentifierName(bool* ok); 627 Handle<String> ParseIdentifierName(bool* ok);
617 Handle<String> ParseIdentifierOrGetOrSet(bool* is_get, 628 Handle<String> ParseIdentifierOrGetOrSet(bool* is_get,
618 bool* is_set, 629 bool* is_set,
619 bool* ok); 630 bool* ok);
620 631
632 // Strict mode validation of LValue expressions
633 void CheckStrictModeLValue(Expression* expression,
634 const char* error,
635 bool* ok);
636
621 // Strict mode octal literal validation. 637 // Strict mode octal literal validation.
622 void CheckOctalLiteral(int beg_pos, int end_pos, bool* ok); 638 void CheckOctalLiteral(int beg_pos, int end_pos, bool* ok);
623 639
624 // Parser support 640 // Parser support
625 VariableProxy* Declare(Handle<String> name, Variable::Mode mode, 641 VariableProxy* Declare(Handle<String> name, Variable::Mode mode,
626 FunctionLiteral* fun, 642 FunctionLiteral* fun,
627 bool resolve, 643 bool resolve,
628 bool* ok); 644 bool* ok);
629 645
630 bool TargetStackContainsLabel(Handle<String> label); 646 bool TargetStackContainsLabel(Handle<String> label);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 // Converts the currently parsed literal to a JavaScript String. 802 // Converts the currently parsed literal to a JavaScript String.
787 Handle<String> GetString(); 803 Handle<String> GetString();
788 804
789 Isolate* isolate_; 805 Isolate* isolate_;
790 JsonScanner scanner_; 806 JsonScanner scanner_;
791 bool stack_overflow_; 807 bool stack_overflow_;
792 }; 808 };
793 } } // namespace v8::internal 809 } } // namespace v8::internal
794 810
795 #endif // V8_PARSER_H_ 811 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « src/objects-visiting.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698