28 pending_empty_(
false),
33 , last_added_(ADD_NONE)
51 int num_text =
text_.length();
54 }
else if (num_text == 1) {
57 RegExpText* text =
new(
zone()) RegExpText(
zone());
58 for (
int i = 0;
i < num_text;
i++)
82 if (term->IsEmpty()) {
111 int num_terms =
terms_.length();
113 if (num_terms == 0) {
114 alternative = RegExpEmpty::GetInstance();
115 }
else if (num_terms == 1) {
116 alternative =
terms_.last();
118 alternative =
new(
zone()) RegExpAlternative(
terms_.GetList(
zone()));
129 if (num_alternatives == 0) {
130 return RegExpEmpty::GetInstance();
132 if (num_alternatives == 1) {
140 int min,
int max, RegExpQuantifier::QuantifierType quantifier_type) {
147 DCHECK(last_added_ == ADD_CHAR);
150 int num_chars = char_vector.
length();
154 char_vector = char_vector.
SubVector(num_chars - 1, num_chars);
157 atom =
new(
zone()) RegExpAtom(char_vector);
159 }
else if (
text_.length() > 0) {
160 DCHECK(last_added_ == ADD_ATOM);
161 atom =
text_.RemoveLast();
163 }
else if (
terms_.length() > 0) {
164 DCHECK(last_added_ == ADD_ATOM);
165 atom =
terms_.RemoveLast();
181 new(
zone()) RegExpQuantifier(
min, max, quantifier_type, atom),
zone());
194 return FunctionEntry(subvector);
196 return FunctionEntry();
202 if (functions_size < 0)
return 0;
203 if (functions_size % FunctionEntry::kSize != 0)
return 0;
204 return functions_size / FunctionEntry::kSize;
211 int data_length =
Length();
218 if (functions_size < 0)
return false;
219 if (functions_size % FunctionEntry::kSize != 0)
return false;
223 if (data_length < minimum_size)
return false;
230 int data_length =
Length();
287 : variable_(variable), node_(node), previous_(*variable) {
292 *variable_ = previous_;
308 : variable_(variable), previous_(*variable) {
313 *variable_ = previous_;
330 #define CHECK_OK ok); \
331 if (!*ok) return NULL; \
336 #define CHECK_FAILED ); \
337 if (failed_) return NULL; \
346 :
public ParserBase<ParserTraits>::CheckpointBase {
349 : CheckpointBase(parser),
parser_(parser) {
354 CheckpointBase::Restore();
382 Property*
property = expression->AsProperty();
383 return property !=
NULL &&
384 property->obj()->AsVariableProxy() !=
NULL &&
385 property->obj()->AsVariableProxy()->is_this();
390 VariableProxy* operand = expression->AsVariableProxy();
391 return operand !=
NULL && !operand->is_this();
409 if (left->AsProperty() !=
NULL &&
410 right->AsFunctionLiteral() !=
NULL) {
411 right->AsFunctionLiteral()->set_pretenure();
418 VariableProxy* callee = expression->AsVariableProxy();
419 if (callee !=
NULL &&
427 VariableProxy* proxy =
428 expression !=
NULL ? expression->AsVariableProxy() :
NULL;
429 if (proxy !=
NULL) proxy->set_is_assigned();
437 if ((*x)->AsLiteral() && (*x)->AsLiteral()->raw_value()->IsNumber() &&
438 y->AsLiteral() &&
y->AsLiteral()->raw_value()->IsNumber()) {
439 double x_val = (*x)->AsLiteral()->raw_value()->AsNumber();
440 double y_val =
y->AsLiteral()->raw_value()->AsNumber();
443 *x = factory->NewNumberLiteral(x_val + y_val, pos);
446 *x = factory->NewNumberLiteral(x_val - y_val, pos);
449 *x = factory->NewNumberLiteral(x_val * y_val, pos);
452 *x = factory->NewNumberLiteral(x_val / y_val, pos);
454 case Token::BIT_OR: {
456 *x = factory->NewNumberLiteral(value, pos);
459 case Token::BIT_AND: {
461 *x = factory->NewNumberLiteral(value, pos);
464 case Token::BIT_XOR: {
466 *x = factory->NewNumberLiteral(value, pos);
471 *x = factory->NewNumberLiteral(value, pos);
477 *x = factory->NewNumberLiteral(value, pos);
483 *x = factory->NewNumberLiteral(value, pos);
498 if (expression->IsLiteral()) {
499 const AstValue* literal = expression->AsLiteral()->raw_value();
503 return factory->NewBooleanLiteral(!condition, pos);
511 return factory->NewNumberLiteral(-value, pos);
513 return factory->NewNumberLiteral(~
DoubleToInt32(value), pos);
521 return factory->NewBinaryOperation(
522 Token::MUL, expression, factory->NewNumberLiteral(1, pos), pos);
526 return factory->NewBinaryOperation(
527 Token::MUL, expression, factory->NewNumberLiteral(-1, pos), pos);
530 if (op == Token::BIT_NOT) {
531 return factory->NewBinaryOperation(
532 Token::BIT_XOR, expression, factory->NewNumberLiteral(~0, pos), pos);
534 return factory->NewUnaryOperation(op, expression, pos);
546 const char* message,
const AstRawString* arg,
int pos) {
553 const char* message,
const AstRawString* arg,
int pos) {
563 int argc = arg !=
NULL ? 1 : 0;
569 array->
Add(arg, zone);
574 CallRuntime* call_constructor =
583 bool is_reference_error) {
601 bool is_reference_error) {
609 bool is_reference_error) {
618 bool is_reference_error) {
658 return factory->NewVariableProxy(scope->
receiver(), pos);
663 return factory->NewSuperReference(
672 return factory->NewClassLiteral(
name, extends, constructor, properties, pos);
680 case Token::NULL_LITERAL:
681 return factory->NewNullLiteral(pos);
682 case Token::TRUE_LITERAL:
683 return factory->NewBooleanLiteral(
true, pos);
684 case Token::FALSE_LITERAL:
685 return factory->NewBooleanLiteral(
false, pos);
686 case Token::NUMBER: {
688 return factory->NewNumberLiteral(value, pos);
703 if (FLAG_print_interface_details)
716 return factory->NewStringLiteral(symbol, pos);
726 factory->NewProperty(iterable, iterator_symbol_literal, pos);
729 return factory->NewCall(prop, args, pos);
748 FunctionLiteral::ArityRestriction arity_restriction,
bool* ok) {
750 name, function_name_location, name_is_strict_reserved, kind,
757 info->extension(),
NULL, info->zone(),
758 info->ast_node_id_gen(), this),
759 scanner_(parse_info->unicode_cache),
760 reusable_preparser_(
NULL),
761 original_scope_(
NULL),
763 cached_parse_data_(
NULL),
765 has_pending_error_(
false),
766 pending_error_message_(
NULL),
767 pending_error_arg_(
NULL),
768 pending_error_char_arg_(
NULL),
769 total_preparse_skipped_(0),
770 pre_parse_timer_(
NULL) {
798 HistogramTimerScope timer_scope(
isolate()->counters()->parse(),
true);
800 isolate()->
counters()->total_parse_size()->Increment(source->length());
801 base::ElapsedTimer timer;
802 if (FLAG_trace_parse) {
817 FunctionLiteral* result;
821 if (source->IsExternalTwoByteString()) {
835 if (eval_scope !=
NULL) {
840 if (FLAG_trace_parse && result !=
NULL) {
841 double ms = timer.Elapsed().InMillisecondsF();
842 if (
info()->is_eval()) {
847 PrintF(
"[parsing script: %s", name_chars.
get());
849 PrintF(
"[parsing script");
851 PrintF(
" - took %0.3f ms]\n", ms);
862 Scope** eval_scope) {
866 FunctionLiteral* result =
NULL;
886 (*scope)->set_start_position(0);
892 (*scope)->is_eval_scope()) {
895 ParsingModeScope parsing_mode(
this,
mode);
917 if (body->length() != 1 ||
918 !body->
at(0)->IsExpressionStatement() ||
919 !body->
at(0)->AsExpressionStatement()->
920 expression()->IsFunctionLiteral()) {
927 result =
factory()->NewFunctionLiteral(
929 body, function_state.materialized_literal_count(),
930 function_state.expected_property_count(),
931 function_state.handler_count(), 0,
932 FunctionLiteral::kNoDuplicateParameters,
933 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kGlobalOrEval,
935 result->set_ast_properties(
factory()->visitor()->ast_properties());
936 result->set_dont_optimize_reason(
937 factory()->visitor()->dont_optimize_reason());
951 HistogramTimerScope timer_scope(
isolate()->counters()->parse_lazy());
953 isolate()->
counters()->total_parse_size()->Increment(source->length());
954 base::ElapsedTimer timer;
955 if (FLAG_trace_parse) {
962 FunctionLiteral* result;
963 if (source->IsExternalTwoByteString()) {
966 shared_info->start_position(),
967 shared_info->end_position());
971 shared_info->start_position(),
972 shared_info->end_position());
976 if (FLAG_trace_parse && result !=
NULL) {
977 double ms = timer.Elapsed().InMillisecondsF();
979 PrintF(
"[parsing function: %s - took %0.3f ms]\n", name_chars.
get(), ms);
1000 FunctionLiteral* result =
NULL;
1006 if (!
info()->closure().is_null()) {
1017 FunctionLiteral::FunctionType function_type = shared_info->is_expression()
1018 ? (shared_info->is_anonymous()
1019 ? FunctionLiteral::ANONYMOUS_EXPRESSION
1020 : FunctionLiteral::NAMED_EXPRESSION)
1021 : FunctionLiteral::DECLARATION;
1024 if (shared_info->is_arrow()) {
1026 DCHECK(expression->IsFunctionLiteral());
1027 result = expression->AsFunctionLiteral();
1033 FunctionLiteral::NORMAL_ARITY, &ok);
1042 if (result !=
NULL) {
1044 result->set_inferred_name(inferred_name);
1051 int end_token,
bool is_eval,
bool is_global,
1052 Scope** eval_scope,
bool* ok) {
1063 bool directive_prologue =
true;
1065 while (peek() != end_token) {
1067 directive_prologue =
false;
1072 if (is_global && !is_eval) {
1078 directive_prologue =
false;
1082 if (directive_prologue) {
1084 ExpressionStatement* e_stat;
1087 if ((e_stat = stat->AsExpressionStatement()) !=
NULL &&
1088 (literal = e_stat->expression()->AsLiteral()) !=
NULL &&
1089 literal->raw_value()->IsString()) {
1093 literal->raw_value()->AsString() ==
1102 if (is_eval && !
scope_->is_eval_scope()) {
1108 if (eval_scope !=
NULL) {
1110 *eval_scope = scope;
1116 directive_prologue =
false;
1117 }
else if (literal->raw_value()->AsString() ==
1128 directive_prologue =
false;
1156 case Token::FUNCTION:
1175 if (FLAG_harmony_modules &&
1176 peek() == Token::IDENTIFIER &&
1177 !
scanner()->HasAnyLineTerminatorBeforeNext() &&
1179 ExpressionStatement* estmt = stmt->AsExpressionStatement();
1180 if (estmt !=
NULL && estmt->expression()->AsVariableProxy() !=
NULL &&
1181 estmt->expression()->AsVariableProxy()->raw_name() ==
1183 !
scanner()->literal_contains_escapes()) {
1203 if (FLAG_print_interface_details)
1210 factory()->NewModuleDeclaration(proxy, module,
scope_, pos);
1214 if (FLAG_print_interface_details)
1216 if (FLAG_print_interfaces) {
1224 return factory()->NewEmptyStatement(pos);
1226 return factory()->NewModuleStatement(proxy, module->
body(), pos);
1240 case Token::ASSIGN: {
1265 if (FLAG_print_interface_details)
PrintF(
"# Literal ");
1274 BlockState block_state(&
scope_, scope);
1275 TargetCollector collector(
zone());
1279 while (peek() != Token::RBRACE) {
1281 if (stat && !stat->
IsEmpty()) {
1282 body->AddStatement(stat,
zone());
1289 body->set_scope(scope);
1292 Interface*
interface = scope->interface();
1294 !it.
done(); it.Advance()) {
1302 interface->MakeModule(ok);
1304 interface->Freeze(ok);
1306 return factory()->NewModuleLiteral(body, interface, pos);
1317 while (
Check(Token::PERIOD)) {
1320 if (FLAG_print_interface_details)
1327 if (FLAG_print_interfaces) {
1328 PrintF(
"PATH TYPE ERROR at '%.*s'\n",
name->length(),
name->raw_data());
1353 if (FLAG_print_interface_details)
1354 PrintF(
"# Module variable %.*s ",
name->length(),
name->raw_data());
1356 VariableProxy* proxy =
scope_->NewUnresolved(
1358 scanner()->location().beg_pos);
1360 return factory()->NewModuleVariable(proxy, pos);
1375 if (FLAG_print_interface_details)
PrintF(
"# Url ");
1382 body->set_scope(scope);
1383 Interface*
interface = scope->interface();
1384 Module* result =
factory()->NewModuleLiteral(body, interface, pos);
1385 interface->Freeze(ok);
1431 for (
int i = 0;
i < names.length(); ++
i) {
1433 if (FLAG_print_interface_details)
1440 if (FLAG_print_interfaces) {
1441 PrintF(
"IMPORT TYPE ERROR at '%.*s'\n",
name->length(),
1452 factory()->NewImportDeclaration(proxy, module,
scope_, pos);
1475 case Token::IDENTIFIER: {
1488 result =
factory()->NewEmptyStatement(pos);
1495 case Token::FUNCTION:
1516 for (
int i = 0;
i < names.length(); ++
i) {
1530 for (
int i = 0;
i < names.length(); ++
i) {
1532 if (FLAG_print_interface_details)
1533 PrintF(
"# Export %.*s ", names[
i]->length(), names[
i]->raw_data());
1568 case Token::FUNCTION:
1615 case Token::SEMICOLON:
1631 case Token::CONTINUE:
1659 if (result) result->AddStatement(statement,
zone());
1663 case Token::FUNCTION: {
1686 case Token::DEBUGGER:
1718 VariableProxy* proxy = declaration->
proxy();
1816 proxy->interface());
1845 if (resolve && var !=
NULL) {
1848 if (FLAG_harmony_modules) {
1851 if (FLAG_print_interface_details) {
1859 if (FLAG_print_interfaces) {
1860 PrintF(
"DECLARE TYPE ERROR\n");
1862 proxy->interface()->Print();
1884 bool done = (peek() == Token::RPAREN);
1887 done = (peek() == Token::RPAREN);
1908 NativeFunctionLiteral* lit =
factory()->NewNativeFunctionLiteral(
1910 return factory()->NewExpressionStatement(
1927 bool is_strict_reserved =
false;
1930 FunctionLiteral* fun =
1934 pos, FunctionLiteral::DECLARATION,
1935 FunctionLiteral::NORMAL_ARITY,
CHECK_OK);
1943 !(
scope_->is_global_scope() ||
scope_->is_eval_scope() ||
1971 bool is_strict_reserved =
false;
1975 is_strict_reserved, pos,
CHECK_OK);
1977 Block* block =
factory()->NewBlock(
NULL, 1,
true, pos);
1985 Assignment* assignment =
factory()->NewAssignment(init_op, proxy, value, pos);
1986 block->AddStatement(
2011 while (peek() != Token::RBRACE) {
2013 if (stat && !stat->
IsEmpty()) {
2014 result->AddStatement(stat,
zone());
2037 { BlockState block_state(&
scope_, block_scope);
2038 TargetCollector collector(
zone());
2042 while (peek() != Token::RBRACE) {
2044 if (stat && !stat->
IsEmpty()) {
2045 body->AddStatement(stat,
zone());
2052 body->set_scope(block_scope);
2102 bool needs_init =
false;
2103 bool is_const =
false;
2122 init_op = Token::INIT_CONST_LEGACY;
2134 init_op = Token::INIT_CONST;
2154 init_op = Token::INIT_LET;
2174 Block* block =
factory()->NewBlock(
NULL, 1,
true, pos);
2202 VariableProxy* proxy =
NewUnresolved(name, mode, interface);
2204 factory()->NewVariableDeclaration(proxy, mode, scope_, pos);
2205 Declare(declaration, mode != VAR, CHECK_OK);
2241 Scope* initialization_scope = is_const ? declaration_scope :
scope_;
2245 if (peek() == Token::ASSIGN ||
mode ==
CONST) {
2251 value->AsCall() ==
NULL &&
2252 value->AsCallNew() ==
NULL) {
2261 if (proxy->var() !=
NULL) {
2262 proxy->var()->set_initializer_position(
position());
2266 if (value ==
NULL && needs_init) {
2295 CallRuntime* initialize;
2298 arguments->
Add(value,
zone());
2305 initialize =
factory()->NewCallRuntime(
2320 arguments->
Add(value,
zone());
2324 initialize =
factory()->NewCallRuntime(
2333 if (initialize !=
NULL) {
2334 block->AddStatement(
factory()->NewExpressionStatement(
2338 }
else if (needs_init) {
2349 Assignment* assignment =
2350 factory()->NewAssignment(init_op, proxy, value, pos);
2351 block->AddStatement(
2359 if (value !=
NULL) {
2364 VariableProxy* proxy =
2366 Assignment* assignment =
2367 factory()->NewAssignment(init_op, proxy, value, pos);
2368 block->AddStatement(
2378 if (nvars == 1 && !is_const) {
2389 if (labels !=
NULL) {
2390 for (
int i = labels->length();
i-- > 0; ) {
2391 if (labels->
at(
i) == label) {
2408 if (peek() == Token::COLON && starts_with_idenfifier && expr !=
NULL &&
2409 expr->AsVariableProxy() !=
NULL &&
2410 !expr->AsVariableProxy()->is_this()) {
2413 VariableProxy* var = expr->AsVariableProxy();
2425 if (labels ==
NULL) {
2432 scope_->RemoveUnresolved(var);
2441 !
scanner()->HasAnyLineTerminatorBeforeNext() && expr !=
NULL &&
2442 expr->AsVariableProxy() !=
NULL &&
2443 expr->AsVariableProxy()->raw_name() ==
2445 !
scanner()->literal_contains_escapes()) {
2451 if (!FLAG_harmony_modules || peek() != Token::IDENTIFIER ||
2452 scanner()->HasAnyLineTerminatorBeforeNext() ||
2453 expr->AsVariableProxy() ==
NULL ||
2454 expr->AsVariableProxy()->raw_name() !=
2456 scanner()->literal_contains_escapes()) {
2459 return factory()->NewExpressionStatement(expr, pos);
2475 if (peek() == Token::ELSE) {
2481 return factory()->NewIfStatement(
2482 condition, then_statement, else_statement, pos);
2494 if (!
scanner()->HasAnyLineTerminatorBeforeNext() &&
2495 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) {
2500 if (target ==
NULL) {
2502 const char* message =
"illegal_continue";
2503 if (label !=
NULL) {
2504 message =
"unknown_label";
2511 return factory()->NewContinueStatement(target, pos);
2524 if (!
scanner()->HasAnyLineTerminatorBeforeNext() &&
2525 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) {
2533 return factory()->NewEmptyStatement(pos);
2537 if (target ==
NULL) {
2539 const char* message =
"illegal_break";
2540 if (label !=
NULL) {
2541 message =
"unknown_label";
2548 return factory()->NewBreakStatement(target, pos);
2565 if (
scanner()->HasAnyLineTerminatorBeforeNext() ||
2566 tok == Token::SEMICOLON ||
2567 tok == Token::RBRACE ||
2568 tok == Token::EOS) {
2578 generator, return_value, Yield::kFinal, loc.
beg_pos);
2581 result =
factory()->NewReturnStatement(return_value, loc.
beg_pos);
2612 scope_->DeclarationScope()->RecordWithStatement();
2615 { BlockState block_state(&
scope_, with_scope);
2620 return factory()->NewWithStatement(with_scope, expr, stmt, pos);
2635 if (*default_seen_ptr) {
2640 *default_seen_ptr =
true;
2648 peek() != Token::RBRACE) {
2650 statements->
Add(stat,
zone());
2653 return factory()->NewCaseClause(label, statements, pos);
2662 SwitchStatement* statement =
2671 bool default_seen =
false;
2674 while (peek() != Token::RBRACE) {
2680 if (statement) statement->Initialize(tag, cases);
2691 if (
scanner()->HasAnyLineTerminatorBeforeNext()) {
2699 return factory()->NewExpressionStatement(
2700 factory()->NewThrow(exception, pos), pos);
2719 TargetCollector try_collector(
zone());
2727 if (tok != Token::CATCH && tok != Token::FINALLY) {
2737 TargetCollector catch_collector(
zone());
2740 Block* catch_block =
NULL;
2742 if (tok == Token::CATCH) {
2756 BlockState block_state(&
scope_, catch_scope);
2763 Block* finally_block =
NULL;
2764 DCHECK(tok == Token::FINALLY || catch_block !=
NULL);
2765 if (tok == Token::FINALLY) {
2775 if (catch_block !=
NULL && finally_block !=
NULL) {
2779 TryCatchStatement* statement =
factory()->NewTryCatchStatement(
2780 index, try_block, catch_scope, catch_variable, catch_block,
2782 statement->set_escaping_targets(try_collector.targets());
2784 try_block->AddStatement(statement,
zone());
2789 if (catch_block !=
NULL) {
2793 result =
factory()->NewTryCatchStatement(
2794 index, try_block, catch_scope, catch_variable, catch_block, pos);
2798 result =
factory()->NewTryFinallyStatement(
2799 index, try_block, finally_block, pos);
2801 try_collector.targets()->AddAll(*catch_collector.targets(),
zone());
2814 DoWhileStatement* loop =
2830 if (peek() == Token::SEMICOLON)
Consume(Token::SEMICOLON);
2832 if (loop !=
NULL) loop->Initialize(cond, body);
2851 if (loop !=
NULL) loop->Initialize(cond, body);
2873 ForOfStatement* for_of = stmt->AsForOfStatement();
2875 if (for_of !=
NULL) {
2887 assign_iterator =
factory()->NewAssignment(
2888 Token::ASSIGN,
factory()->NewVariableProxy(iterator),
2903 next_result =
factory()->NewAssignment(
2912 result_done =
factory()->NewProperty(
2923 assign_each =
factory()->NewAssignment(
2927 for_of->Initialize(each, subject, body,
2974 DCHECK(names->length() > 0);
2978 Block* outer_block =
factory()->NewBlock(
NULL, names->length() + 3,
false,
2980 outer_block->AddStatement(init,
zone());
2986 for (
int i = 0;
i < names->length();
i++) {
2987 VariableProxy* proxy =
2989 Variable* temp =
scope_->DeclarationScope()->NewTemporary(temp_name);
2990 VariableProxy* temp_proxy =
factory()->NewVariableProxy(temp);
2991 Assignment* assignment =
factory()->NewAssignment(
2995 outer_block->AddStatement(assignment_statement,
zone());
3002 VariableProxy* flag_proxy =
factory()->NewVariableProxy(
flag);
3004 Assignment* assignment =
factory()->NewAssignment(
3008 outer_block->AddStatement(assignment_statement,
zone());
3011 outer_block->AddStatement(loop,
zone());
3012 outer_block->set_scope(for_scope);
3015 Block* inner_block =
factory()->NewBlock(
NULL, 2 * names->length() + 3,
3022 for (
int i = 0;
i < names->length();
i++) {
3023 VariableProxy* proxy =
3029 VariableProxy* temp_proxy =
factory()->NewVariableProxy(temps.
at(
i));
3030 Assignment* assignment =
factory()->NewAssignment(
3031 Token::INIT_LET, proxy, temp_proxy, pos);
3034 proxy->var()->set_initializer_position(pos);
3035 inner_block->AddStatement(assignment_statement,
zone());
3044 VariableProxy* flag_proxy =
factory()->NewVariableProxy(
flag);
3045 compare =
factory()->NewCompareOperation(
3051 VariableProxy* flag_proxy =
factory()->NewVariableProxy(
flag);
3053 Assignment* assignment =
factory()->NewAssignment(
3055 clear_flag =
factory()->NewExpressionStatement(assignment, pos);
3059 inner_block->AddStatement(clear_flag_or_next,
zone());
3069 cond, empty, stop, cond->
position());
3070 inner_block->AddStatement(if_not_cond_break,
zone());
3073 inner_block->AddStatement(body,
zone());
3077 for (
int i = 0;
i < names->length();
i++) {
3078 VariableProxy* temp_proxy =
factory()->NewVariableProxy(temps.
at(
i));
3080 VariableProxy* proxy =
factory()->NewVariableProxy(inner_vars.
at(
i), pos);
3081 Assignment* assignment =
factory()->NewAssignment(
3085 inner_block->AddStatement(assignment_statement,
zone());
3089 inner_block->set_scope(inner_scope);
3114 if (peek() != Token::SEMICOLON) {
3119 Block* variable_statement =
3129 factory()->NewForEachStatement(mode, labels, pos);
3133 Expect(Token::RPAREN, CHECK_OK);
3135 VariableProxy* each =
3140 factory()->NewBlock(NULL, 2, false, RelocInfo::kNoPosition);
3141 result->AddStatement(variable_statement, zone());
3142 result->AddStatement(loop, zone());
3144 for_scope->set_end_position(scanner()->location().end_pos);
3145 for_scope = for_scope->FinalizeBlockScope();
3146 DCHECK(for_scope == NULL);
3150 init = variable_statement;
3156 Block* variable_statement =
3181 VariableProxy* temp_proxy =
factory()->NewVariableProxy(temp);
3183 factory()->NewForEachStatement(
mode, labels, pos);
3192 VariableProxy* each =
3197 Assignment* assignment =
factory()->NewAssignment(
3201 body_block->AddStatement(variable_statement,
zone());
3202 body_block->AddStatement(assignment_statement,
zone());
3203 body_block->AddStatement(body,
zone());
3208 body_block->set_scope(for_scope);
3213 init = variable_statement;
3219 bool accept_OF = expression->AsVariableProxy();
3223 expression, lhs_location,
"invalid_lhs_in_for",
CHECK_OK);
3226 factory()->NewForEachStatement(
mode, labels, pos);
3242 init =
factory()->NewExpressionStatement(
3249 ForStatement* loop =
factory()->NewForStatement(labels, pos);
3258 if (let_bindings.length() > 0) {
3265 if (peek() != Token::SEMICOLON) {
3271 if (peek() != Token::RPAREN) {
3280 if (let_bindings.length() > 0) {
3303 block->AddStatement(init,
zone());
3304 block->AddStatement(loop,
zone());
3305 block->set_scope(for_scope);
3306 loop->Initialize(
NULL, cond, next, body);
3309 loop->Initialize(init, cond, next, body);
3327 return factory()->NewDebuggerStatement(pos);
3332 if (expression->IsLiteral())
return true;
3341 DCHECK(IsCompileTimeValue(expression));
3343 ObjectLiteral* object_literal = expression->AsObjectLiteral();
3344 if (object_literal !=
NULL) {
3345 DCHECK(object_literal->is_simple());
3346 if (object_literal->fast_elements()) {
3347 result->set(kLiteralTypeSlot,
Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS));
3349 result->set(kLiteralTypeSlot,
Smi::FromInt(OBJECT_LITERAL_SLOW_ELEMENTS));
3351 result->set(kElementsSlot, *object_literal->constant_properties());
3353 ArrayLiteral* array_literal = expression->AsArrayLiteral();
3354 DCHECK(array_literal !=
NULL && array_literal->is_simple());
3355 result->set(kLiteralTypeSlot,
Smi::FromInt(ARRAY_LITERAL));
3356 result->set(kElementsSlot, *array_literal->constant_elements());
3364 Smi* literal_type = Smi::cast(value->get(kLiteralTypeSlot));
3375 Scope* scope,
int* num_params,
3379 if (expression ==
NULL)
return true;
3388 if (expression->IsVariableProxy()) {
3389 if (expression->AsVariableProxy()->is_this())
return false;
3391 const AstRawString* raw_name = expression->AsVariableProxy()->raw_name();
3409 if (expression->IsBinaryOperation()) {
3410 BinaryOperation* binop = expression->AsBinaryOperation();
3411 if (binop->op() !=
Token::COMMA || binop->left()->is_parenthesized() ||
3412 binop->right()->is_parenthesized())
3416 num_params, dupe_loc) &&
3418 num_params, dupe_loc);
3438 bool name_is_strict_reserved,
FunctionKind kind,
int function_token_pos,
3439 FunctionLiteral::FunctionType function_type,
3440 FunctionLiteral::ArityRestriction arity_restriction,
bool* ok) {
3458 bool should_infer_name = function_name ==
NULL;
3461 if (should_infer_name) {
3465 int num_parameters = 0;
3493 Scope* declaration_scope =
scope_->DeclarationScope();
3496 function_type == FunctionLiteral::DECLARATION &&
3499 declaration_scope != original_declaration_scope)
3503 int materialized_literal_count = -1;
3504 int expected_property_count = -1;
3505 int handler_count = 0;
3506 FunctionLiteral::ParameterFlag duplicate_parameters =
3507 FunctionLiteral::kNoDuplicateParameters;
3509 ? FunctionLiteral::kIsParenthesized
3510 : FunctionLiteral::kNotParenthesized;
3511 AstProperties ast_properties;
3518 scope_->SetScopeName(function_name);
3524 scope_->ForceContextAllocation();
3531 function_state.set_generator_object_variable(temp);
3546 bool done = arity_restriction == FunctionLiteral::GETTER_ARITY ||
3547 (peek() == Token::RPAREN &&
3548 arity_restriction != FunctionLiteral::SETTER_ARITY);
3550 bool is_strict_reserved =
false;
3558 if (!reserved_loc.
IsValid() && is_strict_reserved) {
3561 if (!dupe_error_loc.
IsValid() &&
scope_->IsDeclared(param_name)) {
3562 duplicate_parameters = FunctionLiteral::kHasDuplicateParameters;
3580 if (arity_restriction == FunctionLiteral::SETTER_ARITY)
break;
3581 done = (peek() == Token::RPAREN);
3596 if (function_type == FunctionLiteral::NAMED_EXPRESSION) {
3598 fvar_init_op = Token::INIT_CONST;
3608 VariableProxy* proxy =
factory()->NewVariableProxy(fvar);
3609 VariableDeclaration* fvar_declaration =
factory()->NewVariableDeclaration(
3611 scope_->DeclareFunctionVar(fvar_declaration);
3648 scope_->AllowsLazyCompilation() &&
3652 if (is_lazily_parsed) {
3654 &expected_property_count,
CHECK_OK);
3658 materialized_literal_count = function_state.materialized_literal_count();
3659 expected_property_count = function_state.expected_property_count();
3660 handler_count = function_state.handler_count();
3667 name_is_strict_reserved,
3668 function_name_location,
3669 eval_args_error_log,
3679 ast_properties = *
factory()->visitor()->ast_properties();
3680 dont_optimize_reason =
factory()->visitor()->dont_optimize_reason();
3687 FunctionLiteral* function_literal =
factory()->NewFunctionLiteral(
3689 materialized_literal_count, expected_property_count, handler_count,
3690 num_parameters, duplicate_parameters, function_type,
3691 FunctionLiteral::kIsFunction, parenthesized, kind, pos);
3692 function_literal->set_function_token_position(function_token_pos);
3693 function_literal->set_ast_properties(&ast_properties);
3694 function_literal->set_dont_optimize_reason(dont_optimize_reason);
3697 return function_literal;
3702 int* materialized_literal_count,
3703 int* expected_property_count,
3705 int function_block_pos =
position();
3709 FunctionEntry entry =
3712 CHECK(entry.is_valid());
3714 CHECK(entry.end_pos() > function_block_pos);
3717 scope_->set_end_position(entry.end_pos());
3718 Expect(Token::RBRACE, ok);
3723 *materialized_literal_count = entry.literal_count();
3724 *expected_property_count = entry.property_count();
3725 scope_->SetStrictMode(entry.strict_mode());
3746 Expect(Token::RBRACE, ok);
3751 *materialized_literal_count = logger.
literals();
3752 *expected_property_count = logger.
properties();
3759 *materialized_literal_count,
3760 *expected_property_count,
3775 VariableProxy* fproxy =
scope_->NewUnresolved(
3777 fproxy->BindTo(fvar);
3779 factory()->NewAssignment(fvar_init_op,
3781 factory()->NewThisFunction(pos),
3790 CallRuntime* allocation =
factory()->NewCallRuntime(
3794 VariableProxy* init_proxy =
factory()->NewVariableProxy(
3796 Assignment* assignment =
factory()->NewAssignment(
3798 VariableProxy* get_proxy =
factory()->NewVariableProxy(
3800 Yield* yield =
factory()->NewYield(
3809 VariableProxy* get_proxy =
factory()->NewVariableProxy(
3813 Yield* yield =
factory()->NewYield(get_proxy, undefined, Yield::kFinal,
3872 scope_->DeclarationScope()->ForceEagerCompilation();
3878 if (
function !=
NULL &&
3880 function->function_id == Runtime::kIS_VAR) {
3884 if (args->length() == 1 && args->
at(0)->AsVariableProxy() !=
NULL) {
3894 if (
function !=
NULL &&
3895 function->nargs != -1 &&
3896 function->nargs != args->length()) {
3903 if (
function ==
NULL &&
name->FirstCharacter() ==
'_') {
3910 return factory()->NewCallRuntime(
name,
function, args, pos);
3951 bool anonymous = label ==
NULL;
3954 if (stat ==
NULL)
continue;
3967 bool anonymous = label ==
NULL;
3970 if (stat ==
NULL)
continue;
3986 for (Target* t =
target_stack_; t != stop; t = t->previous()) {
3987 TargetCollector* collector = t->node()->AsTargetCollector();
3988 if (collector !=
NULL) collector->AddTarget(target,
zone());
4001 info_->
script()->set_source_mapping_url(*source_mapping_url);
4017 elements->set(0, *arg_string);
4022 elements->set(0, *arg_string);
4032 if (maybe_error.ToHandle(&error))
isolate()->
Throw(*error, &location);
4075 current_(kEndMarker),
4079 multiline_(multiline),
4081 contains_anchor_(
false),
4082 is_scanned_for_captures_(
false),
4088 uc32 RegExpParser::Next() {
4090 return in()->Get(next_pos_);
4097 void RegExpParser::Advance() {
4098 if (next_pos_ < in()->length()) {
4099 StackLimitCheck check(isolate());
4100 if (check.HasOverflowed()) {
4102 }
else if (zone()->excess_allocation()) {
4103 ReportError(
CStrVector(
"Regular expression too large"));
4105 current_ = in()->Get(next_pos_);
4109 current_ = kEndMarker;
4115 void RegExpParser::Reset(
int pos) {
4117 has_more_ = (pos < in()->length());
4122 void RegExpParser::Advance(
int dist) {
4123 next_pos_ += dist - 1;
4128 bool RegExpParser::simple() {
4133 RegExpTree* RegExpParser::ReportError(Vector<const char> message) {
4135 *error_ = isolate()->factory()->NewStringFromAscii(message).ToHandleChecked();
4137 current_ = kEndMarker;
4138 next_pos_ = in()->length();
4145 RegExpTree* RegExpParser::ParsePattern() {
4150 if (result->IsAtom() && result->AsAtom()->length() == in()->length()) {
4167 RegExpTree* RegExpParser::ParseDisjunction() {
4169 RegExpParserState initial_state(
NULL, INITIAL, 0, zone());
4170 RegExpParserState* stored_state = &initial_state;
4172 RegExpBuilder* builder = initial_state.builder();
4174 switch (current()) {
4176 if (stored_state->IsSubexpression()) {
4180 DCHECK_EQ(INITIAL, stored_state->group_type());
4182 return builder->ToRegExp();
4184 if (!stored_state->IsSubexpression()) {
4187 DCHECK_NE(INITIAL, stored_state->group_type());
4192 RegExpTree* body = builder->ToRegExp();
4194 int end_capture_index = captures_started();
4196 int capture_index = stored_state->capture_index();
4197 SubexpressionType group_type = stored_state->group_type();
4200 stored_state = stored_state->previous_state();
4201 builder = stored_state->builder();
4204 if (group_type == CAPTURE) {
4205 RegExpCapture* capture =
new(zone()) RegExpCapture(body, capture_index);
4206 captures_->at(capture_index - 1) = capture;
4208 }
else if (group_type != GROUPING) {
4209 DCHECK(group_type == POSITIVE_LOOKAHEAD ||
4210 group_type == NEGATIVE_LOOKAHEAD);
4211 bool is_positive = (group_type == POSITIVE_LOOKAHEAD);
4212 body =
new(zone()) RegExpLookahead(body,
4214 end_capture_index - capture_index,
4217 builder->AddAtom(body);
4224 builder->NewAlternative();
4230 return ReportError(
CStrVector(
"Nothing to repeat"));
4234 builder->AddAssertion(
4235 new(zone()) RegExpAssertion(RegExpAssertion::START_OF_LINE));
4237 builder->AddAssertion(
4238 new(zone()) RegExpAssertion(RegExpAssertion::START_OF_INPUT));
4239 set_contains_anchor();
4245 RegExpAssertion::AssertionType assertion_type =
4246 multiline_ ? RegExpAssertion::END_OF_LINE :
4247 RegExpAssertion::END_OF_INPUT;
4248 builder->AddAssertion(
new(zone()) RegExpAssertion(assertion_type));
4254 ZoneList<CharacterRange>* ranges =
4255 new(zone()) ZoneList<CharacterRange>(2, zone());
4257 RegExpTree* atom =
new(zone()) RegExpCharacterClass(ranges,
false);
4258 builder->AddAtom(atom);
4262 SubexpressionType subexpr_type = CAPTURE;
4264 if (current() ==
'?') {
4267 subexpr_type = GROUPING;
4270 subexpr_type = POSITIVE_LOOKAHEAD;
4273 subexpr_type = NEGATIVE_LOOKAHEAD;
4281 if (captures_ ==
NULL) {
4282 captures_ =
new(zone()) ZoneList<RegExpCapture*>(2, zone());
4284 if (captures_started() >= kMaxCaptures) {
4287 captures_->Add(
NULL, zone());
4290 stored_state =
new(zone()) RegExpParserState(stored_state, subexpr_type,
4291 captures_started(), zone());
4292 builder = stored_state->builder();
4297 builder->AddAtom(atom);
4305 return ReportError(
CStrVector(
"\\ at end of pattern"));
4308 builder->AddAssertion(
4309 new(zone()) RegExpAssertion(RegExpAssertion::BOUNDARY));
4313 builder->AddAssertion(
4314 new(zone()) RegExpAssertion(RegExpAssertion::NON_BOUNDARY));
4321 case 'd':
case 'D':
case 's':
case 'S':
case 'w':
case 'W': {
4324 ZoneList<CharacterRange>* ranges =
4325 new(zone()) ZoneList<CharacterRange>(2, zone());
4327 RegExpTree* atom =
new(zone()) RegExpCharacterClass(ranges,
false);
4328 builder->AddAtom(atom);
4331 case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
4332 case '7':
case '8':
case '9': {
4334 if (ParseBackReferenceIndex(&index)) {
4335 RegExpCapture* capture =
NULL;
4336 if (captures_ !=
NULL && index <= captures_->length()) {
4337 capture = captures_->at(index - 1);
4339 if (capture ==
NULL) {
4340 builder->AddEmpty();
4343 RegExpTree* atom =
new(zone()) RegExpBackReference(capture);
4344 builder->AddAtom(atom);
4347 uc32 first_digit = Next();
4348 if (first_digit ==
'8' || first_digit ==
'9') {
4350 builder->AddCharacter(first_digit);
4358 uc32 octal = ParseOctalLiteral();
4359 builder->AddCharacter(octal);
4366 builder->AddCharacter(
'\f');
4370 builder->AddCharacter(
'\n');
4374 builder->AddCharacter(
'\r');
4378 builder->AddCharacter(
'\t');
4382 builder->AddCharacter(
'\v');
4386 uc32 controlLetter = Next();
4389 uc32 letter = controlLetter & ~(
'a' ^
'A');
4390 if (letter <
'A' ||
'Z' < letter) {
4395 builder->AddCharacter(
'\\');
4398 builder->AddCharacter(controlLetter & 0x1f);
4405 if (ParseHexEscape(2, &value)) {
4406 builder->AddCharacter(value);
4408 builder->AddCharacter(
'x');
4415 if (ParseHexEscape(4, &value)) {
4416 builder->AddCharacter(value);
4418 builder->AddCharacter(
'u');
4424 builder->AddCharacter(Next());
4431 if (ParseIntervalQuantifier(&dummy, &dummy)) {
4437 builder->AddCharacter(current());
4444 switch (current()) {
4466 if (ParseIntervalQuantifier(&
min, &max)) {
4468 ReportError(
CStrVector(
"numbers out of order in {} quantifier.")
4478 RegExpQuantifier::QuantifierType quantifier_type = RegExpQuantifier::GREEDY;
4479 if (current() ==
'?') {
4480 quantifier_type = RegExpQuantifier::NON_GREEDY;
4482 }
else if (FLAG_regexp_possessive_quantifier && current() ==
'+') {
4484 quantifier_type = RegExpQuantifier::POSSESSIVE;
4487 builder->AddQuantifierToAtom(
min, max, quantifier_type);
4494 static bool IsSpecialClassEscape(
uc32 c) {
4513 void RegExpParser::ScanForCaptures() {
4515 int capture_count = captures_started();
4518 while ((n = current()) != kEndMarker) {
4526 while ((c = current()) != kEndMarker) {
4531 if (c ==
']')
break;
4537 if (current() !=
'?') capture_count++;
4541 capture_count_ = capture_count;
4542 is_scanned_for_captures_ =
true;
4546 bool RegExpParser::ParseBackReferenceIndex(
int* index_out) {
4548 DCHECK(
'1' <= Next() && Next() <=
'9');
4551 int start = position();
4552 int value = Next() -
'0';
4557 value = 10 * value + (c -
'0');
4558 if (value > kMaxCaptures) {
4567 if (value > captures_started()) {
4568 if (!is_scanned_for_captures_) {
4569 int saved_position = position();
4571 Reset(saved_position);
4573 if (value > capture_count_) {
4590 bool RegExpParser::ParseIntervalQuantifier(
int* min_out,
int* max_out) {
4592 int start = position();
4600 int next = current() -
'0';
4613 if (current() ==
'}') {
4616 }
else if (current() ==
',') {
4618 if (current() ==
'}') {
4623 int next = current() -
'0';
4631 max = 10 * max + next;
4634 if (current() !=
'}') {
4650 uc32 RegExpParser::ParseOctalLiteral() {
4651 DCHECK((
'0' <= current() && current() <=
'7') || current() == kEndMarker);
4654 uc32 value = current() -
'0';
4656 if (
'0' <= current() && current() <=
'7') {
4657 value = value * 8 + current() -
'0';
4659 if (value < 32 &&
'0' <= current() && current() <=
'7') {
4660 value = value * 8 + current() -
'0';
4668 bool RegExpParser::ParseHexEscape(
int length,
uc32 *value) {
4669 int start = position();
4672 for (
int i = 0; !done;
i++) {
4681 if (
i == length - 1) {
4690 uc32 RegExpParser::ParseClassCharacterEscape() {
4691 DCHECK(current() ==
'\\');
4692 DCHECK(has_next() && !IsSpecialClassEscape(Next()));
4694 switch (current()) {
4716 uc32 controlLetter = Next();
4717 uc32 letter = controlLetter & ~(
'A' ^
'a');
4720 if ((controlLetter >=
'0' && controlLetter <=
'9') ||
4721 controlLetter ==
'_' ||
4722 (letter >=
'A' && letter <=
'Z')) {
4726 return controlLetter & 0x1f;
4732 case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
4737 return ParseOctalLiteral();
4741 if (ParseHexEscape(2, &value)) {
4751 if (ParseHexEscape(4, &value)) {
4762 uc32 result = current();
4771 CharacterRange RegExpParser::ParseClassAtom(
uc16* char_class) {
4773 uc32 first = current();
4774 if (first ==
'\\') {
4776 case 'w':
case 'W':
case 'd':
case 'D':
case 's':
case 'S': {
4777 *char_class = Next();
4782 return ReportError(
CStrVector(
"\\ at end of pattern"));
4806 ranges->
Add(range, zone);
4811 RegExpTree* RegExpParser::ParseCharacterClass() {
4812 static const char* kUnterminated =
"Unterminated character class";
4813 static const char* kRangeOutOfOrder =
"Range out of order in character class";
4817 bool is_negated =
false;
4818 if (current() ==
'^') {
4822 ZoneList<CharacterRange>* ranges =
4823 new(zone()) ZoneList<CharacterRange>(2, zone());
4824 while (has_more() && current() !=
']') {
4826 CharacterRange first = ParseClassAtom(&char_class
CHECK_FAILED);
4827 if (current() ==
'-') {
4829 if (current() == kEndMarker) {
4833 }
else if (current() ==
']') {
4839 CharacterRange next = ParseClassAtom(&char_class_2
CHECK_FAILED);
4847 if (first.from() > next.to()) {
4859 if (ranges->length() == 0) {
4861 is_negated = !is_negated;
4863 return new(zone()) RegExpCharacterClass(ranges, is_negated);
4870 bool RegExpParser::ParseRegExp(FlatStringReader* input,
4872 RegExpCompileData* result,
4875 RegExpParser parser(input, &result->error, multiline, zone);
4876 RegExpTree* tree = parser.ParsePattern();
4877 if (parser.failed()) {
4879 DCHECK(!result->error.is_null());
4882 DCHECK(result->error.is_null());
4883 result->tree = tree;
4884 int capture_count = parser.captures_started();
4885 result->simple = tree->IsAtom() && parser.simple() && capture_count == 0;
4886 result->contains_anchor = parser.contains_anchor();
4887 result->capture_count = capture_count;
4889 return !parser.failed();
4895 FunctionLiteral* result =
NULL;
4904 if (
info()->is_lazy()) {
4906 if (
info()->shared_info()->is_function()) {
4919 return (result !=
NULL);
4925 FunctionLiteral* result =
NULL;
4935 info()->source_stream_encoding());
4937 DCHECK(
info()->context().is_null() ||
info()->context()->IsNativeContext());
4950 if (eval_scope !=
NULL) {
UseCounterFeature
Features reported via the SetUseCounterCallback callback.
@ kUseCounterFeatureCount
virtual MaterializedLiteral * AsMaterializedLiteral()
const unsigned char * raw_data() const
virtual int length() const OVERRIDE
Handle< String > string() const
void Internalize(Isolate *isolate)
const AstRawString * GetOneByteString(Vector< const uint8_t > literal)
const AstRawString * GetString(Handle< String > literal)
bool BooleanValue() const
Target(Target **variable, AstNode *node)
TargetScope(Target **variable)
ZoneList< const AstRawString * > * labels() const
virtual BreakableStatement * AsBreakableStatement() FINAL OVERRIDE
bool is_target_for_anonymous() const
static CharacterRange Range(uc16 from, uc16 to)
static CharacterRange Singleton(uc16 value)
static CharacterRange Everything()
static void AddClassEscape(uc16 type, ZoneList< CharacterRange > *ranges, Zone *zone)
static const int kMaxArguments
AstNode::IdGen * ast_node_id_gen()
ScriptCompiler::ExternalSourceStream * source_stream() const
ScriptData ** cached_data() const
Handle< Script > script() const
void SetGlobalScope(Scope *global_scope)
Handle< Context > context() const
void SetFunction(FunctionLiteral *literal)
AstValueFactory * ast_value_factory() const
void SetAstValueFactory(AstValueFactory *ast_value_factory, bool owned=true)
StrictMode strict_mode() const
ParseRestriction parse_restriction() const
Handle< SharedFunctionInfo > shared_info() const
static Handle< FixedArray > GetElements(Handle< FixedArray > value)
static LiteralType GetLiteralType(Handle< FixedArray > value)
static bool IsCompileTimeValue(Expression *expression)
static Handle< FixedArray > GetValue(Isolate *isolate, Expression *expression)
ScriptData * GetScriptData()
void OnCompileError(Handle< Script > script)
VariableMode mode() const
virtual InitializationFlag initialization() const =0
VariableProxy * proxy() const
virtual bool IsPropertyName() const
unsigned parenthesization_level() const
void Initialize(Expression *each, Expression *subject, Statement *body)
void PushVariableName(const AstRawString *name)
void AddFunction(FunctionLiteral *func_to_infer)
void PushEnclosingName(const AstRawString *name)
void PushLiteralName(const AstRawString *name)
void RemoveLastFunction()
void Add(const AstRawString *name, Interface *interface, Zone *zone, bool *ok)
static Interface * NewValue()
static Interface * NewUnknown(Zone *zone)
static Interface * NewModule(Zone *zone)
static Interface * NewConst()
void CountUsage(v8::Isolate::UseCounterFeature feature)
static const char *const kStackOverflowMessage
Object * Throw(Object *exception, MessageLocation *location=NULL)
virtual IterationStatement * AsIterationStatement() FINAL OVERRIDE
Label * continue_target()
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
Vector< const T > ToConstVector()
Handle< String > Internalize(Isolate *isolate) const
Interface * interface() const
FunctionEntry GetFunctionEntry(int start)
v8::Extension * extension_
IdentifierT ParseIdentifierName(bool *ok)
bool allow_harmony_scoping() const
ExpressionT ParseClassLiteral(IdentifierT name, Scanner::Location function_name_location, bool name_is_strict_reserved, int pos, bool *ok)
bool Check(Token::Value token)
IdentifierT ParseIdentifierOrStrictReservedWord(bool *is_strict_reserved, bool *ok)
bool allow_harmony_object_literals() const
bool peek_any_identifier()
Traits::Type::Scope * scope_
void set_allow_harmony_scoping(bool allow)
Traits::Type::Zone * zone() const
void set_allow_lazy(bool allow)
void Expect(Token::Value token, bool *ok)
AstNode::IdGen * ast_node_id_gen() const
void set_stack_overflow()
void set_allow_arrow_functions(bool allow)
AstNode::IdGen * ast_node_id_gen_
void ReportMessageAt(Scanner::Location location, const char *message, bool is_reference_error=false)
bool allow_natives_syntax() const
IdentifierT ParseIdentifier(AllowEvalOrArgumentsAsIdentifier, bool *ok)
Traits::Type::ExpressionList ParseArguments(bool *ok)
void CheckOctalLiteral(int beg_pos, int end_pos, bool *ok)
bool is_generator() const
void set_allow_modules(bool allow)
bool CheckContextualKeyword(Vector< const char > keyword)
void set_allow_harmony_numeric_literals(bool allow)
void set_allow_harmony_object_literals(bool allow)
void set_allow_classes(bool allow)
ExpressionT ParseAssignmentExpression(bool accept_IN, bool *ok)
bool stack_overflow() const
void ExpectSemicolon(bool *ok)
ExpressionT CheckAndRewriteReferenceExpression(ExpressionT expression, Scanner::Location location, const char *message, bool *ok)
void ReportMessage(const char *message, const char *arg=NULL, bool is_reference_error=false)
ExpressionT ParseExpression(bool accept_IN, bool *ok)
bool allow_modules() const
Scanner * scanner() const
FunctionState * function_state_
bool allow_arrow_functions() const
void CheckStrictFunctionNameAndParameters(IdentifierT function_name, bool function_name_is_strict_reserved, const Scanner::Location &function_name_loc, const Scanner::Location &eval_args_error_loc, const Scanner::Location &dupe_error_loc, const Scanner::Location &reserved_loc, bool *ok)
void set_allow_natives_syntax(bool allow)
bool allow_harmony_numeric_literals() const
bool parenthesized_function_
void ExpectContextualKeyword(Vector< const char > keyword, bool *ok)
void Consume(Token::Value token)
Traits::Type::Factory * factory()
void ReportUnexpectedToken(Token::Value token)
Traits::Type::Zone * zone_
bool allow_classes() const
@ kDontAllowEvalOrArguments
virtual void LogFunction(int start, int end, int literals, int properties, StrictMode strict_mode)=0
ParserBase< ParserTraits > * parser_
AstNode::IdGen saved_ast_node_id_gen_
Checkpoint(ParserBase< ParserTraits > *parser)
static bool IsThisProperty(Expression *expression)
const AstRawString * GetSymbol(Scanner *scanner)
Expression * NewThrowReferenceError(const char *type, int pos)
static void CheckAssigningFunctionLiteralToProperty(Expression *left, Expression *right)
void ReportMessage(const char *message, const char *arg=NULL, bool is_reference_error=false)
Expression * ParseV8Intrinsic(bool *ok)
Expression * ExpressionFromString(int pos, Scanner *scanner, AstNodeFactory< AstConstructionVisitor > *factory)
bool IsPrototype(const AstRawString *identifier) const
const AstRawString * GetNextSymbol(Scanner *scanner)
Expression * NewThrowSyntaxError(const char *type, const AstRawString *arg, int pos)
bool IsConstructor(const AstRawString *identifier) const
int DeclareArrowParametersFromExpression(Expression *expression, Scope *scope, Scanner::Location *dupe_loc, bool *ok)
bool IsEvalOrArguments(const AstRawString *identifier) const
Expression * NewThrowError(const AstRawString *constructor, const char *type, const AstRawString *arg, int pos)
Expression * NewThrowTypeError(const char *type, const AstRawString *arg, int pos)
Expression * ThisExpression(Scope *scope, AstNodeFactory< AstConstructionVisitor > *factory, int pos=RelocInfo::kNoPosition)
void PushPropertyName(FuncNameInferrer *fni, Expression *expression)
void ReportMessageAt(Scanner::Location source_location, const char *message, const char *arg=NULL, bool is_reference_error=false)
AstValueFactory * ast_value_factory()
Expression * ClassLiteral(const AstRawString *name, Expression *extends, Expression *constructor, ZoneList< ObjectLiteral::Property * > *properties, int pos, AstNodeFactory< AstConstructionVisitor > *factory)
static Expression * MarkExpressionAsAssigned(Expression *expression)
Literal * ExpressionFromLiteral(Token::Value token, int pos, Scanner *scanner, AstNodeFactory< AstConstructionVisitor > *factory)
Expression * ExpressionFromIdentifier(const AstRawString *name, int pos, Scope *scope, AstNodeFactory< AstConstructionVisitor > *factory)
const AstRawString * GetNumberAsSymbol(Scanner *scanner)
Expression * BuildUnaryExpression(Expression *expression, Token::Value op, int pos, AstNodeFactory< AstConstructionVisitor > *factory)
bool ShortcutNumericLiteralBinaryExpression(Expression **x, Expression *y, Token::Value op, int pos, AstNodeFactory< AstConstructionVisitor > *factory)
void CheckPossibleEvalCall(Expression *expression, Scope *scope)
Expression * SuperReference(Scope *scope, AstNodeFactory< AstConstructionVisitor > *factory, int pos=RelocInfo::kNoPosition)
Expression * GetIterator(Expression *iterable, AstNodeFactory< AstConstructionVisitor > *factory)
FunctionLiteral * ParseFunctionLiteral(const AstRawString *name, Scanner::Location function_name_location, bool name_is_strict_reserved, FunctionKind kind, int function_token_position, FunctionLiteral::FunctionType type, FunctionLiteral::ArityRestriction arity_restriction, bool *ok)
Literal * GetLiteralTheHole(int position, AstNodeFactory< AstConstructionVisitor > *factory)
bool IsFutureStrictReserved(const AstRawString *identifier) const
static bool IsIdentifier(Expression *expression)
ScriptCompiler::CompileOptions compile_options() const
VariableDeclarationContext
IterationStatement * LookupContinueTarget(const AstRawString *label, bool *ok)
Statement * ParseExpressionOrLabelledStatement(ZoneList< const AstRawString * > *labels, bool *ok)
Block * ParseScopedBlock(ZoneList< const AstRawString * > *labels, bool *ok)
Statement * ParseReturnStatement(bool *ok)
Block * ParseBlock(ZoneList< const AstRawString * > *labels, bool *ok)
Scope * DeclarationScope(VariableMode mode)
Statement * ParseBlockElement(ZoneList< const AstRawString * > *labels, bool *ok)
Scope * NewScope(Scope *parent, ScopeType type)
bool TargetStackContainsLabel(const AstRawString *label)
int use_counts_[v8::Isolate::kUseCounterFeatureCount]
IfStatement * ParseIfStatement(ZoneList< const AstRawString * > *labels, bool *ok)
FunctionLiteral * ParseFunctionLiteral(const AstRawString *name, Scanner::Location function_name_location, bool name_is_strict_reserved, FunctionKind kind, int function_token_position, FunctionLiteral::FunctionType type, FunctionLiteral::ArityRestriction arity_restriction, bool *ok)
Statement * ParseModuleElement(ZoneList< const AstRawString * > *labels, bool *ok)
Statement * ParseContinueStatement(bool *ok)
void RegisterTargetUse(Label *target, Target *stop)
void CheckConflictingVarDeclarations(Scope *scope, bool *ok)
Block * ParseImportDeclaration(bool *ok)
Expression * ParseV8Intrinsic(bool *ok)
Statement * ParseNativeDeclaration(bool *ok)
Block * ParseVariableDeclarations(VariableDeclarationContext var_context, VariableDeclarationProperties *decl_props, ZoneList< const AstRawString * > *names, const AstRawString **out, bool *ok)
SwitchStatement * ParseSwitchStatement(ZoneList< const AstRawString * > *labels, bool *ok)
Statement * ParseExportDeclaration(bool *ok)
WhileStatement * ParseWhileStatement(ZoneList< const AstRawString * > *labels, bool *ok)
Module * ParseModulePath(bool *ok)
Block * ParseVariableStatement(VariableDeclarationContext var_context, ZoneList< const AstRawString * > *names, bool *ok)
BreakableStatement * LookupBreakTarget(const AstRawString *label, bool *ok)
VariableProxy * NewUnresolved(const AstRawString *name, VariableMode mode, Interface *interface)
Handle< Script > script() const
FunctionLiteral * ParseLazy()
void HandleSourceURLComments()
Literal * GetLiteralUndefined(int position)
void * ParseSourceElements(ZoneList< Statement * > *processor, int end_token, bool is_eval, bool is_global, Scope **ad_hoc_eval_scope, bool *ok)
bool pending_error_is_reference_error_
CaseClause * ParseCaseClause(bool *default_seen_ptr, bool *ok)
Module * ParseModuleVariable(bool *ok)
PreParser::PreParseResult ParseLazyFunctionBodyWithPreParser(SingletonLogger *logger)
const AstRawString * pending_error_arg_
void Declare(Declaration *declaration, bool resolve, bool *ok)
Statement * ParseStatement(ZoneList< const AstRawString * > *labels, bool *ok)
Statement * ParseForStatement(ZoneList< const AstRawString * > *labels, bool *ok)
Module * ParseModuleUrl(bool *ok)
Statement * ParseClassDeclaration(ZoneList< const AstRawString * > *names, bool *ok)
Statement * ParseWithStatement(ZoneList< const AstRawString * > *labels, bool *ok)
ParseData * cached_parse_data_
FunctionLiteral * DoParseProgram(CompilationInfo *info, Scope **scope, Scope **ad_hoc_eval_scope)
FunctionLiteral * ParseProgram()
HistogramTimer * pre_parse_timer_
Statement * DesugarLetBindingsInForStatement(Scope *inner_scope, ZoneList< const AstRawString * > *names, ForStatement *loop, Statement *init, Expression *cond, Statement *next, Statement *body, bool *ok)
const char * pending_error_char_arg_
CompilationInfo * info() const
void SkipLazyFunctionBody(const AstRawString *function_name, int *materialized_literal_count, int *expected_property_count, bool *ok)
bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode *visit_mode)
VariableDeclarationProperties
DebuggerStatement * ParseDebuggerStatement(bool *ok)
ZoneList< Statement * > * ParseEagerFunctionBody(const AstRawString *function_name, int pos, Variable *fvar, Token::Value fvar_init_op, bool is_generator, bool *ok)
void InitializeForEachStatement(ForEachStatement *stmt, Expression *each, Expression *subject, Statement *body)
Statement * ParseBreakStatement(ZoneList< const AstRawString * > *labels, bool *ok)
DoWhileStatement * ParseDoWhileStatement(ZoneList< const AstRawString * > *labels, bool *ok)
static const int kMaxNumFunctionLocals
Scanner::Location pending_error_location_
Statement * ParseModuleDeclaration(ZoneList< const AstRawString * > *names, bool *ok)
Statement * ParseFunctionDeclaration(ZoneList< const AstRawString * > *names, bool *ok)
Module * ParseModuleLiteral(bool *ok)
Parser(CompilationInfo *info, ParseInfo *parse_info)
AstValueFactory * ast_value_factory() const
const char * pending_error_message_
Module * ParseModule(bool *ok)
int total_preparse_skipped_
Statement * ParseThrowStatement(bool *ok)
Module * ParseModuleSpecifier(bool *ok)
TryStatement * ParseTryStatement(bool *ok)
PreParser * reusable_preparser_
PreParseResult PreParseLazyFunction(StrictMode strict_mode, bool is_generator, ParserRecorder *log)
void AddCharacter(uc16 character)
void AddAtom(RegExpTree *tree)
ZoneList< uc16 > * characters_
BufferedZoneList< RegExpTree, 2 > alternatives_
void AddAssertion(RegExpTree *tree)
RegExpBuilder(Zone *zone)
BufferedZoneList< RegExpTree, 2 > text_
BufferedZoneList< RegExpTree, 2 > terms_
void AddQuantifierToAtom(int min, int max, RegExpQuantifier::QuantifierType type)
static const int kInfinity
virtual int max_match()=0
virtual bool IsTextElement()
static const int kNoPosition
static const Function * FunctionForId(FunctionId id)
static const Function * FunctionForName(Handle< String > name)
void SeekForward(int pos)
void Initialize(Utf16CharacterStream *source)
Location peek_location() const
const LiteralBuffer * source_url() const
const LiteralBuffer * source_mapping_url() const
const AstRawString * NextSymbol(AstValueFactory *ast_value_factory)
Location location() const
const AstRawString * CurrentSymbol(AstValueFactory *ast_value_factory)
void SetStrictMode(StrictMode strict_mode)
void set_end_position(int statement_pos)
bool is_global_scope() const
Variable * Lookup(const AstRawString *name)
Variable * DeclareLocal(const AstRawString *name, VariableMode mode, InitializationFlag init_flag, MaybeAssignedFlag maybe_assigned_flag=kNotAssigned, Interface *interface=Interface::NewValue())
void ForceEagerCompilation()
VariableProxy * NewUnresolved(AstNodeFactory< Visitor > *factory, const AstRawString *name, Interface *interface=Interface::NewValue(), int position=RelocInfo::kNoPosition)
bool is_eval_scope() const
void SetIllegalRedeclaration(Expression *expression)
bool is_function_scope() const
bool IsDeclared(const AstRawString *name)
Scope * DeclarationScope()
void set_start_position(int statement_pos)
bool is_block_scope() const
Scope * FinalizeBlockScope()
StrictMode strict_mode() const
Declaration * CheckConflictingVarDeclarations()
Variable * DeclareParameter(const AstRawString *name, VariableMode mode)
Interface * interface() const
void AddDeclaration(Declaration *declaration)
static Scope * DeserializeScopeChain(Context *context, Scope *global_scope, Zone *zone)
int start_position() const
bool is_module_scope() const
Variable * LookupLocal(const AstRawString *name)
bool is_strict_eval_scope() const
int is_reference_error() const
StrictMode strict_mode() const
const char * argument_opt() const
static Smi * FromInt(int value)
static Handle< String > Flatten(Handle< String > string, PretenureFlag pretenure=NOT_TENURED)
void set_escaping_targets(ZoneList< Label * > *targets)
void set_maybe_assigned()
VariableMode mode() const
Interface * interface() const
void AllocateTo(Location location, int index)
const AstRawString * raw_name() const
Vector< T > SubVector(int from, int to)
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS 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 enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
enable harmony numeric enable harmony object literal extensions true
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS 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 mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS 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 enable alignment of csp to bytes on platforms which prefer the register to always be NULL
enable harmony numeric enable harmony object literal extensions Optimize object Array shift
#define DCHECK_NE(v1, v2)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
Vector< const char > CStrVector(const char *data)
static const uc16 kNoCharClass
bool IsDecimalDigit(uc32 c)
uint32_t DoubleToUint32(double x)
static int min(int a, int b)
bool IsLexicalVariableMode(VariableMode mode)
bool IsDeclaredVariableMode(VariableMode mode)
kExpectedNofPropertiesOffset function_token_position
bool IsGeneratorFunction(FunctionKind kind)
bool IsConciseMethod(FunctionKind kind)
bool CheckAndDeclareArrowParameter(ParserTraits *traits, Expression *expression, Scope *scope, int *num_params, Scanner::Location *dupe_loc)
bool IsImmutableVariableMode(VariableMode mode)
int ArithmeticShiftRight(int x, int s)
void PrintF(const char *format,...)
int32_t DoubleToInt32(double x)
kFeedbackVectorOffset flag
@ ONLY_SINGLE_FUNCTION_LITERAL
const char * DoubleToCString(double v, Vector< char > buffer)
static bool ContainsLabel(ZoneList< const AstRawString * > *labels, const AstRawString *label)
static void AddRangeOrEscape(ZoneList< CharacterRange > *ranges, uc16 char_class, CharacterRange range, Zone *zone)
Debugger support for the V8 JavaScript engine.
static const int kHeaderSize
static const unsigned kMagicNumber
static const int kMagicOffset
static const int kHasErrorOffset
static const unsigned kCurrentVersion
static const int kVersionOffset
static const int kFunctionsSizeOffset
static Location invalid()