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

Side by Side Diff: src/parser.cc

Issue 7374002: Refactor allocation policies. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
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/parser.h ('k') | src/profile-generator.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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 108
109 109
110 void RegExpBuilder::FlushText() { 110 void RegExpBuilder::FlushText() {
111 FlushCharacters(); 111 FlushCharacters();
112 int num_text = text_.length(); 112 int num_text = text_.length();
113 if (num_text == 0) { 113 if (num_text == 0) {
114 return; 114 return;
115 } else if (num_text == 1) { 115 } else if (num_text == 1) {
116 terms_.Add(text_.last()); 116 terms_.Add(text_.last());
117 } else { 117 } else {
118 RegExpText* text = new(zone()) RegExpText(); 118 RegExpText* text = new(zone()) RegExpText(zone());
119 for (int i = 0; i < num_text; i++) 119 for (int i = 0; i < num_text; i++)
120 text_.Get(i)->AppendToText(text); 120 text_.Get(i)->AppendToText(text);
121 terms_.Add(text); 121 terms_.Add(text);
122 } 122 }
123 text_.Clear(); 123 text_.Clear();
124 } 124 }
125 125
126 126
127 void RegExpBuilder::AddCharacter(uc16 c) { 127 void RegExpBuilder::AddCharacter(uc16 c) {
128 pending_empty_ = false; 128 pending_empty_ = false;
129 if (characters_ == NULL) { 129 if (characters_ == NULL) {
130 characters_ = new(zone()) ZoneList<uc16>(4); 130 characters_ = ZoneList<uc16>::New(zone(), 4);
131 } 131 }
132 characters_->Add(c); 132 characters_->Add(c);
133 LAST(ADD_CHAR); 133 LAST(ADD_CHAR);
134 } 134 }
135 135
136 136
137 void RegExpBuilder::AddEmpty() { 137 void RegExpBuilder::AddEmpty() {
138 pending_empty_ = true; 138 pending_empty_ = true;
139 } 139 }
140 140
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 #undef DUMMY 565 #undef DUMMY
566 566
567 // ---------------------------------------------------------------------------- 567 // ----------------------------------------------------------------------------
568 // Implementation of Parser 568 // Implementation of Parser
569 569
570 Parser::Parser(Handle<Script> script, 570 Parser::Parser(Handle<Script> script,
571 bool allow_natives_syntax, 571 bool allow_natives_syntax,
572 v8::Extension* extension, 572 v8::Extension* extension,
573 ScriptDataImpl* pre_data) 573 ScriptDataImpl* pre_data)
574 : isolate_(script->GetIsolate()), 574 : isolate_(script->GetIsolate()),
575 symbol_cache_(pre_data ? pre_data->symbol_count() : 0), 575 symbol_cache_(isolate_->zone(), pre_data ? pre_data->symbol_count() : 0),
576 script_(script), 576 script_(script),
577 scanner_(isolate_->unicode_cache()), 577 scanner_(isolate_->unicode_cache()),
578 top_scope_(NULL), 578 top_scope_(NULL),
579 with_nesting_level_(0), 579 with_nesting_level_(0),
580 lexical_scope_(NULL), 580 lexical_scope_(NULL),
581 target_stack_(NULL), 581 target_stack_(NULL),
582 allow_natives_syntax_(allow_natives_syntax), 582 allow_natives_syntax_(allow_natives_syntax),
583 extension_(extension), 583 extension_(extension),
584 pre_data_(pre_data), 584 pre_data_(pre_data),
585 fni_(NULL), 585 fni_(NULL),
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 ? Scope::GLOBAL_SCOPE 632 ? Scope::GLOBAL_SCOPE
633 : Scope::EVAL_SCOPE; 633 : Scope::EVAL_SCOPE;
634 Handle<String> no_name = isolate()->factory()->empty_symbol(); 634 Handle<String> no_name = isolate()->factory()->empty_symbol();
635 635
636 FunctionLiteral* result = NULL; 636 FunctionLiteral* result = NULL;
637 { Scope* scope = NewScope(top_scope_, type, inside_with()); 637 { Scope* scope = NewScope(top_scope_, type, inside_with());
638 LexicalScope lexical_scope(this, scope, isolate()); 638 LexicalScope lexical_scope(this, scope, isolate());
639 if (strict_mode == kStrictMode) { 639 if (strict_mode == kStrictMode) {
640 top_scope_->EnableStrictMode(); 640 top_scope_->EnableStrictMode();
641 } 641 }
642 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16); 642 ZoneList<Statement*>* body = ZoneList<Statement*>::New(zone(), 16);
643 bool ok = true; 643 bool ok = true;
644 int beg_loc = scanner().location().beg_pos; 644 int beg_loc = scanner().location().beg_pos;
645 ParseSourceElements(body, Token::EOS, &ok); 645 ParseSourceElements(body, Token::EOS, &ok);
646 if (ok && top_scope_->is_strict_mode()) { 646 if (ok && top_scope_->is_strict_mode()) {
647 CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok); 647 CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok);
648 } 648 }
649 if (ok) { 649 if (ok) {
650 result = new(zone()) FunctionLiteral( 650 result = new(zone()) FunctionLiteral(
651 no_name, 651 no_name,
652 top_scope_, 652 top_scope_,
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 void AssignmentFromSomethingElse() { 1063 void AssignmentFromSomethingElse() {
1064 // The this assignment is not a simple one. 1064 // The this assignment is not a simple one.
1065 only_simple_this_property_assignments_ = false; 1065 only_simple_this_property_assignments_ = false;
1066 } 1066 }
1067 1067
1068 void EnsureAllocation() { 1068 void EnsureAllocation() {
1069 if (names_ == NULL) { 1069 if (names_ == NULL) {
1070 ASSERT(assigned_arguments_ == NULL); 1070 ASSERT(assigned_arguments_ == NULL);
1071 ASSERT(assigned_constants_ == NULL); 1071 ASSERT(assigned_constants_ == NULL);
1072 Zone* zone = isolate_->zone(); 1072 Zone* zone = isolate_->zone();
1073 names_ = new(zone) ZoneStringList(4); 1073 names_ = ZoneStringList::New(zone, 4);
1074 assigned_arguments_ = new(zone) ZoneList<int>(4); 1074 assigned_arguments_ = ZoneList<int>::New(zone, 4);
1075 assigned_constants_ = new(zone) ZoneObjectList(4); 1075 assigned_constants_ = ZoneObjectList::New(zone, 4);
1076 } 1076 }
1077 } 1077 }
1078 1078
1079 Isolate* isolate_; 1079 Isolate* isolate_;
1080 bool only_simple_this_property_assignments_; 1080 bool only_simple_this_property_assignments_;
1081 ZoneStringList* names_; 1081 ZoneStringList* names_;
1082 ZoneList<int>* assigned_arguments_; 1082 ZoneList<int>* assigned_arguments_;
1083 ZoneObjectList* assigned_constants_; 1083 ZoneObjectList* assigned_constants_;
1084 }; 1084 };
1085 1085
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 case Token::THROW: 1255 case Token::THROW:
1256 stmt = ParseThrowStatement(ok); 1256 stmt = ParseThrowStatement(ok);
1257 break; 1257 break;
1258 1258
1259 case Token::TRY: { 1259 case Token::TRY: {
1260 // NOTE: It is somewhat complicated to have labels on 1260 // NOTE: It is somewhat complicated to have labels on
1261 // try-statements. When breaking out of a try-finally statement, 1261 // try-statements. When breaking out of a try-finally statement,
1262 // one must take great care not to treat it as a 1262 // one must take great care not to treat it as a
1263 // fall-through. It is much easier just to wrap the entire 1263 // fall-through. It is much easier just to wrap the entire
1264 // try-statement in a statement block and put the labels there 1264 // try-statement in a statement block and put the labels there
1265 Block* result = new(zone()) Block(labels, 1, false); 1265 Block* result = new(zone()) Block(zone(), labels, 1, false);
1266 Target target(&this->target_stack_, result); 1266 Target target(&this->target_stack_, result);
1267 TryStatement* statement = ParseTryStatement(CHECK_OK); 1267 TryStatement* statement = ParseTryStatement(CHECK_OK);
1268 if (statement) { 1268 if (statement) {
1269 statement->set_statement_pos(statement_pos); 1269 statement->set_statement_pos(statement_pos);
1270 } 1270 }
1271 if (result) result->AddStatement(statement); 1271 if (result) result->AddStatement(statement);
1272 return result; 1272 return result;
1273 } 1273 }
1274 1274
1275 case Token::FUNCTION: { 1275 case Token::FUNCTION: {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 1482
1483 1483
1484 Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) { 1484 Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) {
1485 // Block :: 1485 // Block ::
1486 // '{' Statement* '}' 1486 // '{' Statement* '}'
1487 1487
1488 // Note that a Block does not introduce a new execution scope! 1488 // Note that a Block does not introduce a new execution scope!
1489 // (ECMA-262, 3rd, 12.2) 1489 // (ECMA-262, 3rd, 12.2)
1490 // 1490 //
1491 // Construct block expecting 16 statements. 1491 // Construct block expecting 16 statements.
1492 Block* result = new(zone()) Block(labels, 16, false); 1492 Block* result = new(zone()) Block(zone(), labels, 16, false);
1493 Target target(&this->target_stack_, result); 1493 Target target(&this->target_stack_, result);
1494 Expect(Token::LBRACE, CHECK_OK); 1494 Expect(Token::LBRACE, CHECK_OK);
1495 InitializationBlockFinder block_finder(top_scope_, target_stack_); 1495 InitializationBlockFinder block_finder(top_scope_, target_stack_);
1496 while (peek() != Token::RBRACE) { 1496 while (peek() != Token::RBRACE) {
1497 Statement* stat = ParseStatement(NULL, CHECK_OK); 1497 Statement* stat = ParseStatement(NULL, CHECK_OK);
1498 if (stat && !stat->IsEmpty()) { 1498 if (stat && !stat->IsEmpty()) {
1499 result->AddStatement(stat); 1499 result->AddStatement(stat);
1500 block_finder.Update(stat); 1500 block_finder.Update(stat);
1501 } 1501 }
1502 } 1502 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 // Scope declaration, and rewrite the source-level initialization into an 1557 // Scope declaration, and rewrite the source-level initialization into an
1558 // assignment statement. We use a block to collect multiple assignments. 1558 // assignment statement. We use a block to collect multiple assignments.
1559 // 1559 //
1560 // We mark the block as initializer block because we don't want the 1560 // We mark the block as initializer block because we don't want the
1561 // rewriter to add a '.result' assignment to such a block (to get compliant 1561 // rewriter to add a '.result' assignment to such a block (to get compliant
1562 // behavior for code such as print(eval('var x = 7')), and for cosmetic 1562 // behavior for code such as print(eval('var x = 7')), and for cosmetic
1563 // reasons when pretty-printing. Also, unless an assignment (initialization) 1563 // reasons when pretty-printing. Also, unless an assignment (initialization)
1564 // is inside an initializer block, it is ignored. 1564 // is inside an initializer block, it is ignored.
1565 // 1565 //
1566 // Create new block with one expected declaration. 1566 // Create new block with one expected declaration.
1567 Block* block = new(zone()) Block(NULL, 1, true); 1567 Block* block = new(zone()) Block(zone(), NULL, 1, true);
1568 int nvars = 0; // the number of variables declared 1568 int nvars = 0; // the number of variables declared
1569 Handle<String> name; 1569 Handle<String> name;
1570 do { 1570 do {
1571 if (fni_ != NULL) fni_->Enter(); 1571 if (fni_ != NULL) fni_->Enter();
1572 1572
1573 // Parse variable name. 1573 // Parse variable name.
1574 if (nvars > 0) Consume(Token::COMMA); 1574 if (nvars > 0) Consume(Token::COMMA);
1575 name = ParseIdentifier(CHECK_OK); 1575 name = ParseIdentifier(CHECK_OK);
1576 if (fni_ != NULL) fni_->PushVariableName(name); 1576 if (fni_ != NULL) fni_->PushVariableName(name);
1577 1577
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 // guarantee to give the global object a "local" variable; a 1667 // guarantee to give the global object a "local" variable; a
1668 // variable defined in the global object and not in any 1668 // variable defined in the global object and not in any
1669 // prototype. This way, global variable declarations can shadow 1669 // prototype. This way, global variable declarations can shadow
1670 // properties in the prototype chain, but only after the variable 1670 // properties in the prototype chain, but only after the variable
1671 // declaration statement has been executed. This is important in 1671 // declaration statement has been executed. This is important in
1672 // browsers where the global object (window) has lots of 1672 // browsers where the global object (window) has lots of
1673 // properties defined in prototype objects. 1673 // properties defined in prototype objects.
1674 1674
1675 if (initialization_scope->is_global_scope()) { 1675 if (initialization_scope->is_global_scope()) {
1676 // Compute the arguments for the runtime call. 1676 // Compute the arguments for the runtime call.
1677 ZoneList<Expression*>* arguments = new(zone()) ZoneList<Expression*>(3); 1677 ZoneList<Expression*>* arguments = ZoneList<Expression*>::New(zone(), 3);
1678 // We have at least 1 parameter. 1678 // We have at least 1 parameter.
1679 arguments->Add(new(zone()) Literal(name)); 1679 arguments->Add(new(zone()) Literal(name));
1680 CallRuntime* initialize; 1680 CallRuntime* initialize;
1681 1681
1682 if (is_const) { 1682 if (is_const) {
1683 arguments->Add(value); 1683 arguments->Add(value);
1684 value = NULL; // zap the value to avoid the unnecessary assignment 1684 value = NULL; // zap the value to avoid the unnecessary assignment
1685 1685
1686 // Construct the call to Runtime_InitializeConstGlobal 1686 // Construct the call to Runtime_InitializeConstGlobal
1687 // and add it to the initialization statement block. 1687 // and add it to the initialization statement block.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 // structured. However, these are probably changes we want to 1789 // structured. However, these are probably changes we want to
1790 // make later anyway so we should go back and fix this then. 1790 // make later anyway so we should go back and fix this then.
1791 if (ContainsLabel(labels, label) || TargetStackContainsLabel(label)) { 1791 if (ContainsLabel(labels, label) || TargetStackContainsLabel(label)) {
1792 SmartPointer<char> c_string = label->ToCString(DISALLOW_NULLS); 1792 SmartPointer<char> c_string = label->ToCString(DISALLOW_NULLS);
1793 const char* elms[2] = { "Label", *c_string }; 1793 const char* elms[2] = { "Label", *c_string };
1794 Vector<const char*> args(elms, 2); 1794 Vector<const char*> args(elms, 2);
1795 ReportMessage("redeclaration", args); 1795 ReportMessage("redeclaration", args);
1796 *ok = false; 1796 *ok = false;
1797 return NULL; 1797 return NULL;
1798 } 1798 }
1799 if (labels == NULL) labels = new(zone()) ZoneStringList(4); 1799 if (labels == NULL) labels = ZoneStringList::New(zone(), 4);
1800 labels->Add(label); 1800 labels->Add(label);
1801 // Remove the "ghost" variable that turned out to be a label 1801 // Remove the "ghost" variable that turned out to be a label
1802 // from the top scope. This way, we don't try to resolve it 1802 // from the top scope. This way, we don't try to resolve it
1803 // during the scope processing. 1803 // during the scope processing.
1804 top_scope_->RemoveUnresolved(var); 1804 top_scope_->RemoveUnresolved(var);
1805 Expect(Token::COLON, CHECK_OK); 1805 Expect(Token::COLON, CHECK_OK);
1806 return ParseStatement(labels, ok); 1806 return ParseStatement(labels, ok);
1807 } 1807 }
1808 1808
1809 // If we have an extension, we allow a native function declaration. 1809 // If we have an extension, we allow a native function declaration.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 } 1943 }
1944 1944
1945 Expression* expr = ParseExpression(true, CHECK_OK); 1945 Expression* expr = ParseExpression(true, CHECK_OK);
1946 ExpectSemicolon(CHECK_OK); 1946 ExpectSemicolon(CHECK_OK);
1947 return new(zone()) ReturnStatement(expr); 1947 return new(zone()) ReturnStatement(expr);
1948 } 1948 }
1949 1949
1950 1950
1951 Block* Parser::WithHelper(Expression* obj, ZoneStringList* labels, bool* ok) { 1951 Block* Parser::WithHelper(Expression* obj, ZoneStringList* labels, bool* ok) {
1952 // Parse the statement and collect escaping labels. 1952 // Parse the statement and collect escaping labels.
1953 TargetCollector collector; 1953 TargetCollector collector(zone());
1954 Statement* stat; 1954 Statement* stat;
1955 { Target target(&this->target_stack_, &collector); 1955 { Target target(&this->target_stack_, &collector);
1956 with_nesting_level_++; 1956 with_nesting_level_++;
1957 top_scope_->DeclarationScope()->RecordWithStatement(); 1957 top_scope_->DeclarationScope()->RecordWithStatement();
1958 stat = ParseStatement(labels, CHECK_OK); 1958 stat = ParseStatement(labels, CHECK_OK);
1959 with_nesting_level_--; 1959 with_nesting_level_--;
1960 } 1960 }
1961 // Create resulting block with two statements. 1961 // Create resulting block with two statements.
1962 // 1: Evaluate the with expression. 1962 // 1: Evaluate the with expression.
1963 // 2: The try-finally block evaluating the body. 1963 // 2: The try-finally block evaluating the body.
1964 Block* result = new(zone()) Block(NULL, 2, false); 1964 Block* result = new(zone()) Block(zone(), NULL, 2, false);
1965 1965
1966 if (result != NULL) { 1966 if (result != NULL) {
1967 result->AddStatement(new(zone()) EnterWithContextStatement(obj)); 1967 result->AddStatement(new(zone()) EnterWithContextStatement(obj));
1968 1968
1969 // Create body block. 1969 // Create body block.
1970 Block* body = new(zone()) Block(NULL, 1, false); 1970 Block* body = new(zone()) Block(zone(), NULL, 1, false);
1971 body->AddStatement(stat); 1971 body->AddStatement(stat);
1972 1972
1973 // Create exit block. 1973 // Create exit block.
1974 Block* exit = new(zone()) Block(NULL, 1, false); 1974 Block* exit = new(zone()) Block(zone(), NULL, 1, false);
1975 exit->AddStatement(new(zone()) ExitContextStatement()); 1975 exit->AddStatement(new(zone()) ExitContextStatement());
1976 1976
1977 // Return a try-finally statement. 1977 // Return a try-finally statement.
1978 TryFinallyStatement* wrapper = new(zone()) TryFinallyStatement(body, exit); 1978 TryFinallyStatement* wrapper = new(zone()) TryFinallyStatement(body, exit);
1979 wrapper->set_escaping_targets(collector.targets()); 1979 wrapper->set_escaping_targets(collector.targets());
1980 result->AddStatement(wrapper); 1980 result->AddStatement(wrapper);
1981 } 1981 }
1982 return result; 1982 return result;
1983 } 1983 }
1984 1984
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 if (*default_seen_ptr) { 2017 if (*default_seen_ptr) {
2018 ReportMessage("multiple_defaults_in_switch", 2018 ReportMessage("multiple_defaults_in_switch",
2019 Vector<const char*>::empty()); 2019 Vector<const char*>::empty());
2020 *ok = false; 2020 *ok = false;
2021 return NULL; 2021 return NULL;
2022 } 2022 }
2023 *default_seen_ptr = true; 2023 *default_seen_ptr = true;
2024 } 2024 }
2025 Expect(Token::COLON, CHECK_OK); 2025 Expect(Token::COLON, CHECK_OK);
2026 int pos = scanner().location().beg_pos; 2026 int pos = scanner().location().beg_pos;
2027 ZoneList<Statement*>* statements = new(zone()) ZoneList<Statement*>(5); 2027 ZoneList<Statement*>* statements = ZoneList<Statement*>::New(zone(), 5);
2028 while (peek() != Token::CASE && 2028 while (peek() != Token::CASE &&
2029 peek() != Token::DEFAULT && 2029 peek() != Token::DEFAULT &&
2030 peek() != Token::RBRACE) { 2030 peek() != Token::RBRACE) {
2031 Statement* stat = ParseStatement(NULL, CHECK_OK); 2031 Statement* stat = ParseStatement(NULL, CHECK_OK);
2032 statements->Add(stat); 2032 statements->Add(stat);
2033 } 2033 }
2034 2034
2035 return new(zone()) CaseClause(label, statements, pos); 2035 return new(zone()) CaseClause(label, statements, pos);
2036 } 2036 }
2037 2037
2038 2038
2039 SwitchStatement* Parser::ParseSwitchStatement(ZoneStringList* labels, 2039 SwitchStatement* Parser::ParseSwitchStatement(ZoneStringList* labels,
2040 bool* ok) { 2040 bool* ok) {
2041 // SwitchStatement :: 2041 // SwitchStatement ::
2042 // 'switch' '(' Expression ')' '{' CaseClause* '}' 2042 // 'switch' '(' Expression ')' '{' CaseClause* '}'
2043 2043
2044 SwitchStatement* statement = new(zone()) SwitchStatement(labels); 2044 SwitchStatement* statement = new(zone()) SwitchStatement(labels);
2045 Target target(&this->target_stack_, statement); 2045 Target target(&this->target_stack_, statement);
2046 2046
2047 Expect(Token::SWITCH, CHECK_OK); 2047 Expect(Token::SWITCH, CHECK_OK);
2048 Expect(Token::LPAREN, CHECK_OK); 2048 Expect(Token::LPAREN, CHECK_OK);
2049 Expression* tag = ParseExpression(true, CHECK_OK); 2049 Expression* tag = ParseExpression(true, CHECK_OK);
2050 Expect(Token::RPAREN, CHECK_OK); 2050 Expect(Token::RPAREN, CHECK_OK);
2051 2051
2052 bool default_seen = false; 2052 bool default_seen = false;
2053 ZoneList<CaseClause*>* cases = new(zone()) ZoneList<CaseClause*>(4); 2053 ZoneList<CaseClause*>* cases = ZoneList<CaseClause*>::New(zone(), 4);
2054 Expect(Token::LBRACE, CHECK_OK); 2054 Expect(Token::LBRACE, CHECK_OK);
2055 while (peek() != Token::RBRACE) { 2055 while (peek() != Token::RBRACE) {
2056 CaseClause* clause = ParseCaseClause(&default_seen, CHECK_OK); 2056 CaseClause* clause = ParseCaseClause(&default_seen, CHECK_OK);
2057 cases->Add(clause); 2057 cases->Add(clause);
2058 } 2058 }
2059 Expect(Token::RBRACE, CHECK_OK); 2059 Expect(Token::RBRACE, CHECK_OK);
2060 2060
2061 if (statement) statement->Initialize(tag, cases); 2061 if (statement) statement->Initialize(tag, cases);
2062 return statement; 2062 return statement;
2063 } 2063 }
(...skipping 24 matching lines...) Expand all
2088 // 'try' Block Catch Finally 2088 // 'try' Block Catch Finally
2089 // 2089 //
2090 // Catch :: 2090 // Catch ::
2091 // 'catch' '(' Identifier ')' Block 2091 // 'catch' '(' Identifier ')' Block
2092 // 2092 //
2093 // Finally :: 2093 // Finally ::
2094 // 'finally' Block 2094 // 'finally' Block
2095 2095
2096 Expect(Token::TRY, CHECK_OK); 2096 Expect(Token::TRY, CHECK_OK);
2097 2097
2098 TargetCollector try_collector; 2098 TargetCollector try_collector(zone());
2099 Block* try_block; 2099 Block* try_block;
2100 2100
2101 { Target target(&this->target_stack_, &try_collector); 2101 { Target target(&this->target_stack_, &try_collector);
2102 try_block = ParseBlock(NULL, CHECK_OK); 2102 try_block = ParseBlock(NULL, CHECK_OK);
2103 } 2103 }
2104 2104
2105 Token::Value tok = peek(); 2105 Token::Value tok = peek();
2106 if (tok != Token::CATCH && tok != Token::FINALLY) { 2106 if (tok != Token::CATCH && tok != Token::FINALLY) {
2107 ReportMessage("no_catch_or_finally", Vector<const char*>::empty()); 2107 ReportMessage("no_catch_or_finally", Vector<const char*>::empty());
2108 *ok = false; 2108 *ok = false;
2109 return NULL; 2109 return NULL;
2110 } 2110 }
2111 2111
2112 // If we can break out from the catch block and there is a finally block, 2112 // If we can break out from the catch block and there is a finally block,
2113 // then we will need to collect escaping targets from the catch 2113 // then we will need to collect escaping targets from the catch
2114 // block. Since we don't know yet if there will be a finally block, we 2114 // block. Since we don't know yet if there will be a finally block, we
2115 // always collect the targets. 2115 // always collect the targets.
2116 TargetCollector catch_collector; 2116 TargetCollector catch_collector(zone());
2117 Scope* catch_scope = NULL; 2117 Scope* catch_scope = NULL;
2118 Variable* catch_variable = NULL; 2118 Variable* catch_variable = NULL;
2119 Block* catch_block = NULL; 2119 Block* catch_block = NULL;
2120 Handle<String> name; 2120 Handle<String> name;
2121 if (tok == Token::CATCH) { 2121 if (tok == Token::CATCH) {
2122 Consume(Token::CATCH); 2122 Consume(Token::CATCH);
2123 2123
2124 Expect(Token::LPAREN, CHECK_OK); 2124 Expect(Token::LPAREN, CHECK_OK);
2125 name = ParseIdentifier(CHECK_OK); 2125 name = ParseIdentifier(CHECK_OK);
2126 2126
2127 if (top_scope_->is_strict_mode() && IsEvalOrArguments(name)) { 2127 if (top_scope_->is_strict_mode() && IsEvalOrArguments(name)) {
2128 ReportMessage("strict_catch_variable", Vector<const char*>::empty()); 2128 ReportMessage("strict_catch_variable", Vector<const char*>::empty());
2129 *ok = false; 2129 *ok = false;
2130 return NULL; 2130 return NULL;
2131 } 2131 }
2132 2132
2133 Expect(Token::RPAREN, CHECK_OK); 2133 Expect(Token::RPAREN, CHECK_OK);
2134 2134
2135 if (peek() == Token::LBRACE) { 2135 if (peek() == Token::LBRACE) {
2136 // Rewrite the catch body B to a single statement block 2136 // Rewrite the catch body B to a single statement block
2137 // { try B finally { PopContext }}. 2137 // { try B finally { PopContext }}.
2138 Block* inner_body; 2138 Block* inner_body;
2139 // We need to collect escapes from the body for both the inner 2139 // We need to collect escapes from the body for both the inner
2140 // try/finally used to pop the catch context and any possible outer 2140 // try/finally used to pop the catch context and any possible outer
2141 // try/finally. 2141 // try/finally.
2142 TargetCollector inner_collector; 2142 TargetCollector inner_collector(zone());
2143 { Target target(&this->target_stack_, &catch_collector); 2143 { Target target(&this->target_stack_, &catch_collector);
2144 { Target target(&this->target_stack_, &inner_collector); 2144 { Target target(&this->target_stack_, &inner_collector);
2145 catch_scope = NewScope(top_scope_, Scope::CATCH_SCOPE, inside_with()); 2145 catch_scope = NewScope(top_scope_, Scope::CATCH_SCOPE, inside_with());
2146 if (top_scope_->is_strict_mode()) { 2146 if (top_scope_->is_strict_mode()) {
2147 catch_scope->EnableStrictMode(); 2147 catch_scope->EnableStrictMode();
2148 } 2148 }
2149 catch_variable = catch_scope->DeclareLocal(name, Variable::VAR); 2149 catch_variable = catch_scope->DeclareLocal(name, Variable::VAR);
2150 2150
2151 Scope* saved_scope = top_scope_; 2151 Scope* saved_scope = top_scope_;
2152 top_scope_ = catch_scope; 2152 top_scope_ = catch_scope;
2153 inner_body = ParseBlock(NULL, CHECK_OK); 2153 inner_body = ParseBlock(NULL, CHECK_OK);
2154 top_scope_ = saved_scope; 2154 top_scope_ = saved_scope;
2155 } 2155 }
2156 } 2156 }
2157 2157
2158 // Create exit block. 2158 // Create exit block.
2159 Block* inner_finally = new(zone()) Block(NULL, 1, false); 2159 Block* inner_finally = new(zone()) Block(zone(), NULL, 1, false);
2160 inner_finally->AddStatement(new(zone()) ExitContextStatement()); 2160 inner_finally->AddStatement(new(zone()) ExitContextStatement());
2161 2161
2162 // Create a try/finally statement. 2162 // Create a try/finally statement.
2163 TryFinallyStatement* inner_try_finally = 2163 TryFinallyStatement* inner_try_finally =
2164 new(zone()) TryFinallyStatement(inner_body, inner_finally); 2164 new(zone()) TryFinallyStatement(inner_body, inner_finally);
2165 inner_try_finally->set_escaping_targets(inner_collector.targets()); 2165 inner_try_finally->set_escaping_targets(inner_collector.targets());
2166 2166
2167 catch_block = new(zone()) Block(NULL, 1, false); 2167 catch_block = new(zone()) Block(zone(), NULL, 1, false);
2168 catch_block->AddStatement(inner_try_finally); 2168 catch_block->AddStatement(inner_try_finally);
2169 } else { 2169 } else {
2170 Expect(Token::LBRACE, CHECK_OK); 2170 Expect(Token::LBRACE, CHECK_OK);
2171 } 2171 }
2172 2172
2173 tok = peek(); 2173 tok = peek();
2174 } 2174 }
2175 2175
2176 Block* finally_block = NULL; 2176 Block* finally_block = NULL;
2177 if (tok == Token::FINALLY || catch_block == NULL) { 2177 if (tok == Token::FINALLY || catch_block == NULL) {
2178 Consume(Token::FINALLY); 2178 Consume(Token::FINALLY);
2179 finally_block = ParseBlock(NULL, CHECK_OK); 2179 finally_block = ParseBlock(NULL, CHECK_OK);
2180 } 2180 }
2181 2181
2182 // Simplify the AST nodes by converting: 2182 // Simplify the AST nodes by converting:
2183 // 'try B0 catch B1 finally B2' 2183 // 'try B0 catch B1 finally B2'
2184 // to: 2184 // to:
2185 // 'try { try B0 catch B1 } finally B2' 2185 // 'try { try B0 catch B1 } finally B2'
2186 2186
2187 if (catch_block != NULL && finally_block != NULL) { 2187 if (catch_block != NULL && finally_block != NULL) {
2188 // If we have both, create an inner try/catch. 2188 // If we have both, create an inner try/catch.
2189 ASSERT(catch_scope != NULL && catch_variable != NULL); 2189 ASSERT(catch_scope != NULL && catch_variable != NULL);
2190 TryCatchStatement* statement = 2190 TryCatchStatement* statement =
2191 new(zone()) TryCatchStatement(try_block, 2191 new(zone()) TryCatchStatement(try_block,
2192 catch_scope, 2192 catch_scope,
2193 catch_variable, 2193 catch_variable,
2194 catch_block); 2194 catch_block);
2195 statement->set_escaping_targets(try_collector.targets()); 2195 statement->set_escaping_targets(try_collector.targets());
2196 try_block = new(zone()) Block(NULL, 1, false); 2196 try_block = new(zone()) Block(zone(), NULL, 1, false);
2197 try_block->AddStatement(statement); 2197 try_block->AddStatement(statement);
2198 catch_block = NULL; // Clear to indicate it's been handled. 2198 catch_block = NULL; // Clear to indicate it's been handled.
2199 } 2199 }
2200 2200
2201 TryStatement* result = NULL; 2201 TryStatement* result = NULL;
2202 if (catch_block != NULL) { 2202 if (catch_block != NULL) {
2203 ASSERT(finally_block == NULL); 2203 ASSERT(finally_block == NULL);
2204 ASSERT(catch_scope != NULL && catch_variable != NULL); 2204 ASSERT(catch_scope != NULL && catch_variable != NULL);
2205 result = 2205 result =
2206 new(zone()) TryCatchStatement(try_block, 2206 new(zone()) TryCatchStatement(try_block,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2287 VariableProxy* each = top_scope_->NewUnresolved(name, inside_with()); 2287 VariableProxy* each = top_scope_->NewUnresolved(name, inside_with());
2288 ForInStatement* loop = new(zone()) ForInStatement(labels); 2288 ForInStatement* loop = new(zone()) ForInStatement(labels);
2289 Target target(&this->target_stack_, loop); 2289 Target target(&this->target_stack_, loop);
2290 2290
2291 Expect(Token::IN, CHECK_OK); 2291 Expect(Token::IN, CHECK_OK);
2292 Expression* enumerable = ParseExpression(true, CHECK_OK); 2292 Expression* enumerable = ParseExpression(true, CHECK_OK);
2293 Expect(Token::RPAREN, CHECK_OK); 2293 Expect(Token::RPAREN, CHECK_OK);
2294 2294
2295 Statement* body = ParseStatement(NULL, CHECK_OK); 2295 Statement* body = ParseStatement(NULL, CHECK_OK);
2296 loop->Initialize(each, enumerable, body); 2296 loop->Initialize(each, enumerable, body);
2297 Block* result = new(zone()) Block(NULL, 2, false); 2297 Block* result = new(zone()) Block(zone(), NULL, 2, false);
2298 result->AddStatement(variable_statement); 2298 result->AddStatement(variable_statement);
2299 result->AddStatement(loop); 2299 result->AddStatement(loop);
2300 // Parsed for-in loop w/ variable/const declaration. 2300 // Parsed for-in loop w/ variable/const declaration.
2301 return result; 2301 return result;
2302 } else { 2302 } else {
2303 init = variable_statement; 2303 init = variable_statement;
2304 } 2304 }
2305 2305
2306 } else { 2306 } else {
2307 Expression* expression = ParseExpression(false, CHECK_OK); 2307 Expression* expression = ParseExpression(false, CHECK_OK);
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
2789 Expression* result; 2789 Expression* result;
2790 if (peek() == Token::NEW) { 2790 if (peek() == Token::NEW) {
2791 result = ParseNewPrefix(stack, CHECK_OK); 2791 result = ParseNewPrefix(stack, CHECK_OK);
2792 } else { 2792 } else {
2793 result = ParseMemberWithNewPrefixesExpression(stack, CHECK_OK); 2793 result = ParseMemberWithNewPrefixesExpression(stack, CHECK_OK);
2794 } 2794 }
2795 2795
2796 if (!stack->is_empty()) { 2796 if (!stack->is_empty()) {
2797 int last = stack->pop(); 2797 int last = stack->pop();
2798 result = new(zone()) CallNew(result, 2798 result = new(zone()) CallNew(result,
2799 new(zone()) ZoneList<Expression*>(0), 2799 ZoneList<Expression*>::New(zone(), 0),
2800 last); 2800 last);
2801 } 2801 }
2802 return result; 2802 return result;
2803 } 2803 }
2804 2804
2805 2805
2806 Expression* Parser::ParseNewExpression(bool* ok) { 2806 Expression* Parser::ParseNewExpression(bool* ok) {
2807 PositionStack stack(ok); 2807 PositionStack stack(ok);
2808 return ParseNewPrefix(&stack, ok); 2808 return ParseNewPrefix(&stack, ok);
2809 } 2809 }
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
3068 3068
3069 *is_simple = is_simple_acc; 3069 *is_simple = is_simple_acc;
3070 *depth = depth_acc; 3070 *depth = depth_acc;
3071 } 3071 }
3072 3072
3073 3073
3074 Expression* Parser::ParseArrayLiteral(bool* ok) { 3074 Expression* Parser::ParseArrayLiteral(bool* ok) {
3075 // ArrayLiteral :: 3075 // ArrayLiteral ::
3076 // '[' Expression? (',' Expression?)* ']' 3076 // '[' Expression? (',' Expression?)* ']'
3077 3077
3078 ZoneList<Expression*>* values = new(zone()) ZoneList<Expression*>(4); 3078 ZoneList<Expression*>* values = ZoneList<Expression*>::New(zone(), 4);
3079 Expect(Token::LBRACK, CHECK_OK); 3079 Expect(Token::LBRACK, CHECK_OK);
3080 while (peek() != Token::RBRACK) { 3080 while (peek() != Token::RBRACK) {
3081 Expression* elem; 3081 Expression* elem;
3082 if (peek() == Token::COMMA) { 3082 if (peek() == Token::COMMA) {
3083 elem = GetLiteralTheHole(); 3083 elem = GetLiteralTheHole();
3084 } else { 3084 } else {
3085 elem = ParseAssignmentExpression(true, CHECK_OK); 3085 elem = ParseAssignmentExpression(true, CHECK_OK);
3086 } 3086 }
3087 values->Add(elem); 3087 values->Add(elem);
3088 if (peek() != Token::RBRACK) { 3088 if (peek() != Token::RBRACK) {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
3411 3411
3412 3412
3413 Expression* Parser::ParseObjectLiteral(bool* ok) { 3413 Expression* Parser::ParseObjectLiteral(bool* ok) {
3414 // ObjectLiteral :: 3414 // ObjectLiteral ::
3415 // '{' ( 3415 // '{' (
3416 // ((IdentifierName | String | Number) ':' AssignmentExpression) 3416 // ((IdentifierName | String | Number) ':' AssignmentExpression)
3417 // | (('get' | 'set') (IdentifierName | String | Number) FunctionLiteral) 3417 // | (('get' | 'set') (IdentifierName | String | Number) FunctionLiteral)
3418 // )*[','] '}' 3418 // )*[','] '}'
3419 3419
3420 ZoneList<ObjectLiteral::Property*>* properties = 3420 ZoneList<ObjectLiteral::Property*>* properties =
3421 new(zone()) ZoneList<ObjectLiteral::Property*>(4); 3421 ZoneList<ObjectLiteral::Property*>::New(zone(), 4);
3422 int number_of_boilerplate_properties = 0; 3422 int number_of_boilerplate_properties = 0;
3423 bool has_function = false; 3423 bool has_function = false;
3424 3424
3425 ObjectLiteralPropertyChecker checker(this, top_scope_->is_strict_mode()); 3425 ObjectLiteralPropertyChecker checker(this, top_scope_->is_strict_mode());
3426 3426
3427 Expect(Token::LBRACE, CHECK_OK); 3427 Expect(Token::LBRACE, CHECK_OK);
3428 Scanner::Location loc = scanner().location(); 3428 Scanner::Location loc = scanner().location();
3429 3429
3430 while (peek() != Token::RBRACE) { 3430 while (peek() != Token::RBRACE) {
3431 if (fni_ != NULL) fni_->Enter(); 3431 if (fni_ != NULL) fni_->Enter();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
3574 Next(); 3574 Next();
3575 3575
3576 return new(zone()) RegExpLiteral(js_pattern, js_flags, literal_index); 3576 return new(zone()) RegExpLiteral(js_pattern, js_flags, literal_index);
3577 } 3577 }
3578 3578
3579 3579
3580 ZoneList<Expression*>* Parser::ParseArguments(bool* ok) { 3580 ZoneList<Expression*>* Parser::ParseArguments(bool* ok) {
3581 // Arguments :: 3581 // Arguments ::
3582 // '(' (AssignmentExpression)*[','] ')' 3582 // '(' (AssignmentExpression)*[','] ')'
3583 3583
3584 ZoneList<Expression*>* result = new(zone()) ZoneList<Expression*>(4); 3584 ZoneList<Expression*>* result = ZoneList<Expression*>::New(zone(), 4);
3585 Expect(Token::LPAREN, CHECK_OK); 3585 Expect(Token::LPAREN, CHECK_OK);
3586 bool done = (peek() == Token::RPAREN); 3586 bool done = (peek() == Token::RPAREN);
3587 while (!done) { 3587 while (!done) {
3588 Expression* argument = ParseAssignmentExpression(true, CHECK_OK); 3588 Expression* argument = ParseAssignmentExpression(true, CHECK_OK);
3589 result->Add(argument); 3589 result->Add(argument);
3590 if (result->length() > kMaxNumFunctionParameters) { 3590 if (result->length() > kMaxNumFunctionParameters) {
3591 ReportMessageAt(scanner().location(), "too_many_arguments", 3591 ReportMessageAt(scanner().location(), "too_many_arguments",
3592 Vector<const char*>::empty()); 3592 Vector<const char*>::empty());
3593 *ok = false; 3593 *ok = false;
3594 return NULL; 3594 return NULL;
(...skipping 22 matching lines...) Expand all
3617 Handle<String> name = 3617 Handle<String> name =
3618 is_named ? var_name : isolate()->factory()->empty_symbol(); 3618 is_named ? var_name : isolate()->factory()->empty_symbol();
3619 // The function name, if any. 3619 // The function name, if any.
3620 Handle<String> function_name = isolate()->factory()->empty_symbol(); 3620 Handle<String> function_name = isolate()->factory()->empty_symbol();
3621 if (is_named && (type == EXPRESSION || type == NESTED)) { 3621 if (is_named && (type == EXPRESSION || type == NESTED)) {
3622 function_name = name; 3622 function_name = name;
3623 } 3623 }
3624 3624
3625 int num_parameters = 0; 3625 int num_parameters = 0;
3626 Scope* scope = NewScope(top_scope_, Scope::FUNCTION_SCOPE, inside_with()); 3626 Scope* scope = NewScope(top_scope_, Scope::FUNCTION_SCOPE, inside_with());
3627 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(8); 3627 ZoneList<Statement*>* body = ZoneList<Statement*>::New(zone(), 8);
3628 int materialized_literal_count; 3628 int materialized_literal_count;
3629 int expected_property_count; 3629 int expected_property_count;
3630 int start_pos; 3630 int start_pos;
3631 int end_pos; 3631 int end_pos;
3632 bool only_simple_this_property_assignments; 3632 bool only_simple_this_property_assignments;
3633 Handle<FixedArray> this_property_assignments; 3633 Handle<FixedArray> this_property_assignments;
3634 bool has_duplicate_parameters = false; 3634 bool has_duplicate_parameters = false;
3635 // Parse function body. 3635 // Parse function body.
3636 { LexicalScope lexical_scope(this, scope, isolate()); 3636 { LexicalScope lexical_scope(this, scope, isolate());
3637 top_scope_->SetScopeName(name); 3637 top_scope_->SetScopeName(name);
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
4099 TENURED); 4099 TENURED);
4100 for (int i = 0; i < argc; i++) { 4100 for (int i = 0; i < argc; i++) {
4101 Handle<Object> element = arguments[i]; 4101 Handle<Object> element = arguments[i];
4102 if (!element.is_null()) { 4102 if (!element.is_null()) {
4103 elements->set(i, *element); 4103 elements->set(i, *element);
4104 } 4104 }
4105 } 4105 }
4106 Handle<JSArray> array = isolate()->factory()->NewJSArrayWithElements(elements, 4106 Handle<JSArray> array = isolate()->factory()->NewJSArrayWithElements(elements,
4107 TENURED); 4107 TENURED);
4108 4108
4109 ZoneList<Expression*>* args = new(zone()) ZoneList<Expression*>(2); 4109 ZoneList<Expression*>* args = ZoneList<Expression*>::New(zone(), 2);
4110 args->Add(new(zone()) Literal(type)); 4110 args->Add(new(zone()) Literal(type));
4111 args->Add(new(zone()) Literal(array)); 4111 args->Add(new(zone()) Literal(array));
4112 return new(zone()) Throw(new(zone()) CallRuntime(constructor, NULL, args), 4112 return new(zone()) Throw(new(zone()) CallRuntime(constructor, NULL, args),
4113 scanner().location().beg_pos); 4113 scanner().location().beg_pos);
4114 } 4114 }
4115 4115
4116 // ---------------------------------------------------------------------------- 4116 // ----------------------------------------------------------------------------
4117 // Regular expressions 4117 // Regular expressions
4118 4118
4119 4119
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
4294 RegExpAssertion::Type type = 4294 RegExpAssertion::Type type =
4295 multiline_ ? RegExpAssertion::END_OF_LINE : 4295 multiline_ ? RegExpAssertion::END_OF_LINE :
4296 RegExpAssertion::END_OF_INPUT; 4296 RegExpAssertion::END_OF_INPUT;
4297 builder->AddAssertion(new(zone()) RegExpAssertion(type)); 4297 builder->AddAssertion(new(zone()) RegExpAssertion(type));
4298 continue; 4298 continue;
4299 } 4299 }
4300 case '.': { 4300 case '.': {
4301 Advance(); 4301 Advance();
4302 // everything except \x0a, \x0d, \u2028 and \u2029 4302 // everything except \x0a, \x0d, \u2028 and \u2029
4303 ZoneList<CharacterRange>* ranges = 4303 ZoneList<CharacterRange>* ranges =
4304 new(zone()) ZoneList<CharacterRange>(2); 4304 ZoneList<CharacterRange>::New(zone(), 2);
4305 CharacterRange::AddClassEscape('.', ranges); 4305 CharacterRange::AddClassEscape('.', ranges);
4306 RegExpTree* atom = new(zone()) RegExpCharacterClass(ranges, false); 4306 RegExpTree* atom = new(zone()) RegExpCharacterClass(ranges, false);
4307 builder->AddAtom(atom); 4307 builder->AddAtom(atom);
4308 break; 4308 break;
4309 } 4309 }
4310 case '(': { 4310 case '(': {
4311 SubexpressionType type = CAPTURE; 4311 SubexpressionType type = CAPTURE;
4312 Advance(); 4312 Advance();
4313 if (current() == '?') { 4313 if (current() == '?') {
4314 switch (Next()) { 4314 switch (Next()) {
4315 case ':': 4315 case ':':
4316 type = GROUPING; 4316 type = GROUPING;
4317 break; 4317 break;
4318 case '=': 4318 case '=':
4319 type = POSITIVE_LOOKAHEAD; 4319 type = POSITIVE_LOOKAHEAD;
4320 break; 4320 break;
4321 case '!': 4321 case '!':
4322 type = NEGATIVE_LOOKAHEAD; 4322 type = NEGATIVE_LOOKAHEAD;
4323 break; 4323 break;
4324 default: 4324 default:
4325 ReportError(CStrVector("Invalid group") CHECK_FAILED); 4325 ReportError(CStrVector("Invalid group") CHECK_FAILED);
4326 break; 4326 break;
4327 } 4327 }
4328 Advance(2); 4328 Advance(2);
4329 } else { 4329 } else {
4330 if (captures_ == NULL) { 4330 if (captures_ == NULL) {
4331 captures_ = new(zone()) ZoneList<RegExpCapture*>(2); 4331 captures_ = ZoneList<RegExpCapture*>::New(zone(), 2);
4332 } 4332 }
4333 if (captures_started() >= kMaxCaptures) { 4333 if (captures_started() >= kMaxCaptures) {
4334 ReportError(CStrVector("Too many captures") CHECK_FAILED); 4334 ReportError(CStrVector("Too many captures") CHECK_FAILED);
4335 } 4335 }
4336 captures_->Add(NULL); 4336 captures_->Add(NULL);
4337 } 4337 }
4338 // Store current state and begin new disjunction parsing. 4338 // Store current state and begin new disjunction parsing.
4339 stored_state = new(zone()) RegExpParserState(stored_state, 4339 stored_state = new(zone()) RegExpParserState(stored_state,
4340 type, 4340 type,
4341 captures_started()); 4341 captures_started());
(...skipping 23 matching lines...) Expand all
4365 continue; 4365 continue;
4366 // AtomEscape :: 4366 // AtomEscape ::
4367 // CharacterClassEscape 4367 // CharacterClassEscape
4368 // 4368 //
4369 // CharacterClassEscape :: one of 4369 // CharacterClassEscape :: one of
4370 // d D s S w W 4370 // d D s S w W
4371 case 'd': case 'D': case 's': case 'S': case 'w': case 'W': { 4371 case 'd': case 'D': case 's': case 'S': case 'w': case 'W': {
4372 uc32 c = Next(); 4372 uc32 c = Next();
4373 Advance(2); 4373 Advance(2);
4374 ZoneList<CharacterRange>* ranges = 4374 ZoneList<CharacterRange>* ranges =
4375 new(zone()) ZoneList<CharacterRange>(2); 4375 ZoneList<CharacterRange>::New(zone(), 2);
4376 CharacterRange::AddClassEscape(c, ranges); 4376 CharacterRange::AddClassEscape(c, ranges);
4377 RegExpTree* atom = new(zone()) RegExpCharacterClass(ranges, false); 4377 RegExpTree* atom = new(zone()) RegExpCharacterClass(ranges, false);
4378 builder->AddAtom(atom); 4378 builder->AddAtom(atom);
4379 break; 4379 break;
4380 } 4380 }
4381 case '1': case '2': case '3': case '4': case '5': case '6': 4381 case '1': case '2': case '3': case '4': case '5': case '6':
4382 case '7': case '8': case '9': { 4382 case '7': case '8': case '9': {
4383 int index = 0; 4383 int index = 0;
4384 if (ParseBackReferenceIndex(&index)) { 4384 if (ParseBackReferenceIndex(&index)) {
4385 RegExpCapture* capture = NULL; 4385 RegExpCapture* capture = NULL;
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
4861 static const char* kUnterminated = "Unterminated character class"; 4861 static const char* kUnterminated = "Unterminated character class";
4862 static const char* kRangeOutOfOrder = "Range out of order in character class"; 4862 static const char* kRangeOutOfOrder = "Range out of order in character class";
4863 4863
4864 ASSERT_EQ(current(), '['); 4864 ASSERT_EQ(current(), '[');
4865 Advance(); 4865 Advance();
4866 bool is_negated = false; 4866 bool is_negated = false;
4867 if (current() == '^') { 4867 if (current() == '^') {
4868 is_negated = true; 4868 is_negated = true;
4869 Advance(); 4869 Advance();
4870 } 4870 }
4871 ZoneList<CharacterRange>* ranges = new(zone()) ZoneList<CharacterRange>(2); 4871 ZoneList<CharacterRange>* ranges = ZoneList<CharacterRange>::New(zone(), 2);
4872 while (has_more() && current() != ']') { 4872 while (has_more() && current() != ']') {
4873 uc16 char_class = kNoCharClass; 4873 uc16 char_class = kNoCharClass;
4874 CharacterRange first = ParseClassAtom(&char_class CHECK_FAILED); 4874 CharacterRange first = ParseClassAtom(&char_class CHECK_FAILED);
4875 if (current() == '-') { 4875 if (current() == '-') {
4876 Advance(); 4876 Advance();
4877 if (current() == kEndMarker) { 4877 if (current() == kEndMarker) {
4878 // If we reach the end we break out of the loop and let the 4878 // If we reach the end we break out of the loop and let the
4879 // following code report an error. 4879 // following code report an error.
4880 break; 4880 break;
4881 } else if (current() == ']') { 4881 } else if (current() == ']') {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
5085 info->is_global(), 5085 info->is_global(),
5086 info->StrictMode()); 5086 info->StrictMode());
5087 } 5087 }
5088 } 5088 }
5089 5089
5090 info->SetFunction(result); 5090 info->SetFunction(result);
5091 return (result != NULL); 5091 return (result != NULL);
5092 } 5092 }
5093 5093
5094 } } // namespace v8::internal 5094 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698