50 pending_empty_(
false),
55 , last_added_(ADD_NONE)
60 void RegExpBuilder::FlushCharacters() {
61 pending_empty_ =
false;
62 if (characters_ !=
NULL) {
65 text_.Add(atom, zone());
71 void RegExpBuilder::FlushText() {
73 int num_text = text_.length();
76 }
else if (num_text == 1) {
77 terms_.Add(text_.last(), zone());
79 RegExpText* text =
new(zone()) RegExpText(zone());
80 for (
int i = 0; i < num_text; i++)
81 text_.Get(i)->AppendToText(text, zone());
82 terms_.Add(text, zone());
89 pending_empty_ =
false;
90 if (characters_ ==
NULL) {
93 characters_->
Add(c, zone());
99 pending_empty_ =
true;
104 if (term->IsEmpty()) {
110 text_.Add(term, zone());
113 terms_.Add(term, zone());
121 terms_.Add(assert, zone());
131 void RegExpBuilder::FlushTerms() {
133 int num_terms = terms_.length();
135 if (num_terms == 0) {
136 alternative = RegExpEmpty::GetInstance();
137 }
else if (num_terms == 1) {
138 alternative = terms_.last();
140 alternative =
new(zone()) RegExpAlternative(terms_.GetList(zone()));
142 alternatives_.Add(alternative, zone());
150 int num_alternatives = alternatives_.length();
151 if (num_alternatives == 0) {
152 return RegExpEmpty::GetInstance();
154 if (num_alternatives == 1) {
155 return alternatives_.last();
157 return new(zone()) RegExpDisjunction(alternatives_.GetList(zone()));
162 int min,
int max, RegExpQuantifier::QuantifierType quantifier_type) {
163 if (pending_empty_) {
164 pending_empty_ =
false;
168 if (characters_ !=
NULL) {
169 ASSERT(last_added_ == ADD_CHAR);
172 int num_chars = char_vector.
length();
175 text_.Add(
new(zone()) RegExpAtom(prefix), zone());
176 char_vector = char_vector.
SubVector(num_chars - 1, num_chars);
179 atom =
new(zone()) RegExpAtom(char_vector);
181 }
else if (text_.length() > 0) {
182 ASSERT(last_added_ == ADD_ATOM);
183 atom = text_.RemoveLast();
185 }
else if (terms_.length() > 0) {
186 ASSERT(last_added_ == ADD_ATOM);
187 atom = terms_.RemoveLast();
194 terms_.Add(atom, zone());
203 new(zone()) RegExpQuantifier(min, max, quantifier_type, atom), zone());
210 if (symbol_cache_.length() <= symbol_id) {
213 symbol_id + 1 - symbol_cache_.length(),
zone());
216 if (result.is_null()) {
218 ASSERT(!result.is_null());
219 symbol_cache_.at(symbol_id) = result;
222 isolate()->
counters()->total_preparse_symbols_skipped()->Increment();
230 if ((function_index_ + FunctionEntry::kSize <= store_.
length())
231 && (static_cast<int>(store_[function_index_]) == start)) {
232 int index = function_index_;
233 function_index_ += FunctionEntry::kSize;
234 return FunctionEntry(store_.
SubVector(index,
235 index + FunctionEntry::kSize));
237 return FunctionEntry();
242 return ReadNumber(&symbol_data_);
264 for (
unsigned int i = 0; i <= arg_count; i++) {
268 int length =
static_cast<int>(Read(pos));
269 if (length < 0)
return false;
280 if (functions_size < 0)
return false;
281 if (functions_size % FunctionEntry::kSize != 0)
return false;
285 if (symbol_count < 0)
return false;
289 if (store_.
length() < minimum_size)
return false;
295 const char* ScriptDataImpl::ReadString(
unsigned* start,
int* chars) {
296 int length = start[0];
297 char* result = NewArray<char>(length + 1);
298 for (
int i = 0; i < length; i++) {
299 result[i] = start[i + 1];
301 result[length] =
'\0';
302 if (chars !=
NULL) *chars = length;
316 return ReadString(start,
NULL);
322 const char** array = NewArray<const char*>(arg_count);
327 for (
int i = 0; i < arg_count; i++) {
329 array[i] = ReadString(ReadAddress(pos), &count);
336 unsigned ScriptDataImpl::Read(
int position) {
341 unsigned* ScriptDataImpl::ReadAddress(
int position) {
346 Scope* Parser::NewScope(Scope* parent,
ScopeType scope_type) {
347 Scope* result =
new(
zone()) Scope(parent, scope_type,
zone());
348 result->Initialize();
362 : variable_(variable), node_(node), previous_(*variable) {
367 *variable_ = previous_;
383 : variable_(variable), previous_(*variable) {
388 *variable_ = previous_;
405 #define CHECK_OK ok); \
406 if (!*ok) return NULL; \
408 #define DUMMY ) // to make indentation work
411 #define CHECK_FAILED ); \
412 if (failed_) return NULL; \
414 #define DUMMY ) // to make indentation work
421 return identifier.is_identical_to(
422 parser_->isolate()->
factory()->eval_string()) ||
423 identifier.is_identical_to(
424 parser_->isolate()->
factory()->arguments_string());
430 Property*
property = expression->AsProperty();
431 return property !=
NULL &&
432 property->obj()->AsVariableProxy() !=
NULL &&
433 property->obj()->AsVariableProxy()->is_this();
438 VariableProxy* operand = expression->AsVariableProxy();
439 return operand !=
NULL && !operand->is_this();
449 parser_->isolate()->
factory()->anonymous_function_string());
457 if (left->AsProperty() !=
NULL &&
458 right->AsFunctionLiteral() !=
NULL) {
459 right->AsFunctionLiteral()->set_pretenure();
466 VariableProxy* callee = expression->AsVariableProxy();
467 if (callee !=
NULL &&
468 callee->IsVariable(parser_->isolate()->
factory()->eval_string())) {
475 VariableProxy* proxy = expression !=
NULL
476 ? expression->AsVariableProxy()
478 if (proxy !=
NULL) proxy->MarkAsLValue();
485 VariableProxy* lhs = expression !=
NULL
486 ? expression->AsVariableProxy()
499 if ((*x)->AsLiteral() && (*x)->AsLiteral()->value()->IsNumber() &&
500 y->AsLiteral() && y->AsLiteral()->value()->IsNumber()) {
501 double x_val = (*x)->AsLiteral()->value()->Number();
502 double y_val = y->AsLiteral()->value()->Number();
505 *x = factory->NewNumberLiteral(x_val + y_val, pos);
508 *x = factory->NewNumberLiteral(x_val - y_val, pos);
511 *x = factory->NewNumberLiteral(x_val * y_val, pos);
514 *x = factory->NewNumberLiteral(x_val / y_val, pos);
516 case Token::BIT_OR: {
518 *x = factory->NewNumberLiteral(value, pos);
521 case Token::BIT_AND: {
523 *x = factory->NewNumberLiteral(value, pos);
526 case Token::BIT_XOR: {
528 *x = factory->NewNumberLiteral(value, pos);
533 *x = factory->NewNumberLiteral(value, pos);
539 *x = factory->NewNumberLiteral(value, pos);
545 *x = factory->NewNumberLiteral(value, pos);
560 if (expression->AsLiteral() !=
NULL) {
567 return factory->NewLiteral(result, pos);
570 double value = literal->Number();
575 return factory->NewNumberLiteral(-value, pos);
577 return factory->NewNumberLiteral(~
DoubleToInt32(value), pos);
585 return factory->NewBinaryOperation(
586 Token::MUL, expression, factory->NewNumberLiteral(1, pos), pos);
590 return factory->NewBinaryOperation(
591 Token::MUL, expression, factory->NewNumberLiteral(-1, pos), pos);
594 if (op == Token::BIT_NOT) {
595 return factory->NewBinaryOperation(
596 Token::BIT_XOR, expression, factory->NewNumberLiteral(~0, pos), pos);
598 return factory->NewUnaryOperation(op, expression, pos);
605 bool is_reference_error) {
617 for (
int i = 0; i < args.
length(); i++) {
620 elements->set(i, *arg_string);
626 parser_->isolate()->
Throw(*result, &location);
632 bool is_reference_error) {
641 bool is_reference_error) {
653 for (
int i = 0; i < args.length(); i++) {
654 elements->set(i, *args[i]);
660 parser_->isolate()->
Throw(*result, &location);
666 int symbol_id = (*parser_->cached_data())->GetSymbolIdentifier();
668 if (symbol_id >= 0 &&
669 symbol_id < (*parser_->cached_data())->symbol_count()) {
670 return parser_->LookupCachedSymbol(symbol_id);
693 return factory->NewVariableProxy(scope->
receiver());
703 case Token::NULL_LITERAL:
704 return factory->NewLiteral(isolate_factory->null_value(), pos);
705 case Token::TRUE_LITERAL:
706 return factory->NewLiteral(isolate_factory->true_value(), pos);
707 case Token::FALSE_LITERAL:
708 return factory->NewLiteral(isolate_factory->false_value(), pos);
709 case Token::NUMBER: {
711 return factory->NewNumberLiteral(value, pos);
726 if (FLAG_print_interface_details)
727 PrintF(
"# Variable %s ", name->ToAsciiArray());
739 return factory->NewLiteral(symbol, pos);
745 return factory->NewLiteral(parser_->isolate()->
factory()->the_hole_value(),
746 RelocInfo::kNoPosition);
751 return parser_->ParseV8Intrinsic(ok);
758 bool name_is_strict_reserved,
760 int function_token_position,
761 FunctionLiteral::FunctionType type,
763 return parser_->ParseFunctionLiteral(name, function_name_location,
764 name_is_strict_reserved, is_generator,
765 function_token_position, type, ok);
771 info->isolate()->stack_guard()->real_climit(),
776 isolate_(info->isolate()),
777 symbol_cache_(0, info->zone()),
778 script_(info->script()),
779 scanner_(isolate_->unicode_cache()),
780 reusable_preparser_(
NULL),
781 original_scope_(
NULL),
786 ASSERT(!script_.is_null());
787 isolate_->set_ast_node_id(0);
798 FunctionLiteral* Parser::ParseProgram() {
801 HistogramTimerScope timer_scope(isolate()->counters()->parse(),
true);
803 isolate()->
counters()->total_parse_size()->Increment(source->length());
805 if (FLAG_trace_parse) {
811 CompleteParserRecorder recorder;
815 (*cached_data_)->Initialize();
818 source->TryFlatten();
819 FunctionLiteral* result;
820 if (source->IsExternalTwoByteString()) {
824 ExternalTwoByteStringUtf16CharacterStream stream(
825 Handle<ExternalTwoByteString>::cast(source), 0, source->length());
827 result = DoParseProgram(
info(), source);
829 GenericStringUtf16CharacterStream stream(source, 0, source->length());
831 result = DoParseProgram(
info(), source);
834 if (FLAG_trace_parse && result !=
NULL) {
835 double ms = timer.Elapsed().InMillisecondsF();
836 if (
info()->is_eval()) {
838 }
else if (
info()->script()->
name()->IsString()) {
840 SmartArrayPointer<char> name_chars = name->ToCString();
841 PrintF(
"[parsing script: %s", name_chars.get());
843 PrintF(
"[parsing script");
845 PrintF(
" - took %0.3f ms]\n", ms);
848 Vector<unsigned> store = recorder.ExtractData();
849 *cached_data_ =
new ScriptDataImpl(store);
856 FunctionLiteral* Parser::DoParseProgram(CompilationInfo*
info,
857 Handle<String> source) {
861 Handle<String> no_name = isolate()->
factory()->empty_string();
863 FunctionLiteral* result =
NULL;
865 info->SetGlobalScope(scope);
866 if (!info->context().is_null()) {
869 original_scope_ = scope;
870 if (info->is_eval()) {
871 if (!scope->is_global_scope() || info->strict_mode() ==
STRICT) {
874 }
else if (info->is_global()) {
877 scope->set_start_position(0);
878 scope->set_end_position(source->length());
884 scope->is_eval_scope()) {
887 ParsingModeScope parsing_mode(
this, mode);
892 scope_->SetStrictMode(info->strict_mode());
893 ZoneList<Statement*>* body =
new(
zone()) ZoneList<Statement*>(16,
zone());
896 ParseSourceElements(body, Token::EOS, info->is_eval(),
true, &ok);
902 CheckConflictingVarDeclarations(
scope_, &ok);
906 if (body->length() != 1 ||
907 !body->at(0)->IsExpressionStatement() ||
908 !body->at(0)->AsExpressionStatement()->
909 expression()->IsFunctionLiteral()) {
910 ReportMessage(
"single_function_literal", Vector<const char*>::empty());
916 result =
factory()->NewFunctionLiteral(
920 function_state.materialized_literal_count(),
921 function_state.expected_property_count(),
922 function_state.handler_count(),
924 FunctionLiteral::kNoDuplicateParameters,
925 FunctionLiteral::ANONYMOUS_EXPRESSION,
926 FunctionLiteral::kGlobalOrEval,
927 FunctionLiteral::kNotParenthesized,
928 FunctionLiteral::kNotGenerator,
930 result->set_ast_properties(
factory()->visitor()->ast_properties());
931 result->set_slot_processor(
factory()->visitor()->slot_processor());
932 result->set_dont_optimize_reason(
933 factory()->visitor()->dont_optimize_reason());
946 FunctionLiteral* Parser::ParseLazy() {
947 HistogramTimerScope timer_scope(isolate()->counters()->parse_lazy());
949 isolate()->
counters()->total_parse_size()->Increment(source->length());
951 if (FLAG_trace_parse) {
954 Handle<SharedFunctionInfo> shared_info =
info()->shared_info();
957 source->TryFlatten();
958 FunctionLiteral* result;
959 if (source->IsExternalTwoByteString()) {
960 ExternalTwoByteStringUtf16CharacterStream stream(
961 Handle<ExternalTwoByteString>::cast(source),
962 shared_info->start_position(),
963 shared_info->end_position());
964 result = ParseLazy(&stream);
966 GenericStringUtf16CharacterStream stream(source,
967 shared_info->start_position(),
968 shared_info->end_position());
969 result = ParseLazy(&stream);
972 if (FLAG_trace_parse && result !=
NULL) {
973 double ms = timer.Elapsed().InMillisecondsF();
974 SmartArrayPointer<char> name_chars = result->debug_name()->ToCString();
975 PrintF(
"[parsing function: %s - took %0.3f ms]\n", name_chars.get(), ms);
981 FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) {
982 Handle<SharedFunctionInfo> shared_info =
info()->shared_info();
994 FunctionLiteral* result =
NULL;
999 info()->SetGlobalScope(scope);
1000 if (!
info()->closure().is_null()) {
1004 original_scope_ = scope;
1008 scope->SetStrictMode(shared_info->strict_mode());
1009 FunctionLiteral::FunctionType function_type = shared_info->is_expression()
1010 ? (shared_info->is_anonymous()
1011 ? FunctionLiteral::ANONYMOUS_EXPRESSION
1012 : FunctionLiteral::NAMED_EXPRESSION)
1013 : FunctionLiteral::DECLARATION;
1015 result = ParseFunctionLiteral(name,
1018 shared_info->is_generator(),
1019 RelocInfo::kNoPosition,
1029 if (result ==
NULL) {
1032 Handle<String> inferred_name(shared_info->inferred_name());
1033 result->set_inferred_name(inferred_name);
1039 void* Parser::ParseSourceElements(ZoneList<Statement*>* processor,
1051 TargetScope scope(&this->target_stack_);
1054 bool directive_prologue =
true;
1056 while (peek() != end_token) {
1058 directive_prologue =
false;
1063 if (is_global && !is_eval) {
1068 if (stat ==
NULL || stat->IsEmpty()) {
1069 directive_prologue =
false;
1073 if (directive_prologue) {
1075 ExpressionStatement* e_stat;
1078 if ((e_stat = stat->AsExpressionStatement()) !=
NULL &&
1079 (literal = e_stat->expression()->AsLiteral()) !=
NULL &&
1085 directive->Equals(isolate()->heap()->use_strict_string()) &&
1086 token_loc.end_pos - token_loc.beg_pos ==
1087 isolate()->
heap()->use_strict_string()->length() + 2) {
1093 if (is_eval && !
scope_->is_eval_scope()) {
1096 scope->set_start_position(
scope_->start_position());
1097 scope->set_end_position(
scope_->end_position());
1103 directive_prologue =
false;
1107 directive_prologue =
false;
1111 processor->Add(stat,
zone());
1135 case Token::FUNCTION:
1136 return ParseFunctionDeclaration(
NULL, ok);
1139 return ParseVariableStatement(kModuleElement,
NULL, ok);
1141 return ParseImportDeclaration(ok);
1143 return ParseExportDeclaration(ok);
1145 Statement* stmt = ParseStatement(labels,
CHECK_OK);
1147 if (FLAG_harmony_modules &&
1148 peek() == Token::IDENTIFIER &&
1149 !
scanner()->HasAnyLineTerminatorBeforeNext() &&
1151 ExpressionStatement* estmt = stmt->AsExpressionStatement();
1152 if (estmt !=
NULL &&
1153 estmt->expression()->AsVariableProxy() !=
NULL &&
1154 estmt->expression()->AsVariableProxy()->name()->
Equals(
1155 isolate()->heap()->module_string()) &&
1157 return ParseModuleDeclaration(
NULL, ok);
1166 Statement* Parser::ParseModuleDeclaration(
ZoneStringList* names,
bool* ok) {
1174 if (FLAG_print_interface_details)
1175 PrintF(
"# Module %s...\n", name->ToAsciiArray());
1178 Module* module = ParseModule(
CHECK_OK);
1179 VariableProxy* proxy = NewUnresolved(name,
MODULE, module->interface());
1180 Declaration* declaration =
1181 factory()->NewModuleDeclaration(proxy, module,
scope_, pos);
1182 Declare(declaration,
true,
CHECK_OK);
1185 if (FLAG_print_interface_details)
1186 PrintF(
"# Module %s.\n", name->ToAsciiArray());
1188 if (FLAG_print_interfaces) {
1189 PrintF(
"module %s : ", name->ToAsciiArray());
1190 module->interface()->Print();
1194 if (names) names->Add(name,
zone());
1195 if (module->body() ==
NULL)
1196 return factory()->NewEmptyStatement(pos);
1198 return factory()->NewModuleStatement(proxy, module->body(), pos);
1202 Module* Parser::ParseModule(
bool* ok) {
1210 return ParseModuleLiteral(ok);
1212 case Token::ASSIGN: {
1214 Module* result = ParseModulePath(
CHECK_OK);
1221 Module* result = ParseModuleUrl(
CHECK_OK);
1229 Module* Parser::ParseModuleLiteral(
bool* ok) {
1235 Block* body =
factory()->NewBlock(
NULL, 16,
false, RelocInfo::kNoPosition);
1237 if (FLAG_print_interface_details)
PrintF(
"# Literal ");
1242 scope->set_start_position(
scanner()->location().beg_pos);
1243 scope->SetStrictMode(
STRICT);
1246 BlockState block_state(&
scope_, scope);
1247 TargetCollector collector(
zone());
1248 Target target(&this->target_stack_, &collector);
1249 Target target_body(&this->target_stack_, body);
1251 while (peek() != Token::RBRACE) {
1253 if (stat && !stat->IsEmpty()) {
1254 body->AddStatement(stat,
zone());
1260 scope->set_end_position(
scanner()->location().end_pos);
1261 body->set_scope(scope);
1264 Interface*
interface = scope->
interface();
1265 for (Interface::Iterator it =
interface->iterator();
1266 !it.done(); it.Advance()) {
1267 if (scope->LocalLookup(it.name()) ==
NULL) {
1268 Handle<String>
name(it.name());
1270 Vector<Handle<String> >(&name, 1));
1284 Module* Parser::ParseModulePath(
bool* ok) {
1290 Module* result = ParseModuleVariable(
CHECK_OK);
1291 while (
Check(Token::PERIOD)) {
1294 if (FLAG_print_interface_details)
1295 PrintF(
"# Path .%s ", name->ToAsciiArray());
1297 Module* member =
factory()->NewModulePath(result, name, pos);
1298 result->interface()->Add(name, member->interface(),
zone(), ok);
1301 if (FLAG_print_interfaces) {
1302 PrintF(
"PATH TYPE ERROR at '%s'\n", name->ToAsciiArray());
1304 result->interface()->Print();
1306 member->interface()->Print();
1310 Vector<Handle<String> >(&name, 1));
1320 Module* Parser::ParseModuleVariable(
bool* ok) {
1327 if (FLAG_print_interface_details)
1328 PrintF(
"# Module variable %s ", name->ToAsciiArray());
1330 VariableProxy* proxy =
scope_->NewUnresolved(
1332 scanner()->location().beg_pos);
1334 return factory()->NewModuleVariable(proxy, pos);
1338 Module* Parser::ParseModuleUrl(
bool* ok) {
1349 if (FLAG_print_interface_details)
PrintF(
"# Url ");
1356 body->set_scope(scope);
1357 Interface*
interface = scope->
interface();
1367 Module* Parser::ParseModuleSpecifier(
bool* ok) {
1373 return ParseModuleUrl(ok);
1375 return ParseModulePath(ok);
1380 Block* Parser::ParseImportDeclaration(
bool* ok) {
1391 names.Add(name,
zone());
1395 names.Add(name,
zone());
1399 Module* module = ParseModuleSpecifier(
CHECK_OK);
1405 for (
int i = 0; i < names.length(); ++i) {
1407 if (FLAG_print_interface_details)
1408 PrintF(
"# Import %s ", names[i]->ToAsciiArray());
1414 if (FLAG_print_interfaces) {
1415 PrintF(
"IMPORT TYPE ERROR at '%s'\n", names[i]->ToAsciiArray());
1417 module->interface()->Print();
1421 Vector<Handle<String> >(&name, 1));
1424 VariableProxy* proxy = NewUnresolved(names[i],
LET,
interface);
1425 Declaration* declaration =
1426 factory()->NewImportDeclaration(proxy, module,
scope_, pos);
1427 Declare(declaration,
true,
CHECK_OK);
1434 Statement* Parser::ParseExportDeclaration(
bool* ok) {
1446 Statement* result =
NULL;
1449 case Token::IDENTIFIER: {
1451 Handle<String> name =
1455 names.Add(name,
zone());
1459 names.Add(name,
zone());
1462 result =
factory()->NewEmptyStatement(pos);
1464 result = ParseModuleDeclaration(&names,
CHECK_OK);
1469 case Token::FUNCTION:
1470 result = ParseFunctionDeclaration(&names,
CHECK_OK);
1476 result = ParseVariableStatement(kModuleElement, &names,
CHECK_OK);
1487 for (
int i = 0; i < names.length(); ++i) {
1489 if (FLAG_print_interface_details)
1490 PrintF(
"# Export %s ", names[i]->ToAsciiArray());
1496 VariableProxy* proxy = NewUnresolved(names[i],
LET, inner);
1524 case Token::FUNCTION:
1525 return ParseFunctionDeclaration(
NULL, ok);
1528 return ParseVariableStatement(kModuleElement,
NULL, ok);
1530 return ParseStatement(labels, ok);
1535 Statement* Parser::ParseStatement(
ZoneStringList* labels,
bool* ok) {
1561 return ParseBlock(labels, ok);
1566 return ParseVariableStatement(kStatement,
NULL, ok);
1568 case Token::SEMICOLON:
1570 return factory()->NewEmptyStatement(RelocInfo::kNoPosition);
1573 return ParseIfStatement(labels, ok);
1576 return ParseDoWhileStatement(labels, ok);
1579 return ParseWhileStatement(labels, ok);
1582 return ParseForStatement(labels, ok);
1584 case Token::CONTINUE:
1585 return ParseContinueStatement(ok);
1588 return ParseBreakStatement(labels, ok);
1591 return ParseReturnStatement(ok);
1594 return ParseWithStatement(labels, ok);
1597 return ParseSwitchStatement(labels, ok);
1600 return ParseThrowStatement(ok);
1609 factory()->NewBlock(labels, 1,
false, RelocInfo::kNoPosition);
1610 Target target(&this->target_stack_, result);
1611 TryStatement* statement = ParseTryStatement(
CHECK_OK);
1612 if (result) result->AddStatement(statement,
zone());
1616 case Token::FUNCTION: {
1633 return ParseFunctionDeclaration(
NULL, ok);
1636 case Token::DEBUGGER:
1637 return ParseDebuggerStatement(ok);
1640 return ParseExpressionOrLabelledStatement(labels, ok);
1645 VariableProxy* Parser::NewUnresolved(
1657 void Parser::Declare(Declaration* declaration,
bool resolve,
bool* ok) {
1658 VariableProxy* proxy = declaration->proxy();
1659 Handle<String> name = proxy->name();
1661 Scope* declaration_scope = DeclarationScope(mode);
1662 Variable* var =
NULL;
1672 if (declaration_scope->is_function_scope() ||
1673 declaration_scope->is_strict_eval_scope() ||
1674 declaration_scope->is_block_scope() ||
1675 declaration_scope->is_module_scope() ||
1676 declaration_scope->is_global_scope()) {
1681 var = declaration_scope->is_global_scope()
1682 ? declaration_scope->Lookup(name)
1683 : declaration_scope->LocalLookup(name);
1686 var = declaration_scope->DeclareLocal(
1687 name, mode, declaration->initialization(), proxy->interface());
1688 }
else if ((mode !=
VAR || var->mode() !=
VAR) &&
1689 (!declaration_scope->is_global_scope() ||
1709 SmartArrayPointer<char> c_string = name->ToCString(
DISALLOW_NULLS);
1710 const char* elms[2] = {
"Variable", c_string.get() };
1711 Vector<const char*> args(elms, 2);
1716 Handle<String> message_string =
1719 Expression* expression =
1720 NewThrowTypeError(isolate()->
factory()->redeclaration_string(),
1721 message_string, name);
1722 declaration_scope->SetIllegalRedeclaration(expression);
1742 declaration_scope->AddDeclaration(declaration);
1744 if (mode ==
CONST_LEGACY && declaration_scope->is_global_scope()) {
1748 var =
new(
zone()) Variable(
1749 declaration_scope, name, mode,
true, kind,
1751 }
else if (declaration_scope->is_eval_scope() &&
1752 declaration_scope->strict_mode() ==
SLOPPY) {
1757 var =
new(
zone()) Variable(
1758 declaration_scope, name, mode,
true, kind,
1759 declaration->initialization(), proxy->interface());
1788 if (resolve && var !=
NULL) {
1791 if (FLAG_harmony_modules) {
1794 if (FLAG_print_interface_details)
1795 PrintF(
"# Declare %s\n", var->name()->ToAsciiArray());
1797 proxy->interface()->Unify(var->interface(),
zone(), &ok);
1800 if (FLAG_print_interfaces) {
1801 PrintF(
"DECLARE TYPE ERROR\n");
1803 proxy->interface()->Print();
1805 var->interface()->Print();
1809 Vector<Handle<String> >(&name, 1));
1820 Statement* Parser::ParseNativeDeclaration(
bool* ok) {
1826 bool done = (peek() == Token::RPAREN);
1829 done = (peek() == Token::RPAREN);
1847 Declaration* declaration =
1849 Declare(declaration,
true,
CHECK_OK);
1850 NativeFunctionLiteral* lit =
factory()->NewNativeFunctionLiteral(
1852 return factory()->NewExpressionStatement(
1854 Token::INIT_VAR, proxy, lit, RelocInfo::kNoPosition),
1859 Statement* Parser::ParseFunctionDeclaration(
ZoneStringList* names,
bool* ok) {
1868 bool is_strict_reserved =
false;
1871 FunctionLiteral* fun = ParseFunctionLiteral(name,
1876 FunctionLiteral::DECLARATION,
1887 Declaration* declaration =
1888 factory()->NewFunctionDeclaration(proxy, mode, fun,
scope_, pos);
1889 Declare(declaration,
true,
CHECK_OK);
1890 if (names) names->Add(name,
zone());
1891 return factory()->NewEmptyStatement(RelocInfo::kNoPosition);
1897 return ParseScopedBlock(labels, ok);
1908 factory()->NewBlock(labels, 16,
false, RelocInfo::kNoPosition);
1909 Target target(&this->target_stack_, result);
1911 while (peek() != Token::RBRACE) {
1913 if (stat && !stat->IsEmpty()) {
1914 result->AddStatement(stat,
zone());
1930 factory()->NewBlock(labels, 16,
false, RelocInfo::kNoPosition);
1935 block_scope->set_start_position(
scanner()->location().beg_pos);
1936 { BlockState block_state(&
scope_, block_scope);
1937 TargetCollector collector(
zone());
1938 Target target(&this->target_stack_, &collector);
1939 Target target_body(&this->target_stack_, body);
1941 while (peek() != Token::RBRACE) {
1943 if (stat && !stat->IsEmpty()) {
1944 body->AddStatement(stat,
zone());
1949 block_scope->set_end_position(
scanner()->location().end_pos);
1950 block_scope = block_scope->FinalizeBlockScope();
1951 body->set_scope(block_scope);
1956 Block* Parser::ParseVariableStatement(VariableDeclarationContext var_context,
1962 Handle<String> ignore;
1964 ParseVariableDeclarations(var_context,
NULL, names, &ignore,
CHECK_OK);
1975 Block* Parser::ParseVariableDeclarations(
1976 VariableDeclarationContext var_context,
1977 VariableDeclarationProperties* decl_props,
1979 Handle<String>* out,
2001 bool needs_init =
false;
2002 bool is_const =
false;
2021 init_op = Token::INIT_CONST_LEGACY;
2025 if (var_context == kStatement) {
2028 ReportMessage(
"unprotected_const", Vector<const char*>::empty());
2033 init_op = Token::INIT_CONST;
2035 ReportMessage(
"strict_const", Vector<const char*>::empty());
2057 if (var_context == kStatement) {
2059 ReportMessage(
"unprotected_let", Vector<const char*>::empty());
2065 init_op = Token::INIT_LET;
2070 Scope* declaration_scope = DeclarationScope(mode);
2087 Handle<String>
name;
2111 Interface*
interface =
2113 VariableProxy* proxy = NewUnresolved(name, mode, interface);
2114 Declaration* declaration =
2115 factory()->NewVariableDeclaration(proxy, mode, scope_, pos);
2116 Declare(declaration, mode != VAR, CHECK_OK);
2118 if (declaration_scope->num_var_or_const() > kMaxNumFunctionLocals) {
2123 if (names) names->Add(name,
zone());
2152 Scope* initialization_scope = is_const ? declaration_scope :
scope_;
2153 Expression* value =
NULL;
2156 if (peek() == Token::ASSIGN || mode ==
CONST) {
2162 value->AsCall() ==
NULL &&
2163 value->AsCallNew() ==
NULL) {
2168 if (decl_props !=
NULL) *decl_props = kHasInitializers;
2172 if (proxy->var() !=
NULL) {
2173 proxy->var()->set_initializer_position(
position());
2177 if (value ==
NULL && needs_init) {
2178 value = GetLiteralUndefined(
position());
2200 if (initialization_scope->is_global_scope() &&
2203 ZoneList<Expression*>* arguments =
2204 new(
zone()) ZoneList<Expression*>(3,
zone());
2206 arguments->Add(
factory()->NewLiteral(name, pos),
zone());
2207 CallRuntime* initialize;
2210 arguments->Add(value,
zone());
2217 initialize =
factory()->NewCallRuntime(
2218 isolate()->
factory()->InitializeConstGlobal_string(),
2225 arguments->Add(
factory()->NewNumberLiteral(strict_mode, pos),
zone());
2231 if (value !=
NULL && !inside_with()) {
2232 arguments->Add(value,
zone());
2240 initialize =
factory()->NewCallRuntime(
2241 isolate()->
factory()->InitializeVarGlobal_string(),
2246 block->AddStatement(
2247 factory()->NewExpressionStatement(initialize, RelocInfo::kNoPosition),
2249 }
else if (needs_init) {
2260 Assignment* assignment =
2261 factory()->NewAssignment(init_op, proxy, value, pos);
2262 block->AddStatement(
2263 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition),
2270 if (value !=
NULL) {
2275 VariableProxy* proxy =
2276 initialization_scope->NewUnresolved(
factory(), name, interface);
2277 Assignment* assignment =
2278 factory()->NewAssignment(init_op, proxy, value, pos);
2279 block->AddStatement(
2280 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition),
2289 if (nvars == 1 && !is_const) {
2297 static bool ContainsLabel(
ZoneStringList* labels, Handle<String> label) {
2298 ASSERT(!label.is_null());
2300 for (
int i = labels->length(); i-- > 0; )
2301 if (labels->at(i).is_identical_to(label))
2308 Statement* Parser::ParseExpressionOrLabelledStatement(
ZoneStringList* labels,
2316 if (peek() == Token::COLON && starts_with_idenfifier && expr !=
NULL &&
2317 expr->AsVariableProxy() !=
NULL &&
2318 !expr->AsVariableProxy()->is_this()) {
2321 VariableProxy* var = expr->AsVariableProxy();
2322 Handle<String> label = var->name();
2328 if (ContainsLabel(labels, label) || TargetStackContainsLabel(label)) {
2329 SmartArrayPointer<char> c_string = label->ToCString(
DISALLOW_NULLS);
2330 const char* elms[2] = {
"Label", c_string.get() };
2331 Vector<const char*> args(elms, 2);
2336 if (labels ==
NULL) {
2339 labels->Add(label,
zone());
2343 scope_->RemoveUnresolved(var);
2345 return ParseStatement(labels, ok);
2352 peek() == Token::FUNCTION &&
2353 !
scanner()->HasAnyLineTerminatorBeforeNext() &&
2355 expr->AsVariableProxy() !=
NULL &&
2356 expr->AsVariableProxy()->name()->
Equals(
2357 isolate()->heap()->native_string()) &&
2359 return ParseNativeDeclaration(ok);
2364 if (!FLAG_harmony_modules ||
2365 peek() != Token::IDENTIFIER ||
2366 scanner()->HasAnyLineTerminatorBeforeNext() ||
2367 expr->AsVariableProxy() ==
NULL ||
2368 !expr->AsVariableProxy()->name()->
Equals(
2369 isolate()->heap()->module_string()) ||
2373 return factory()->NewExpressionStatement(expr, pos);
2377 IfStatement* Parser::ParseIfStatement(
ZoneStringList* labels,
bool* ok) {
2386 Statement* then_statement = ParseStatement(labels,
CHECK_OK);
2387 Statement* else_statement =
NULL;
2388 if (peek() == Token::ELSE) {
2390 else_statement = ParseStatement(labels,
CHECK_OK);
2392 else_statement =
factory()->NewEmptyStatement(RelocInfo::kNoPosition);
2394 return factory()->NewIfStatement(
2395 condition, then_statement, else_statement, pos);
2399 Statement* Parser::ParseContinueStatement(
bool* ok) {
2407 if (!
scanner()->HasAnyLineTerminatorBeforeNext() &&
2408 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) {
2412 IterationStatement* target =
NULL;
2413 target = LookupContinueTarget(label,
CHECK_OK);
2414 if (target ==
NULL) {
2416 const char*
message =
"illegal_continue";
2417 Vector<Handle<String> > args;
2418 if (!label.is_null()) {
2419 message =
"unknown_label";
2420 args = Vector<Handle<String> >(&label, 1);
2427 return factory()->NewContinueStatement(target, pos);
2431 Statement* Parser::ParseBreakStatement(
ZoneStringList* labels,
bool* ok) {
2437 Handle<String> label;
2439 if (!
scanner()->HasAnyLineTerminatorBeforeNext() &&
2440 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) {
2446 if (!label.is_null() && ContainsLabel(labels, label)) {
2448 return factory()->NewEmptyStatement(pos);
2450 BreakableStatement* target =
NULL;
2451 target = LookupBreakTarget(label,
CHECK_OK);
2452 if (target ==
NULL) {
2454 const char* message =
"illegal_break";
2455 Vector<Handle<String> > args;
2456 if (!label.is_null()) {
2457 message =
"unknown_label";
2458 args = Vector<Handle<String> >(&label, 1);
2465 return factory()->NewBreakStatement(target, pos);
2469 Statement* Parser::ParseReturnStatement(
bool* ok) {
2481 Expression* return_value;
2482 if (
scanner()->HasAnyLineTerminatorBeforeNext() ||
2483 tok == Token::SEMICOLON ||
2484 tok == Token::RBRACE ||
2485 tok == Token::EOS) {
2486 return_value = GetLiteralUndefined(
position());
2492 Expression* generator =
factory()->NewVariableProxy(
2494 Expression* yield =
factory()->NewYield(
2495 generator, return_value, Yield::FINAL, pos);
2496 result =
factory()->NewExpressionStatement(yield, pos);
2498 result =
factory()->NewReturnStatement(return_value, pos);
2506 Scope* declaration_scope =
scope_->DeclarationScope();
2507 if (declaration_scope->is_global_scope() ||
2508 declaration_scope->is_eval_scope()) {
2509 Handle<String> message = isolate()->
factory()->illegal_return_string();
2510 Expression* throw_error =
2511 NewThrowSyntaxError(message, Handle<Object>::null());
2512 return factory()->NewExpressionStatement(throw_error, pos);
2518 Statement* Parser::ParseWithStatement(
ZoneStringList* labels,
bool* ok) {
2526 ReportMessage(
"strict_mode_with", Vector<const char*>::empty());
2535 scope_->DeclarationScope()->RecordWithStatement();
2538 { BlockState block_state(&
scope_, with_scope);
2539 with_scope->set_start_position(
scanner()->peek_location().beg_pos);
2540 stmt = ParseStatement(labels,
CHECK_OK);
2541 with_scope->set_end_position(
scanner()->location().end_pos);
2543 return factory()->NewWithStatement(with_scope, expr, stmt, pos);
2547 CaseClause* Parser::ParseCaseClause(
bool* default_seen_ptr,
bool* ok) {
2552 Expression* label =
NULL;
2558 if (*default_seen_ptr) {
2560 Vector<const char*>::empty());
2564 *default_seen_ptr =
true;
2568 ZoneList<Statement*>* statements =
2569 new(
zone()) ZoneList<Statement*>(5,
zone());
2572 peek() != Token::RBRACE) {
2574 statements->Add(stat,
zone());
2577 return factory()->NewCaseClause(label, statements, pos);
2581 SwitchStatement* Parser::ParseSwitchStatement(
ZoneStringList* labels,
2586 SwitchStatement* statement =
2588 Target target(&this->target_stack_, statement);
2595 bool default_seen =
false;
2596 ZoneList<CaseClause*>* cases =
new(
zone()) ZoneList<CaseClause*>(4,
zone());
2598 while (peek() != Token::RBRACE) {
2599 CaseClause* clause = ParseCaseClause(&default_seen,
CHECK_OK);
2600 cases->Add(clause,
zone());
2604 if (statement) statement->Initialize(tag, cases);
2609 Statement* Parser::ParseThrowStatement(
bool* ok) {
2615 if (
scanner()->HasAnyLineTerminatorBeforeNext()) {
2616 ReportMessage(
"newline_after_throw", Vector<const char*>::empty());
2623 return factory()->NewExpressionStatement(
2624 factory()->NewThrow(exception, pos), pos);
2628 TryStatement* Parser::ParseTryStatement(
bool* ok) {
2643 TargetCollector try_collector(
zone());
2646 { Target target(&this->target_stack_, &try_collector);
2651 if (tok != Token::CATCH && tok != Token::FINALLY) {
2652 ReportMessage(
"no_catch_or_finally", Vector<const char*>::empty());
2661 TargetCollector catch_collector(
zone());
2662 Scope* catch_scope =
NULL;
2663 Variable* catch_variable =
NULL;
2665 Handle<String>
name;
2666 if (tok == Token::CATCH) {
2671 catch_scope->set_start_position(
scanner()->location().beg_pos);
2676 Target target(&this->target_stack_, &catch_collector);
2682 BlockState block_state(&
scope_, catch_scope);
2685 catch_scope->set_end_position(
scanner()->location().end_pos);
2690 ASSERT(tok == Token::FINALLY || catch_block !=
NULL);
2691 if (tok == Token::FINALLY) {
2701 if (catch_block !=
NULL && finally_block !=
NULL) {
2705 TryCatchStatement* statement =
factory()->NewTryCatchStatement(
2706 index, try_block, catch_scope, catch_variable, catch_block,
2707 RelocInfo::kNoPosition);
2708 statement->set_escaping_targets(try_collector.targets());
2709 try_block =
factory()->NewBlock(
NULL, 1,
false, RelocInfo::kNoPosition);
2710 try_block->AddStatement(statement,
zone());
2714 TryStatement* result =
NULL;
2715 if (catch_block !=
NULL) {
2719 result =
factory()->NewTryCatchStatement(
2720 index, try_block, catch_scope, catch_variable, catch_block, pos);
2724 result =
factory()->NewTryFinallyStatement(
2725 index, try_block, finally_block, pos);
2727 try_collector.targets()->AddAll(*catch_collector.targets(),
zone());
2730 result->set_escaping_targets(try_collector.targets());
2735 DoWhileStatement* Parser::ParseDoWhileStatement(
ZoneStringList* labels,
2740 DoWhileStatement* loop =
2742 Target target(&this->target_stack_, loop);
2756 if (peek() == Token::SEMICOLON)
Consume(Token::SEMICOLON);
2758 if (loop !=
NULL) loop->Initialize(cond, body);
2763 WhileStatement* Parser::ParseWhileStatement(
ZoneStringList* labels,
bool* ok) {
2768 Target target(&this->target_stack_, loop);
2776 if (loop !=
NULL) loop->Initialize(cond, body);
2781 bool Parser::CheckInOrOf(
bool accept_OF,
2795 void Parser::InitializeForEachStatement(ForEachStatement* stmt,
2797 Expression* subject,
2799 ForOfStatement* for_of = stmt->AsForOfStatement();
2801 if (for_of !=
NULL) {
2802 Factory* heap_factory = isolate()->
factory();
2803 Variable* iterator =
scope_->DeclarationScope()->NewTemporary(
2804 heap_factory->dot_iterator_string());
2805 Variable* result =
scope_->DeclarationScope()->NewTemporary(
2806 heap_factory->dot_result_string());
2808 Expression* assign_iterator;
2809 Expression* next_result;
2810 Expression* result_done;
2811 Expression* assign_each;
2815 Expression* iterator_proxy =
factory()->NewVariableProxy(iterator);
2816 assign_iterator =
factory()->NewAssignment(
2817 Token::ASSIGN, iterator_proxy, subject, RelocInfo::kNoPosition);
2822 Expression* iterator_proxy =
factory()->NewVariableProxy(iterator);
2823 Expression* next_literal =
factory()->NewLiteral(
2824 heap_factory->next_string(), RelocInfo::kNoPosition);
2825 Expression* next_property =
factory()->NewProperty(
2826 iterator_proxy, next_literal, RelocInfo::kNoPosition);
2827 ZoneList<Expression*>* next_arguments =
2828 new(
zone()) ZoneList<Expression*>(0,
zone());
2829 Expression* next_call =
factory()->NewCall(
2830 next_property, next_arguments, RelocInfo::kNoPosition);
2831 Expression* result_proxy =
factory()->NewVariableProxy(result);
2832 next_result =
factory()->NewAssignment(
2833 Token::ASSIGN, result_proxy, next_call, RelocInfo::kNoPosition);
2838 Expression* done_literal =
factory()->NewLiteral(
2839 heap_factory->done_string(), RelocInfo::kNoPosition);
2840 Expression* result_proxy =
factory()->NewVariableProxy(result);
2841 result_done =
factory()->NewProperty(
2842 result_proxy, done_literal, RelocInfo::kNoPosition);
2847 Expression* value_literal =
factory()->NewLiteral(
2848 heap_factory->value_string(), RelocInfo::kNoPosition);
2849 Expression* result_proxy =
factory()->NewVariableProxy(result);
2850 Expression* result_value =
factory()->NewProperty(
2851 result_proxy, value_literal, RelocInfo::kNoPosition);
2852 assign_each =
factory()->NewAssignment(
2853 Token::ASSIGN, each, result_value, RelocInfo::kNoPosition);
2856 for_of->Initialize(each, subject, body,
2857 assign_iterator, next_result, result_done, assign_each);
2859 stmt->Initialize(each, subject, body);
2864 Statement* Parser::ParseForStatement(
ZoneStringList* labels,
bool* ok) {
2869 Statement* init =
NULL;
2872 Scope* saved_scope =
scope_;
2878 for_scope->set_start_position(
scanner()->location().beg_pos);
2879 if (peek() != Token::SEMICOLON) {
2882 Handle<String>
name;
2883 VariableDeclarationProperties decl_props = kHasNoInitializers;
2884 Block* variable_statement =
2885 ParseVariableDeclarations(kForStatement, &decl_props,
NULL, &name,
2887 bool accept_OF = decl_props == kHasNoInitializers;
2890 if (!name.is_null() && CheckInOrOf(accept_OF, &mode)) {
2891 Interface*
interface =
2893 ForEachStatement* loop =
2894 factory()->NewForEachStatement(mode, labels, pos);
2895 Target target(&this->target_stack_, loop);
2898 Expect(Token::RPAREN, CHECK_OK);
2900 VariableProxy* each =
2901 scope_->NewUnresolved(factory(), name, interface);
2902 Statement* body = ParseStatement(NULL, CHECK_OK);
2903 InitializeForEachStatement(loop, each, enumerable, body);
2905 factory()->NewBlock(NULL, 2, false, RelocInfo::kNoPosition);
2906 result->AddStatement(variable_statement, zone());
2907 result->AddStatement(loop, zone());
2909 for_scope->set_end_position(scanner()->location().end_pos);
2910 for_scope = for_scope->FinalizeBlockScope();
2911 ASSERT(for_scope == NULL);
2915 init = variable_statement;
2918 Handle<String>
name;
2919 VariableDeclarationProperties decl_props = kHasNoInitializers;
2920 Block* variable_statement =
2921 ParseVariableDeclarations(kForStatement, &decl_props,
NULL, &name,
2923 bool accept_IN = !name.is_null() && decl_props != kHasInitializers;
2924 bool accept_OF = decl_props == kHasNoInitializers;
2927 if (accept_IN && CheckInOrOf(accept_OF, &mode)) {
2943 Factory* heap_factory = isolate()->
factory();
2944 Handle<String> tempstr =
2947 Handle<String> tempname = heap_factory->InternalizeString(tempstr);
2948 Variable* temp =
scope_->DeclarationScope()->NewTemporary(tempname);
2949 VariableProxy* temp_proxy =
factory()->NewVariableProxy(temp);
2950 ForEachStatement* loop =
2951 factory()->NewForEachStatement(mode, labels, pos);
2952 Target target(&this->target_stack_, loop);
2960 VariableProxy* each =
2964 factory()->NewBlock(
NULL, 3,
false, RelocInfo::kNoPosition);
2965 Assignment* assignment =
factory()->NewAssignment(
2966 Token::ASSIGN, each, temp_proxy, RelocInfo::kNoPosition);
2967 Statement* assignment_statement =
factory()->NewExpressionStatement(
2968 assignment, RelocInfo::kNoPosition);
2969 body_block->AddStatement(variable_statement,
zone());
2970 body_block->AddStatement(assignment_statement,
zone());
2971 body_block->AddStatement(body,
zone());
2972 InitializeForEachStatement(loop, temp_proxy, enumerable, body_block);
2974 for_scope->set_end_position(
scanner()->location().end_pos);
2975 for_scope = for_scope->FinalizeBlockScope();
2976 body_block->set_scope(for_scope);
2981 init = variable_statement;
2987 bool accept_OF = expression->AsVariableProxy();
2989 if (CheckInOrOf(accept_OF, &mode)) {
2990 if (expression ==
NULL || !expression->IsValidLeftHandSide()) {
2995 ForEachStatement* loop =
2996 factory()->NewForEachStatement(mode, labels, pos);
2997 Target target(&this->target_stack_, loop);
3003 InitializeForEachStatement(loop, expression, enumerable, body);
3005 for_scope->set_end_position(
scanner()->location().end_pos);
3006 for_scope = for_scope->FinalizeBlockScope();
3012 init =
factory()->NewExpressionStatement(
3013 expression, RelocInfo::kNoPosition);
3019 ForStatement* loop =
factory()->NewForStatement(labels, pos);
3020 Target target(&this->target_stack_, loop);
3025 Expression* cond =
NULL;
3026 if (peek() != Token::SEMICOLON) {
3031 Statement* next =
NULL;
3032 if (peek() != Token::RPAREN) {
3034 next =
factory()->NewExpressionStatement(exp, RelocInfo::kNoPosition);
3040 for_scope->set_end_position(
scanner()->location().end_pos);
3041 for_scope = for_scope->FinalizeBlockScope();
3042 if (for_scope !=
NULL) {
3054 Block* result =
factory()->NewBlock(
NULL, 2,
false, RelocInfo::kNoPosition);
3055 result->AddStatement(init,
zone());
3056 result->AddStatement(loop,
zone());
3057 result->set_scope(for_scope);
3058 loop->Initialize(
NULL, cond, next, body);
3061 loop->Initialize(init, cond, next, body);
3067 DebuggerStatement* Parser::ParseDebuggerStatement(
bool* ok) {
3077 return factory()->NewDebuggerStatement(pos);
3081 void Parser::ReportInvalidPreparseData(Handle<String> name,
bool* ok) {
3082 SmartArrayPointer<char> name_string = name->ToCString(
DISALLOW_NULLS);
3083 const char* element[1] = { name_string.get() };
3085 Vector<const char*>(element, 1));
3091 if (expression->AsLiteral() !=
NULL)
return true;
3100 ASSERT(IsCompileTimeValue(expression));
3102 ObjectLiteral* object_literal = expression->AsObjectLiteral();
3103 if (object_literal !=
NULL) {
3104 ASSERT(object_literal->is_simple());
3105 if (object_literal->fast_elements()) {
3106 result->set(kLiteralTypeSlot,
Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS));
3108 result->set(kLiteralTypeSlot,
Smi::FromInt(OBJECT_LITERAL_SLOW_ELEMENTS));
3110 result->set(kElementsSlot, *object_literal->constant_properties());
3112 ArrayLiteral* array_literal = expression->AsArrayLiteral();
3113 ASSERT(array_literal !=
NULL && array_literal->is_simple());
3114 result->set(kLiteralTypeSlot,
Smi::FromInt(ARRAY_LITERAL));
3115 result->set(kElementsSlot, *array_literal->constant_elements());
3123 Smi* literal_type =
Smi::cast(value->get(kLiteralTypeSlot));
3133 FunctionLiteral* Parser::ParseFunctionLiteral(
3136 bool name_is_strict_reserved,
3138 int function_token_pos,
3139 FunctionLiteral::FunctionType function_type,
3144 int pos = function_token_pos == RelocInfo::kNoPosition
3150 bool should_infer_name = function_name.
is_null();
3153 if (should_infer_name) {
3154 function_name = isolate()->
factory()->empty_string();
3157 int num_parameters = 0;
3185 Scope* declaration_scope =
scope_->DeclarationScope();
3188 function_type == FunctionLiteral::DECLARATION &&
3190 (original_scope_ == original_declaration_scope ||
3191 declaration_scope != original_declaration_scope)
3194 ZoneList<Statement*>* body =
NULL;
3195 int materialized_literal_count = -1;
3196 int expected_property_count = -1;
3197 int handler_count = 0;
3198 FunctionLiteral::ParameterFlag duplicate_parameters =
3199 FunctionLiteral::kNoDuplicateParameters;
3201 ? FunctionLiteral::kIsParenthesized
3202 : FunctionLiteral::kNotParenthesized;
3203 FunctionLiteral::IsGeneratorFlag generator = is_generator
3204 ? FunctionLiteral::kIsGenerator
3205 : FunctionLiteral::kNotGenerator;
3206 DeferredFeedbackSlotProcessor* slot_processor;
3207 AstProperties ast_properties;
3211 scope_->SetScopeName(function_name);
3217 scope_->ForceContextAllocation();
3222 Variable* temp =
scope_->DeclarationScope()->NewTemporary(
3223 isolate()->
factory()->dot_generator_object_string());
3224 function_state.set_generator_object_variable(temp);
3230 scope->set_start_position(
scanner()->location().beg_pos);
3239 bool done = (peek() == Token::RPAREN);
3241 bool is_strict_reserved =
false;
3242 Handle<String> param_name =
3249 if (!reserved_loc.IsValid() && is_strict_reserved) {
3252 if (!dupe_error_loc.IsValid() &&
scope_->IsDeclared(param_name)) {
3253 duplicate_parameters = FunctionLiteral::kHasDuplicateParameters;
3257 scope_->DeclareParameter(param_name,
VAR);
3264 done = (peek() == Token::RPAREN);
3277 Variable* fvar =
NULL;
3279 if (function_type == FunctionLiteral::NAMED_EXPRESSION) {
3281 fvar_init_op = Token::INIT_CONST;
3287 function_name, fvar_mode,
true ,
3289 VariableProxy* proxy =
factory()->NewVariableProxy(fvar);
3290 VariableDeclaration* fvar_declaration =
factory()->NewVariableDeclaration(
3291 proxy, fvar_mode,
scope_, RelocInfo::kNoPosition);
3292 scope_->DeclareFunctionVar(fvar_declaration);
3329 scope_->AllowsLazyCompilation() &&
3333 if (is_lazily_parsed) {
3334 int function_block_pos =
position();
3335 FunctionEntry entry;
3340 entry = (*cached_data())->GetFunctionEntry(function_block_pos);
3341 if (entry.is_valid()) {
3342 if (entry.end_pos() <= function_block_pos) {
3345 ReportInvalidPreparseData(function_name,
CHECK_OK);
3349 scope->set_end_position(entry.end_pos());
3351 isolate()->
counters()->total_preparse_skipped()->Increment(
3352 scope->end_position() - function_block_pos);
3353 materialized_literal_count = entry.literal_count();
3354 expected_property_count = entry.property_count();
3355 scope_->SetStrictMode(entry.strict_mode());
3363 is_lazily_parsed =
false;
3372 SingletonLogger logger;
3380 if (logger.has_error()) {
3381 const char* arg = logger.argument_opt();
3382 Vector<const char*> args;
3384 args = Vector<const char*>(&arg, 1);
3387 Scanner::Location(logger.start(), logger.end()),
3393 scope->set_end_position(logger.end());
3395 isolate()->
counters()->total_preparse_skipped()->Increment(
3396 scope->end_position() - function_block_pos);
3397 materialized_literal_count = logger.literals();
3398 expected_property_count = logger.properties();
3399 scope_->SetStrictMode(logger.strict_mode());
3405 materialized_literal_count,
3406 expected_property_count,
3412 if (!is_lazily_parsed) {
3416 body =
new(
zone()) ZoneList<Statement*>(8,
zone());
3418 VariableProxy* fproxy =
scope_->NewUnresolved(
3420 fproxy->BindTo(fvar);
3421 body->Add(
factory()->NewExpressionStatement(
3422 factory()->NewAssignment(fvar_init_op,
3424 factory()->NewThisFunction(pos),
3425 RelocInfo::kNoPosition),
3426 RelocInfo::kNoPosition),
zone());
3431 ZoneList<Expression*>* arguments =
3432 new(
zone()) ZoneList<Expression*>(0,
zone());
3433 CallRuntime* allocation =
factory()->NewCallRuntime(
3434 isolate()->
factory()->empty_string(),
3437 VariableProxy* init_proxy =
factory()->NewVariableProxy(
3439 Assignment* assignment =
factory()->NewAssignment(
3440 Token::INIT_VAR, init_proxy, allocation, RelocInfo::kNoPosition);
3441 VariableProxy* get_proxy =
factory()->NewVariableProxy(
3443 Yield* yield =
factory()->NewYield(
3444 get_proxy, assignment, Yield::INITIAL, RelocInfo::kNoPosition);
3445 body->Add(
factory()->NewExpressionStatement(
3446 yield, RelocInfo::kNoPosition),
zone());
3449 ParseSourceElements(body, Token::RBRACE,
false,
false,
CHECK_OK);
3452 VariableProxy* get_proxy =
factory()->NewVariableProxy(
3454 Expression *undefined =
factory()->NewLiteral(
3455 isolate()->
factory()->undefined_value(), RelocInfo::kNoPosition);
3456 Yield* yield =
factory()->NewYield(
3457 get_proxy, undefined, Yield::FINAL, RelocInfo::kNoPosition);
3458 body->Add(
factory()->NewExpressionStatement(
3459 yield, RelocInfo::kNoPosition),
zone());
3462 materialized_literal_count = function_state.materialized_literal_count();
3463 expected_property_count = function_state.expected_property_count();
3464 handler_count = function_state.handler_count();
3467 scope->set_end_position(
scanner()->location().end_pos);
3478 if (name_is_strict_reserved) {
3479 ReportMessageAt(function_name_location,
"unexpected_strict_reserved");
3483 if (eval_args_error_log.IsValid()) {
3488 if (dupe_error_loc.IsValid()) {
3493 if (reserved_loc.IsValid()) {
3499 scope->end_position(),
3502 ast_properties = *
factory()->visitor()->ast_properties();
3503 slot_processor =
factory()->visitor()->slot_processor();
3504 dont_optimize_reason =
factory()->visitor()->dont_optimize_reason();
3508 CheckConflictingVarDeclarations(scope,
CHECK_OK);
3511 FunctionLiteral* function_literal =
3512 factory()->NewFunctionLiteral(function_name,
3515 materialized_literal_count,
3516 expected_property_count,
3519 duplicate_parameters,
3521 FunctionLiteral::kIsFunction,
3525 function_literal->set_function_token_position(function_token_pos);
3526 function_literal->set_ast_properties(&ast_properties);
3527 function_literal->set_slot_processor(slot_processor);
3528 function_literal->set_dont_optimize_reason(dont_optimize_reason);
3531 return function_literal;
3536 SingletonLogger* logger) {
3537 HistogramTimerScope preparse_scope(isolate()->counters()->pre_parse());
3540 if (reusable_preparser_ ==
NULL) {
3542 reusable_preparser_ =
new PreParser(&scanner_,
NULL, stack_limit);
3560 Expression* Parser::ParseV8Intrinsic(
bool* ok) {
3573 scope_->DeclarationScope()->ForceEagerCompilation();
3579 if (
function !=
NULL &&
3581 function->function_id == Runtime::kIS_VAR) {
3585 if (args->length() == 1 && args->at(0)->AsVariableProxy() !=
NULL) {
3595 if (
function !=
NULL &&
3596 function->nargs != -1 &&
3597 function->nargs != args->length()) {
3598 ReportMessage(
"illegal_access", Vector<const char*>::empty());
3604 if (
function ==
NULL && name->
Get(0) ==
'_') {
3606 Vector<Handle<String> >(&name, 1));
3612 return factory()->NewCallRuntime(name,
function, args, pos);
3616 Literal* Parser::GetLiteralUndefined(
int position) {
3618 isolate()->
factory()->undefined_value(), position);
3622 void Parser::CheckConflictingVarDeclarations(Scope* scope,
bool* ok) {
3623 Declaration* decl = scope->CheckConflictingVarDeclarations();
3627 Handle<String> name = decl->proxy()->name();
3628 SmartArrayPointer<char> c_string = name->ToCString(
DISALLOW_NULLS);
3629 const char* elms[2] = {
"Variable", c_string.get() };
3630 Vector<const char*> args(elms, 2);
3631 int position = decl->proxy()->position();
3632 Scanner::Location location = position == RelocInfo::kNoPosition
3634 : Scanner::Location(position, position + 1);
3645 bool Parser::TargetStackContainsLabel(Handle<String> label) {
3646 for (Target* t = target_stack_; t !=
NULL; t = t->previous()) {
3647 BreakableStatement* stat = t->node()->AsBreakableStatement();
3648 if (stat !=
NULL && ContainsLabel(stat->labels(), label))
3655 BreakableStatement* Parser::LookupBreakTarget(Handle<String> label,
bool* ok) {
3656 bool anonymous = label.is_null();
3657 for (Target* t = target_stack_; t !=
NULL; t = t->previous()) {
3658 BreakableStatement* stat = t->node()->AsBreakableStatement();
3659 if (stat ==
NULL)
continue;
3660 if ((anonymous && stat->is_target_for_anonymous()) ||
3661 (!anonymous && ContainsLabel(stat->labels(), label))) {
3662 RegisterTargetUse(stat->break_target(), t->previous());
3670 IterationStatement* Parser::LookupContinueTarget(Handle<String> label,
3672 bool anonymous = label.is_null();
3673 for (Target* t = target_stack_; t !=
NULL; t = t->previous()) {
3674 IterationStatement* stat = t->node()->AsIterationStatement();
3675 if (stat ==
NULL)
continue;
3677 ASSERT(stat->is_target_for_anonymous());
3678 if (anonymous || ContainsLabel(stat->labels(), label)) {
3679 RegisterTargetUse(stat->continue_target(), t->previous());
3687 void Parser::RegisterTargetUse(Label* target, Target* stop) {
3691 for (Target* t = target_stack_; t != stop; t = t->previous()) {
3692 TargetCollector* collector = t->node()->AsTargetCollector();
3693 if (collector !=
NULL) collector->AddTarget(target,
zone());
3698 Expression* Parser::NewThrowReferenceError(Handle<String> message) {
3699 return NewThrowError(isolate()->
factory()->MakeReferenceError_string(),
3700 message, HandleVector<Object>(
NULL, 0));
3704 Expression* Parser::NewThrowSyntaxError(Handle<String> message,
3705 Handle<Object> first) {
3706 int argc = first.is_null() ? 0 : 1;
3707 Vector< Handle<Object> > arguments = HandleVector<Object>(&first, argc);
3708 return NewThrowError(
3709 isolate()->
factory()->MakeSyntaxError_string(), message, arguments);
3713 Expression* Parser::NewThrowTypeError(Handle<String> message,
3714 Handle<Object> first,
3715 Handle<Object> second) {
3716 ASSERT(!first.is_null() && !second.is_null());
3717 Handle<Object> elements[] = { first, second };
3718 Vector< Handle<Object> > arguments =
3719 HandleVector<Object>(elements,
ARRAY_SIZE(elements));
3720 return NewThrowError(
3721 isolate()->
factory()->MakeTypeError_string(), message, arguments);
3725 Expression* Parser::NewThrowError(Handle<String> constructor,
3726 Handle<String> message,
3727 Vector< Handle<Object> > arguments) {
3728 int argc = arguments.length();
3731 for (
int i = 0; i < argc; i++) {
3732 Handle<Object> element = arguments[i];
3733 if (!element.is_null()) {
3734 elements->set(i, *element);
3741 ZoneList<Expression*>* args =
new(
zone()) ZoneList<Expression*>(2,
zone());
3742 args->Add(
factory()->NewLiteral(message, pos),
zone());
3743 args->Add(
factory()->NewLiteral(array, pos),
zone());
3744 CallRuntime* call_constructor =
3745 factory()->NewCallRuntime(constructor,
NULL, args, pos);
3746 return factory()->NewThrow(call_constructor, pos);
3754 RegExpParser::RegExpParser(FlatStringReader* in,
3755 Handle<String>* error,
3758 : isolate_(zone->isolate()),
3767 multiline_(multiline),
3769 contains_anchor_(
false),
3770 is_scanned_for_captures_(
false),
3776 uc32 RegExpParser::Next() {
3778 return in()->Get(next_pos_);
3785 void RegExpParser::Advance() {
3786 if (next_pos_ < in()->length()) {
3787 StackLimitCheck
check(isolate());
3788 if (
check.HasOverflowed()) {
3790 }
else if (zone()->excess_allocation()) {
3791 ReportError(
CStrVector(
"Regular expression too large"));
3803 void RegExpParser::Reset(
int pos) {
3805 has_more_ = (pos < in()->length());
3810 void RegExpParser::Advance(
int dist) {
3811 next_pos_ += dist - 1;
3816 bool RegExpParser::simple() {
3821 RegExpTree* RegExpParser::ReportError(Vector<const char> message) {
3823 *error_ = isolate()->factory()->NewStringFromAscii(message,
NOT_TENURED);
3824 ASSERT(!error_->is_null());
3827 next_pos_ = in()->length();
3834 RegExpTree* RegExpParser::ParsePattern() {
3839 if (result->IsAtom() && result->AsAtom()->length() == in()->length()) {
3856 RegExpTree* RegExpParser::ParseDisjunction() {
3858 RegExpParserState initial_state(
NULL, INITIAL, 0, zone());
3859 RegExpParserState* stored_state = &initial_state;
3861 RegExpBuilder* builder = initial_state.builder();
3863 switch (current()) {
3865 if (stored_state->IsSubexpression()) {
3869 ASSERT_EQ(INITIAL, stored_state->group_type());
3871 return builder->ToRegExp();
3873 if (!stored_state->IsSubexpression()) {
3876 ASSERT_NE(INITIAL, stored_state->group_type());
3881 RegExpTree* body = builder->ToRegExp();
3883 int end_capture_index = captures_started();
3885 int capture_index = stored_state->capture_index();
3886 SubexpressionType group_type = stored_state->group_type();
3889 stored_state = stored_state->previous_state();
3890 builder = stored_state->builder();
3893 if (group_type == CAPTURE) {
3894 RegExpCapture* capture =
new(zone()) RegExpCapture(body, capture_index);
3895 captures_->at(capture_index - 1) = capture;
3897 }
else if (group_type != GROUPING) {
3898 ASSERT(group_type == POSITIVE_LOOKAHEAD ||
3899 group_type == NEGATIVE_LOOKAHEAD);
3900 bool is_positive = (group_type == POSITIVE_LOOKAHEAD);
3901 body =
new(zone()) RegExpLookahead(body,
3903 end_capture_index - capture_index,
3906 builder->AddAtom(body);
3913 builder->NewAlternative();
3919 return ReportError(
CStrVector(
"Nothing to repeat"));
3923 builder->AddAssertion(
3924 new(zone()) RegExpAssertion(RegExpAssertion::START_OF_LINE));
3926 builder->AddAssertion(
3927 new(zone()) RegExpAssertion(RegExpAssertion::START_OF_INPUT));
3928 set_contains_anchor();
3934 RegExpAssertion::AssertionType assertion_type =
3935 multiline_ ? RegExpAssertion::END_OF_LINE :
3936 RegExpAssertion::END_OF_INPUT;
3937 builder->AddAssertion(
new(zone()) RegExpAssertion(assertion_type));
3943 ZoneList<CharacterRange>* ranges =
3944 new(zone()) ZoneList<CharacterRange>(2, zone());
3946 RegExpTree* atom =
new(zone()) RegExpCharacterClass(ranges,
false);
3947 builder->AddAtom(atom);
3951 SubexpressionType subexpr_type = CAPTURE;
3953 if (current() ==
'?') {
3956 subexpr_type = GROUPING;
3959 subexpr_type = POSITIVE_LOOKAHEAD;
3962 subexpr_type = NEGATIVE_LOOKAHEAD;
3970 if (captures_ ==
NULL) {
3971 captures_ =
new(zone()) ZoneList<RegExpCapture*>(2, zone());
3973 if (captures_started() >= kMaxCaptures) {
3976 captures_->Add(
NULL, zone());
3979 stored_state =
new(zone()) RegExpParserState(stored_state, subexpr_type,
3980 captures_started(), zone());
3981 builder = stored_state->builder();
3986 builder->AddAtom(atom);
3994 return ReportError(
CStrVector(
"\\ at end of pattern"));
3997 builder->AddAssertion(
3998 new(zone()) RegExpAssertion(RegExpAssertion::BOUNDARY));
4002 builder->AddAssertion(
4003 new(zone()) RegExpAssertion(RegExpAssertion::NON_BOUNDARY));
4010 case 'd':
case 'D':
case 's':
case 'S':
case 'w':
case 'W': {
4013 ZoneList<CharacterRange>* ranges =
4014 new(zone()) ZoneList<CharacterRange>(2, zone());
4016 RegExpTree* atom =
new(zone()) RegExpCharacterClass(ranges,
false);
4017 builder->AddAtom(atom);
4020 case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
4021 case '7':
case '8':
case '9': {
4023 if (ParseBackReferenceIndex(&index)) {
4024 RegExpCapture* capture =
NULL;
4025 if (captures_ !=
NULL && index <= captures_->length()) {
4026 capture = captures_->at(index - 1);
4028 if (capture ==
NULL) {
4029 builder->AddEmpty();
4032 RegExpTree* atom =
new(zone()) RegExpBackReference(capture);
4033 builder->AddAtom(atom);
4036 uc32 first_digit = Next();
4037 if (first_digit ==
'8' || first_digit ==
'9') {
4039 builder->AddCharacter(first_digit);
4047 uc32 octal = ParseOctalLiteral();
4048 builder->AddCharacter(octal);
4055 builder->AddCharacter(
'\f');
4059 builder->AddCharacter(
'\n');
4063 builder->AddCharacter(
'\r');
4067 builder->AddCharacter(
'\t');
4071 builder->AddCharacter(
'\v');
4075 uc32 controlLetter = Next();
4078 uc32 letter = controlLetter & ~(
'a' ^
'A');
4079 if (letter <
'A' ||
'Z' < letter) {
4084 builder->AddCharacter(
'\\');
4087 builder->AddCharacter(controlLetter & 0x1f);
4094 if (ParseHexEscape(2, &value)) {
4095 builder->AddCharacter(value);
4097 builder->AddCharacter(
'x');
4104 if (ParseHexEscape(4, &value)) {
4105 builder->AddCharacter(value);
4107 builder->AddCharacter(
'u');
4113 builder->AddCharacter(Next());
4120 if (ParseIntervalQuantifier(&dummy, &dummy)) {
4126 builder->AddCharacter(current());
4133 switch (current()) {
4155 if (ParseIntervalQuantifier(&min, &max)) {
4157 ReportError(
CStrVector(
"numbers out of order in {} quantifier.")
4167 RegExpQuantifier::QuantifierType quantifier_type = RegExpQuantifier::GREEDY;
4168 if (current() ==
'?') {
4169 quantifier_type = RegExpQuantifier::NON_GREEDY;
4171 }
else if (FLAG_regexp_possessive_quantifier && current() ==
'+') {
4173 quantifier_type = RegExpQuantifier::POSSESSIVE;
4176 builder->AddQuantifierToAtom(min, max, quantifier_type);
4183 static bool IsSpecialClassEscape(
uc32 c) {
4202 void RegExpParser::ScanForCaptures() {
4204 int capture_count = captures_started();
4207 while ((n = current()) != kEndMarker) {
4215 while ((c = current()) != kEndMarker) {
4220 if (c ==
']')
break;
4226 if (current() !=
'?') capture_count++;
4230 capture_count_ = capture_count;
4231 is_scanned_for_captures_ =
true;
4235 bool RegExpParser::ParseBackReferenceIndex(
int* index_out) {
4237 ASSERT(
'1' <= Next() && Next() <=
'9');
4240 int start = position();
4241 int value = Next() -
'0';
4246 value = 10 * value + (c -
'0');
4247 if (value > kMaxCaptures) {
4256 if (value > captures_started()) {
4257 if (!is_scanned_for_captures_) {
4258 int saved_position = position();
4260 Reset(saved_position);
4262 if (value > capture_count_) {
4279 bool RegExpParser::ParseIntervalQuantifier(
int* min_out,
int* max_out) {
4281 int start = position();
4289 int next = current() -
'0';
4298 min = 10 * min + next;
4302 if (current() ==
'}') {
4305 }
else if (current() ==
',') {
4307 if (current() ==
'}') {
4312 int next = current() -
'0';
4320 max = 10 * max + next;
4323 if (current() !=
'}') {
4339 uc32 RegExpParser::ParseOctalLiteral() {
4340 ASSERT((
'0' <= current() && current() <=
'7') || current() == kEndMarker);
4343 uc32 value = current() -
'0';
4345 if (
'0' <= current() && current() <=
'7') {
4346 value = value * 8 + current() -
'0';
4348 if (value < 32 &&
'0' <= current() && current() <=
'7') {
4349 value = value * 8 + current() -
'0';
4357 bool RegExpParser::ParseHexEscape(
int length,
uc32 *value) {
4358 int start = position();
4361 for (
int i = 0; !done; i++) {
4370 if (i == length - 1) {
4379 uc32 RegExpParser::ParseClassCharacterEscape() {
4380 ASSERT(current() ==
'\\');
4381 ASSERT(has_next() && !IsSpecialClassEscape(Next()));
4383 switch (current()) {
4405 uc32 controlLetter = Next();
4406 uc32 letter = controlLetter & ~(
'A' ^
'a');
4409 if ((controlLetter >=
'0' && controlLetter <=
'9') ||
4410 controlLetter ==
'_' ||
4411 (letter >=
'A' && letter <=
'Z')) {
4415 return controlLetter & 0x1f;
4421 case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
4426 return ParseOctalLiteral();
4430 if (ParseHexEscape(2, &value)) {
4440 if (ParseHexEscape(4, &value)) {
4451 uc32 result = current();
4460 CharacterRange RegExpParser::ParseClassAtom(
uc16* char_class) {
4462 uc32 first = current();
4463 if (first ==
'\\') {
4465 case 'w':
case 'W':
case 'd':
case 'D':
case 's':
case 'S': {
4466 *char_class = Next();
4471 return ReportError(
CStrVector(
"\\ at end of pattern"));
4483 static const uc16 kNoCharClass = 0;
4488 static inline void AddRangeOrEscape(ZoneList<CharacterRange>* ranges,
4490 CharacterRange range,
4492 if (char_class != kNoCharClass) {
4495 ranges->Add(range, zone);
4500 RegExpTree* RegExpParser::ParseCharacterClass() {
4501 static const char* kUnterminated =
"Unterminated character class";
4502 static const char* kRangeOutOfOrder =
"Range out of order in character class";
4506 bool is_negated =
false;
4507 if (current() ==
'^') {
4511 ZoneList<CharacterRange>* ranges =
4512 new(zone()) ZoneList<CharacterRange>(2, zone());
4513 while (has_more() && current() !=
']') {
4514 uc16 char_class = kNoCharClass;
4515 CharacterRange first = ParseClassAtom(&char_class
CHECK_FAILED);
4516 if (current() ==
'-') {
4518 if (current() == kEndMarker) {
4522 }
else if (current() ==
']') {
4523 AddRangeOrEscape(ranges, char_class, first, zone());
4527 uc16 char_class_2 = kNoCharClass;
4528 CharacterRange next = ParseClassAtom(&char_class_2
CHECK_FAILED);
4529 if (char_class != kNoCharClass || char_class_2 != kNoCharClass) {
4531 AddRangeOrEscape(ranges, char_class, first, zone());
4533 AddRangeOrEscape(ranges, char_class_2, next, zone());
4536 if (first.from() > next.to()) {
4541 AddRangeOrEscape(ranges, char_class, first, zone());
4548 if (ranges->length() == 0) {
4550 is_negated = !is_negated;
4552 return new(zone()) RegExpCharacterClass(ranges, is_negated);
4560 if (owns_store_) store_.
Dispose();
4565 return store_.
length() *
sizeof(unsigned);
4570 return reinterpret_cast<const char*
>(store_.
start());
4585 if (store_.length() > symbol_data_offset) {
4586 symbol_data_ =
reinterpret_cast<byte*
>(&store_[symbol_data_offset]);
4589 symbol_data_ =
reinterpret_cast<byte*
>(&store_[0] + store_.length());
4591 symbol_data_end_ =
reinterpret_cast<byte*
>(&store_[0] + store_.length());
4596 int ScriptDataImpl::ReadNumber(
byte** source) {
4603 byte* data = *source;
4604 if (data >= symbol_data_end_)
return -1;
4610 int result = input & 0x7f;
4612 while ((input & 0x80u) != 0) {
4613 if (data >= symbol_data_end_)
return -1;
4615 result = (result << 7) | (input & 0x7f);
4627 HistogramTimerScope timer(isolate->
counters()->pre_parse());
4630 PreParser preparser(&scanner, &recorder, stack_limit);
4636 scanner.Initialize(source);
4655 RegExpParser parser(input, &result->
error, multiline, zone);
4657 if (parser.failed()) {
4663 result->
tree = tree;
4664 int capture_count = parser.captures_started();
4665 result->
simple = tree->IsAtom() && parser.simple() && capture_count == 0;
4669 return !parser.failed();
4675 FunctionLiteral* result =
NULL;
4676 if (info()->is_lazy()) {
4677 ASSERT(!info()->is_eval());
4678 if (info()->shared_info()->is_function()) {
4679 result = ParseLazy();
4681 result = ParseProgram();
4684 SetCachedData(info()->cached_data(), info()->cached_data_mode());
4686 (*info()->cached_data())->has_error()) {
4693 for (
int i = 0; i < args.
length(); i++) {
4697 ASSERT(info()->isolate()->has_pending_exception());
4699 result = ParseProgram();
4702 info()->SetFunction(result);
4703 return (result !=
NULL);
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
v8::Extension * extension_
Scope * DeclarationScope()
Failure * StackOverflow()
virtual bool IsTextElement()
PreParseResult PreParseProgram()
Vector< const char * > BuildArgs()
void PushVariableName(Handle< String > name)
ExpressionT ParseExpression(bool accept_IN, bool *ok)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths true
void PrintF(const char *format,...)
bool allow_generators() const
Expression * BuildUnaryExpression(Expression *expression, Token::Value op, int pos, AstNodeFactory< AstConstructionVisitor > *factory)
static Interface * NewModule(Zone *zone)
static String * cast(Object *obj)
int GetSymbolIdentifier()
static const unsigned kMagicNumber
bool peek_any_identifier()
Local< Value > Get(Handle< Value > key)
static Expression * MarkExpressionAsLValue(Expression *expression)
static Smi * FromInt(int value)
static const Function * FunctionForName(Handle< String > name)
Vector< const T > ToConstVector()
void CheckOctalLiteral(int beg_pos, int end_pos, bool *ok)
ParserTraits::Type::Zone * zone() const
static Handle< T > cast(Handle< S > that)
void AddQuantifierToAtom(int min, int max, RegExpQuantifier::QuantifierType type)
void CheckStrictModeLValue(Expression *expression, bool *ok)
static Handle< FixedArray > GetElements(Handle< FixedArray > value)
void set_allow_modules(bool allow)
Handle< String > NextLiteralString(Scanner *scanner, PretenureFlag tenured)
static void CheckAssigningFunctionLiteralToProperty(Expression *left, Expression *right)
Expression * ExpressionFromString(int pos, Scanner *scanner, AstNodeFactory< AstConstructionVisitor > *factory)
void set_allow_harmony_numeric_literals(bool allow)
bool parenthesized_function_
Vector< T > SubVector(int from, int to)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage message
Handle< JSArray > NewJSArrayWithElements(Handle< FixedArrayBase > elements, ElementsKind elements_kind, int length, PretenureFlag pretenure=NOT_TENURED)
VariableProxy * NewUnresolved(AstNodeFactory< Visitor > *factory, Handle< String > name, Interface *interface=Interface::NewValue(), int position=RelocInfo::kNoPosition)
bool Check(Token::Value token)
void ReportUnexpectedToken(Token::Value token)
static CharacterRange Everything()
void AddAtom(RegExpTree *tree)
static const Function * FunctionForId(FunctionId id)
Scanner * scanner() const
#define ASSERT(condition)
void ForceEagerCompilation()
ExpressionT ParseAssignmentExpression(bool accept_IN, bool *ok)
static bool IsCompileTimeValue(Expression *expression)
void set_allow_natives_syntax(bool allow)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including on console Map counters to a file Enable debugger compile events enable GDBJIT interface(disables compacting GC)") DEFINE_bool(gdbjit_full
virtual MaterializedLiteral * AsMaterializedLiteral()
void Consume(Token::Value token)
void set_allow_harmony_scoping(bool allow)
ParserTraits::Type::Scope * scope_
bool allow_for_of() const
virtual ~ScriptDataImpl()
IdentifierT ParseIdentifierOrStrictReservedWord(bool *is_strict_reserved, bool *ok)
bool is_generator() const
bool Equals(Handle< Value > that) const
void ReportMessageAt(Scanner::Location source_location, const char *message, Vector< const char * > args, bool is_reference_error=false)
#define RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, value)
static Smi * cast(Object *object)
Literal * GetLiteralTheHole(int position, AstNodeFactory< AstConstructionVisitor > *factory)
StackGuard * stack_guard()
static const int kSymbolCountOffset
FunctionEntry GetFunctionEntry(int start)
bool stack_overflow() const
Literal * ExpressionFromLiteral(Token::Value token, int pos, Scanner *scanner, AstNodeFactory< AstConstructionVisitor > *factory)
static Interface * NewValue()
Handle< String > NewStringFromUtf8(Vector< const char > str, PretenureFlag pretenure=NOT_TENURED)
UnicodeCache * unicode_cache()
void AddAssertion(RegExpTree *tree)
void ReportMessageAt(Scanner::Location location, const char *message, bool is_reference_error=false)
static Interface * NewUnknown(Zone *zone)
Handle< Object > NewReferenceError(const char *message, Vector< Handle< Object > > args)
bool literal_contains_escapes() const
IdentifierT ParseIdentifierName(bool *ok)
static CharacterRange Range(uc16 from, uc16 to)
static LiteralType GetLiteralType(Handle< FixedArray > value)
static const int kInfinity
void ExpectSemicolon(bool *ok)
void RemoveLastFunction()
bool allow_harmony_scoping() const
static const int kMessageEndPos
void check(i::Vector< const uint8_t > string)
static bool IsIdentifier(Expression *expression)
void ExpectContextualKeyword(Vector< const char > keyword, bool *ok)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array shift
Handle< Object > ToBoolean(bool value)
static const int kMessageStartPos
static const int kMessageTextPos
void ReportMessage(const char *message, Vector< const char * > args, bool is_reference_error=false)
static const int kMessageArgCountPos
void SeekForward(int pos)
bool allow_harmony_numeric_literals() const
static const int kFunctionsSizeOffset
void set_allow_lazy(bool allow)
Handle< FixedArray > NewFixedArray(int size, PretenureFlag pretenure=NOT_TENURED)
bool IsLexicalVariableMode(VariableMode mode)
bool IsEvalOrArguments(Handle< String > identifier) const
static Handle< FixedArray > GetValue(Isolate *isolate, Expression *expression)
Handle< String > GetSymbol(Scanner *scanner=NULL)
TargetScope(Target **variable)
bool CheckContextualKeyword(Vector< const char > keyword)
bool BooleanValue() const
Failure * Throw(Object *exception, MessageLocation *location=NULL)
#define STATIC_ASCII_VECTOR(x)
FunctionState * function_state_
virtual bool IsPropertyName()
bool IsDeclaredVariableMode(VariableMode mode)
virtual void LogFunction(int start, int end, int literals, int properties, StrictMode strict_mode)=0
void Initialize(Utf16CharacterStream *source)
Vector< const char > CStrVector(const char *data)
static ScriptDataImpl * PreParse(Isolate *isolate, Utf16CharacterStream *source)
bool ShortcutNumericLiteralBinaryExpression(Expression **x, Expression *y, Token::Value op, int pos, AstNodeFactory< AstConstructionVisitor > *factory)
void ReportMessage(const char *message, Vector< Handle< String > > args, bool is_reference_error=false)
const char * BuildMessage()
static Location invalid()
static Interface * NewConst()
Vector< unsigned > ExtractData()
void set_stack_overflow()
V8_INLINE bool IsString() const
void PushEnclosingName(Handle< String > name)
int ArithmeticShiftRight(int x, int s)
uint32_t DoubleToUint32(double x)
bool allow_natives_syntax() const
Handle< Object > NewSyntaxError(const char *message, Handle< JSArray > args)
void PushLiteralName(Handle< String > name)
int32_t DoubleToInt32(double x)
Expression * ThisExpression(Scope *scope, AstNodeFactory< AstConstructionVisitor > *factory)
Location location() const
PreParseResult PreParseLazyFunction(StrictMode strict_mode, bool is_generator, ParserRecorder *log)
Handle< String > InternalizeOneByteString(Vector< const uint8_t > str)
void set_allow_for_of(bool allow)
static const unsigned kCurrentVersion
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
virtual const char * Data()
Target(Target **variable, AstNode *node)
static bool IsThisProperty(Expression *expression)
void set_allow_generators(bool allow)
void AddCharacter(uc16 character)
Scanner::Location MessageLocation()
void LogSymbol(ParserRecorder *log, int position)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
void Add(Handle< String > name, Interface *interface, Zone *zone, bool *ok)
static const unsigned char kNumberTerminator
static Handle< T > null()
void PushPropertyName(FuncNameInferrer *fni, Expression *expression)
#define ASSERT_EQ(v1, v2)
bool allow_modules() const
#define ASSERT_NE(v1, v2)
static FixedArray * cast(Object *obj)
Handle< String > AllocateNextLiteralString(Isolate *isolate, PretenureFlag tenured)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
static const int kMaxArguments
void AddFunction(FunctionLiteral *func_to_infer)
ZoneList< Handle< String > > ZoneStringList
Handle< String > NewConsString(Handle< String > left, Handle< String > right)
FunctionLiteral * ParseFunctionLiteral(Handle< String > name, Scanner::Location function_name_location, bool name_is_strict_reserved, bool is_generator, int function_token_position, FunctionLiteral::FunctionType type, bool *ok)
void DeleteArray(T *array)
ParserTraits::Type::ExpressionList ParseArguments(bool *ok)
virtual int max_match()=0
void Expect(Token::Value token, bool *ok)
static const int kHeaderSize
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
RegExpBuilder(Zone *zone)
Handle< String > AllocateInternalizedString(Isolate *isolate)
static Scope * DeserializeScopeChain(Context *context, Scope *global_scope, Zone *zone)
IdentifierT ParseIdentifier(AllowEvalOrArgumentsAsIdentifier, bool *ok)
static const char *const kStackOverflowMessage
Parser(CompilationInfo *info)
static void AddClassEscape(uc16 type, ZoneList< CharacterRange > *ranges, Zone *zone)
bool IsDecimalDigit(uc32 c)
Expression * ParseV8Intrinsic(bool *ok)
static CharacterRange Singleton(uc16 value)
ParserTraits::Type::Factory * factory()
Location peek_location() const
void CheckPossibleEvalCall(Expression *expression, Scope *scope)
Expression * ExpressionFromIdentifier(Handle< String > name, int pos, Scope *scope, AstNodeFactory< AstConstructionVisitor > *factory)