OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 Scope* outer_scope_; | 483 Scope* outer_scope_; |
484 }; | 484 }; |
485 | 485 |
486 | 486 |
487 Parser::FunctionState::FunctionState(Parser* parser, | 487 Parser::FunctionState::FunctionState(Parser* parser, |
488 Scope* scope, | 488 Scope* scope, |
489 Isolate* isolate) | 489 Isolate* isolate) |
490 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), | 490 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), |
491 next_handler_index_(0), | 491 next_handler_index_(0), |
492 expected_property_count_(0), | 492 expected_property_count_(0), |
493 only_simple_this_property_assignments_(false), | |
494 this_property_assignments_(isolate->factory()->empty_fixed_array()), | |
495 generator_object_variable_(NULL), | 493 generator_object_variable_(NULL), |
496 parser_(parser), | 494 parser_(parser), |
497 outer_function_state_(parser->current_function_state_), | 495 outer_function_state_(parser->current_function_state_), |
498 outer_scope_(parser->top_scope_), | 496 outer_scope_(parser->top_scope_), |
499 saved_ast_node_id_(isolate->ast_node_id()), | 497 saved_ast_node_id_(isolate->ast_node_id()), |
500 factory_(isolate, parser->zone()) { | 498 factory_(isolate, parser->zone()) { |
501 parser->top_scope_ = scope; | 499 parser->top_scope_ = scope; |
502 parser->current_function_state_ = this; | 500 parser->current_function_state_ = this; |
503 isolate->set_ast_node_id(BailoutId::FirstUsable().ToInt()); | 501 isolate->set_ast_node_id(BailoutId::FirstUsable().ToInt()); |
504 } | 502 } |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 } | 666 } |
669 | 667 |
670 if (ok) { | 668 if (ok) { |
671 result = factory()->NewFunctionLiteral( | 669 result = factory()->NewFunctionLiteral( |
672 no_name, | 670 no_name, |
673 top_scope_, | 671 top_scope_, |
674 body, | 672 body, |
675 function_state.materialized_literal_count(), | 673 function_state.materialized_literal_count(), |
676 function_state.expected_property_count(), | 674 function_state.expected_property_count(), |
677 function_state.handler_count(), | 675 function_state.handler_count(), |
678 function_state.only_simple_this_property_assignments(), | |
679 function_state.this_property_assignments(), | |
680 0, | 676 0, |
681 FunctionLiteral::kNoDuplicateParameters, | 677 FunctionLiteral::kNoDuplicateParameters, |
682 FunctionLiteral::ANONYMOUS_EXPRESSION, | 678 FunctionLiteral::ANONYMOUS_EXPRESSION, |
683 FunctionLiteral::kGlobalOrEval, | 679 FunctionLiteral::kGlobalOrEval, |
684 FunctionLiteral::kNotParenthesized, | 680 FunctionLiteral::kNotParenthesized, |
685 FunctionLiteral::kNotGenerator); | 681 FunctionLiteral::kNotGenerator); |
686 result->set_ast_properties(factory()->visitor()->ast_properties()); | 682 result->set_ast_properties(factory()->visitor()->ast_properties()); |
687 } else if (stack_overflow_) { | 683 } else if (stack_overflow_) { |
688 isolate()->StackOverflow(); | 684 isolate()->StackOverflow(); |
689 } | 685 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 Handle<FixedArray> elements = factory->NewFixedArray(args.length()); | 839 Handle<FixedArray> elements = factory->NewFixedArray(args.length()); |
844 for (int i = 0; i < args.length(); i++) { | 840 for (int i = 0; i < args.length(); i++) { |
845 elements->set(i, *args[i]); | 841 elements->set(i, *args[i]); |
846 } | 842 } |
847 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); | 843 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); |
848 Handle<Object> result = factory->NewSyntaxError(type, array); | 844 Handle<Object> result = factory->NewSyntaxError(type, array); |
849 isolate()->Throw(*result, &location); | 845 isolate()->Throw(*result, &location); |
850 } | 846 } |
851 | 847 |
852 | 848 |
853 // A ThisNamedPropertyAssignmentFinder finds and marks statements of the form | |
854 // this.x = ...;, where x is a named property. It also determines whether a | |
855 // function contains only assignments of this type. | |
856 class ThisNamedPropertyAssignmentFinder { | |
857 public: | |
858 ThisNamedPropertyAssignmentFinder(Isolate* isolate, Zone* zone) | |
859 : isolate_(isolate), | |
860 only_simple_this_property_assignments_(true), | |
861 names_(0, zone), | |
862 assigned_arguments_(0, zone), | |
863 assigned_constants_(0, zone), | |
864 zone_(zone) { | |
865 } | |
866 | |
867 static Assignment* AsAssignment(Statement* stat) { | |
868 if (stat == NULL) return NULL; | |
869 ExpressionStatement* exp_stat = stat->AsExpressionStatement(); | |
870 if (exp_stat == NULL) return NULL; | |
871 return exp_stat->expression()->AsAssignment(); | |
872 } | |
873 | |
874 void Update(Scope* scope, Statement* stat) { | |
875 // Bail out if function already has property assignment that are | |
876 // not simple this property assignments. | |
877 if (!only_simple_this_property_assignments_) { | |
878 return; | |
879 } | |
880 | |
881 // Check whether this statement is of the form this.x = ...; | |
882 Assignment* assignment = AsAssignment(stat); | |
883 if (IsThisPropertyAssignment(assignment)) { | |
884 HandleThisPropertyAssignment(scope, assignment); | |
885 } else { | |
886 only_simple_this_property_assignments_ = false; | |
887 } | |
888 } | |
889 | |
890 // Returns whether only statements of the form this.x = y; where y is either a | |
891 // constant or a function argument was encountered. | |
892 bool only_simple_this_property_assignments() { | |
893 return only_simple_this_property_assignments_; | |
894 } | |
895 | |
896 // Returns a fixed array containing three elements for each assignment of the | |
897 // form this.x = y; | |
898 Handle<FixedArray> GetThisPropertyAssignments() { | |
899 if (names_.is_empty()) { | |
900 return isolate_->factory()->empty_fixed_array(); | |
901 } | |
902 ASSERT_EQ(names_.length(), assigned_arguments_.length()); | |
903 ASSERT_EQ(names_.length(), assigned_constants_.length()); | |
904 Handle<FixedArray> assignments = | |
905 isolate_->factory()->NewFixedArray(names_.length() * 3); | |
906 for (int i = 0; i < names_.length(); ++i) { | |
907 assignments->set(i * 3, *names_[i]); | |
908 assignments->set(i * 3 + 1, Smi::FromInt(assigned_arguments_[i])); | |
909 assignments->set(i * 3 + 2, *assigned_constants_[i]); | |
910 } | |
911 return assignments; | |
912 } | |
913 | |
914 private: | |
915 bool IsThisPropertyAssignment(Assignment* assignment) { | |
916 if (assignment != NULL) { | |
917 Property* property = assignment->target()->AsProperty(); | |
918 return assignment->op() == Token::ASSIGN | |
919 && property != NULL | |
920 && property->obj()->AsVariableProxy() != NULL | |
921 && property->obj()->AsVariableProxy()->is_this(); | |
922 } | |
923 return false; | |
924 } | |
925 | |
926 void HandleThisPropertyAssignment(Scope* scope, Assignment* assignment) { | |
927 // Check that the property assigned to is a named property, which is not | |
928 // __proto__. | |
929 Property* property = assignment->target()->AsProperty(); | |
930 ASSERT(property != NULL); | |
931 Literal* literal = property->key()->AsLiteral(); | |
932 uint32_t dummy; | |
933 if (literal != NULL && | |
934 literal->handle()->IsString() && | |
935 !String::cast(*(literal->handle()))->Equals( | |
936 isolate_->heap()->proto_string()) && | |
937 !String::cast(*(literal->handle()))->AsArrayIndex(&dummy)) { | |
938 Handle<String> key = Handle<String>::cast(literal->handle()); | |
939 | |
940 // Check whether the value assigned is either a constant or matches the | |
941 // name of one of the arguments to the function. | |
942 if (assignment->value()->AsLiteral() != NULL) { | |
943 // Constant assigned. | |
944 Literal* literal = assignment->value()->AsLiteral(); | |
945 AssignmentFromConstant(key, literal->handle()); | |
946 return; | |
947 } else if (assignment->value()->AsVariableProxy() != NULL) { | |
948 // Variable assigned. | |
949 Handle<String> name = | |
950 assignment->value()->AsVariableProxy()->name(); | |
951 // Check whether the variable assigned matches an argument name. | |
952 for (int i = 0; i < scope->num_parameters(); i++) { | |
953 if (*scope->parameter(i)->name() == *name) { | |
954 // Assigned from function argument. | |
955 AssignmentFromParameter(key, i); | |
956 return; | |
957 } | |
958 } | |
959 } | |
960 } | |
961 // It is not a simple "this.x = value;" assignment with a constant | |
962 // or parameter value. | |
963 AssignmentFromSomethingElse(); | |
964 } | |
965 | |
966 | |
967 | |
968 | |
969 // We will potentially reorder the property assignments, so they must be | |
970 // simple enough that the ordering does not matter. | |
971 void AssignmentFromParameter(Handle<String> name, int index) { | |
972 EnsureInitialized(); | |
973 for (int i = 0; i < names_.length(); ++i) { | |
974 if (name->Equals(*names_[i])) { | |
975 assigned_arguments_[i] = index; | |
976 assigned_constants_[i] = isolate_->factory()->undefined_value(); | |
977 return; | |
978 } | |
979 } | |
980 names_.Add(name, zone()); | |
981 assigned_arguments_.Add(index, zone()); | |
982 assigned_constants_.Add(isolate_->factory()->undefined_value(), zone()); | |
983 } | |
984 | |
985 void AssignmentFromConstant(Handle<String> name, Handle<Object> value) { | |
986 EnsureInitialized(); | |
987 for (int i = 0; i < names_.length(); ++i) { | |
988 if (name->Equals(*names_[i])) { | |
989 assigned_arguments_[i] = -1; | |
990 assigned_constants_[i] = value; | |
991 return; | |
992 } | |
993 } | |
994 names_.Add(name, zone()); | |
995 assigned_arguments_.Add(-1, zone()); | |
996 assigned_constants_.Add(value, zone()); | |
997 } | |
998 | |
999 void AssignmentFromSomethingElse() { | |
1000 // The this assignment is not a simple one. | |
1001 only_simple_this_property_assignments_ = false; | |
1002 } | |
1003 | |
1004 void EnsureInitialized() { | |
1005 if (names_.capacity() == 0) { | |
1006 ASSERT(assigned_arguments_.capacity() == 0); | |
1007 ASSERT(assigned_constants_.capacity() == 0); | |
1008 names_.Initialize(4, zone()); | |
1009 assigned_arguments_.Initialize(4, zone()); | |
1010 assigned_constants_.Initialize(4, zone()); | |
1011 } | |
1012 } | |
1013 | |
1014 Zone* zone() const { return zone_; } | |
1015 | |
1016 Isolate* isolate_; | |
1017 bool only_simple_this_property_assignments_; | |
1018 ZoneStringList names_; | |
1019 ZoneList<int> assigned_arguments_; | |
1020 ZoneObjectList assigned_constants_; | |
1021 Zone* zone_; | |
1022 }; | |
1023 | |
1024 | |
1025 void* Parser::ParseSourceElements(ZoneList<Statement*>* processor, | 849 void* Parser::ParseSourceElements(ZoneList<Statement*>* processor, |
1026 int end_token, | 850 int end_token, |
1027 bool is_eval, | 851 bool is_eval, |
1028 bool is_global, | 852 bool is_global, |
1029 bool* ok) { | 853 bool* ok) { |
1030 // SourceElements :: | 854 // SourceElements :: |
1031 // (ModuleElement)* <end_token> | 855 // (ModuleElement)* <end_token> |
1032 | 856 |
1033 // Allocate a target stack to use for this set of source | 857 // Allocate a target stack to use for this set of source |
1034 // elements. This way, all scripts and functions get their own | 858 // elements. This way, all scripts and functions get their own |
1035 // target stack thus avoiding illegal breaks and continues across | 859 // target stack thus avoiding illegal breaks and continues across |
1036 // functions. | 860 // functions. |
1037 TargetScope scope(&this->target_stack_); | 861 TargetScope scope(&this->target_stack_); |
1038 | 862 |
1039 ASSERT(processor != NULL); | 863 ASSERT(processor != NULL); |
1040 ThisNamedPropertyAssignmentFinder this_property_assignment_finder(isolate(), | |
1041 zone()); | |
1042 bool directive_prologue = true; // Parsing directive prologue. | 864 bool directive_prologue = true; // Parsing directive prologue. |
1043 | 865 |
1044 while (peek() != end_token) { | 866 while (peek() != end_token) { |
1045 if (directive_prologue && peek() != Token::STRING) { | 867 if (directive_prologue && peek() != Token::STRING) { |
1046 directive_prologue = false; | 868 directive_prologue = false; |
1047 } | 869 } |
1048 | 870 |
1049 Scanner::Location token_loc = scanner().peek_location(); | 871 Scanner::Location token_loc = scanner().peek_location(); |
1050 Statement* stat; | 872 Statement* stat; |
1051 if (is_global && !is_eval) { | 873 if (is_global && !is_eval) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 ? EXTENDED_MODE : STRICT_MODE); | 913 ? EXTENDED_MODE : STRICT_MODE); |
1092 // "use strict" is the only directive for now. | 914 // "use strict" is the only directive for now. |
1093 directive_prologue = false; | 915 directive_prologue = false; |
1094 } | 916 } |
1095 } else { | 917 } else { |
1096 // End of the directive prologue. | 918 // End of the directive prologue. |
1097 directive_prologue = false; | 919 directive_prologue = false; |
1098 } | 920 } |
1099 } | 921 } |
1100 | 922 |
1101 // Find and mark all assignments to named properties in this (this.x =) | |
1102 if (top_scope_->is_function_scope()) { | |
1103 this_property_assignment_finder.Update(top_scope_, stat); | |
1104 } | |
1105 processor->Add(stat, zone()); | 923 processor->Add(stat, zone()); |
1106 } | 924 } |
1107 | 925 |
1108 // Propagate the collected information on this property assignments. | |
1109 if (top_scope_->is_function_scope()) { | |
1110 bool only_simple_this_property_assignments = | |
1111 this_property_assignment_finder.only_simple_this_property_assignments() | |
1112 && top_scope_->declarations()->length() == 0; | |
1113 if (only_simple_this_property_assignments) { | |
1114 current_function_state_->SetThisPropertyAssignmentInfo( | |
1115 only_simple_this_property_assignments, | |
1116 this_property_assignment_finder.GetThisPropertyAssignments()); | |
1117 } | |
1118 } | |
1119 | |
1120 return 0; | 926 return 0; |
1121 } | 927 } |
1122 | 928 |
1123 | 929 |
1124 Statement* Parser::ParseModuleElement(ZoneStringList* labels, | 930 Statement* Parser::ParseModuleElement(ZoneStringList* labels, |
1125 bool* ok) { | 931 bool* ok) { |
1126 // (Ecma 262 5th Edition, clause 14): | 932 // (Ecma 262 5th Edition, clause 14): |
1127 // SourceElement: | 933 // SourceElement: |
1128 // Statement | 934 // Statement |
1129 // FunctionDeclaration | 935 // FunctionDeclaration |
(...skipping 3250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4380 // Function declarations are function scoped in normal mode, so they are | 4186 // Function declarations are function scoped in normal mode, so they are |
4381 // hoisted. In harmony block scoping mode they are block scoped, so they | 4187 // hoisted. In harmony block scoping mode they are block scoped, so they |
4382 // are not hoisted. | 4188 // are not hoisted. |
4383 Scope* scope = (type == FunctionLiteral::DECLARATION && !is_extended_mode()) | 4189 Scope* scope = (type == FunctionLiteral::DECLARATION && !is_extended_mode()) |
4384 ? NewScope(top_scope_->DeclarationScope(), FUNCTION_SCOPE) | 4190 ? NewScope(top_scope_->DeclarationScope(), FUNCTION_SCOPE) |
4385 : NewScope(top_scope_, FUNCTION_SCOPE); | 4191 : NewScope(top_scope_, FUNCTION_SCOPE); |
4386 ZoneList<Statement*>* body = NULL; | 4192 ZoneList<Statement*>* body = NULL; |
4387 int materialized_literal_count = -1; | 4193 int materialized_literal_count = -1; |
4388 int expected_property_count = -1; | 4194 int expected_property_count = -1; |
4389 int handler_count = 0; | 4195 int handler_count = 0; |
4390 bool only_simple_this_property_assignments; | |
4391 Handle<FixedArray> this_property_assignments; | |
4392 FunctionLiteral::ParameterFlag duplicate_parameters = | 4196 FunctionLiteral::ParameterFlag duplicate_parameters = |
4393 FunctionLiteral::kNoDuplicateParameters; | 4197 FunctionLiteral::kNoDuplicateParameters; |
4394 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_ | 4198 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_ |
4395 ? FunctionLiteral::kIsParenthesized | 4199 ? FunctionLiteral::kIsParenthesized |
4396 : FunctionLiteral::kNotParenthesized; | 4200 : FunctionLiteral::kNotParenthesized; |
4397 FunctionLiteral::IsGeneratorFlag generator = is_generator | 4201 FunctionLiteral::IsGeneratorFlag generator = is_generator |
4398 ? FunctionLiteral::kIsGenerator | 4202 ? FunctionLiteral::kIsGenerator |
4399 : FunctionLiteral::kNotGenerator; | 4203 : FunctionLiteral::kNotGenerator; |
4400 AstProperties ast_properties; | 4204 AstProperties ast_properties; |
4401 // Parse function body. | 4205 // Parse function body. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4512 } | 4316 } |
4513 scanner().SeekForward(entry.end_pos() - 1); | 4317 scanner().SeekForward(entry.end_pos() - 1); |
4514 | 4318 |
4515 scope->set_end_position(entry.end_pos()); | 4319 scope->set_end_position(entry.end_pos()); |
4516 Expect(Token::RBRACE, CHECK_OK); | 4320 Expect(Token::RBRACE, CHECK_OK); |
4517 isolate()->counters()->total_preparse_skipped()->Increment( | 4321 isolate()->counters()->total_preparse_skipped()->Increment( |
4518 scope->end_position() - function_block_pos); | 4322 scope->end_position() - function_block_pos); |
4519 materialized_literal_count = entry.literal_count(); | 4323 materialized_literal_count = entry.literal_count(); |
4520 expected_property_count = entry.property_count(); | 4324 expected_property_count = entry.property_count(); |
4521 top_scope_->SetLanguageMode(entry.language_mode()); | 4325 top_scope_->SetLanguageMode(entry.language_mode()); |
4522 only_simple_this_property_assignments = false; | |
4523 this_property_assignments = isolate()->factory()->empty_fixed_array(); | |
4524 } else { | 4326 } else { |
4525 is_lazily_compiled = false; | 4327 is_lazily_compiled = false; |
4526 } | 4328 } |
4527 } else { | 4329 } else { |
4528 // With no preparser data, we partially parse the function, without | 4330 // With no preparser data, we partially parse the function, without |
4529 // building an AST. This gathers the data needed to build a lazy | 4331 // building an AST. This gathers the data needed to build a lazy |
4530 // function. | 4332 // function. |
4531 SingletonLogger logger; | 4333 SingletonLogger logger; |
4532 preparser::PreParser::PreParseResult result = | 4334 preparser::PreParser::PreParseResult result = |
4533 LazyParseFunctionLiteral(&logger); | 4335 LazyParseFunctionLiteral(&logger); |
(...skipping 14 matching lines...) Expand all Loading... |
4548 *ok = false; | 4350 *ok = false; |
4549 return NULL; | 4351 return NULL; |
4550 } | 4352 } |
4551 scope->set_end_position(logger.end()); | 4353 scope->set_end_position(logger.end()); |
4552 Expect(Token::RBRACE, CHECK_OK); | 4354 Expect(Token::RBRACE, CHECK_OK); |
4553 isolate()->counters()->total_preparse_skipped()->Increment( | 4355 isolate()->counters()->total_preparse_skipped()->Increment( |
4554 scope->end_position() - function_block_pos); | 4356 scope->end_position() - function_block_pos); |
4555 materialized_literal_count = logger.literals(); | 4357 materialized_literal_count = logger.literals(); |
4556 expected_property_count = logger.properties(); | 4358 expected_property_count = logger.properties(); |
4557 top_scope_->SetLanguageMode(logger.language_mode()); | 4359 top_scope_->SetLanguageMode(logger.language_mode()); |
4558 only_simple_this_property_assignments = false; | |
4559 this_property_assignments = isolate()->factory()->empty_fixed_array(); | |
4560 } | 4360 } |
4561 } | 4361 } |
4562 | 4362 |
4563 if (!is_lazily_compiled) { | 4363 if (!is_lazily_compiled) { |
4564 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 4364 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
4565 body = new(zone()) ZoneList<Statement*>(8, zone()); | 4365 body = new(zone()) ZoneList<Statement*>(8, zone()); |
4566 if (fvar != NULL) { | 4366 if (fvar != NULL) { |
4567 VariableProxy* fproxy = top_scope_->NewUnresolved( | 4367 VariableProxy* fproxy = top_scope_->NewUnresolved( |
4568 factory(), function_name, Interface::NewConst()); | 4368 factory(), function_name, Interface::NewConst()); |
4569 fproxy->BindTo(fvar); | 4369 fproxy->BindTo(fvar); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4602 Expression *undefined = factory()->NewLiteral( | 4402 Expression *undefined = factory()->NewLiteral( |
4603 isolate()->factory()->undefined_value()); | 4403 isolate()->factory()->undefined_value()); |
4604 Yield* yield = factory()->NewYield( | 4404 Yield* yield = factory()->NewYield( |
4605 get_proxy, undefined, Yield::FINAL, RelocInfo::kNoPosition); | 4405 get_proxy, undefined, Yield::FINAL, RelocInfo::kNoPosition); |
4606 body->Add(factory()->NewExpressionStatement(yield), zone()); | 4406 body->Add(factory()->NewExpressionStatement(yield), zone()); |
4607 } | 4407 } |
4608 | 4408 |
4609 materialized_literal_count = function_state.materialized_literal_count(); | 4409 materialized_literal_count = function_state.materialized_literal_count(); |
4610 expected_property_count = function_state.expected_property_count(); | 4410 expected_property_count = function_state.expected_property_count(); |
4611 handler_count = function_state.handler_count(); | 4411 handler_count = function_state.handler_count(); |
4612 only_simple_this_property_assignments = | |
4613 function_state.only_simple_this_property_assignments(); | |
4614 this_property_assignments = function_state.this_property_assignments(); | |
4615 | 4412 |
4616 Expect(Token::RBRACE, CHECK_OK); | 4413 Expect(Token::RBRACE, CHECK_OK); |
4617 scope->set_end_position(scanner().location().end_pos); | 4414 scope->set_end_position(scanner().location().end_pos); |
4618 } | 4415 } |
4619 | 4416 |
4620 // Validate strict mode. | 4417 // Validate strict mode. |
4621 if (!top_scope_->is_classic_mode()) { | 4418 if (!top_scope_->is_classic_mode()) { |
4622 if (IsEvalOrArguments(function_name)) { | 4419 if (IsEvalOrArguments(function_name)) { |
4623 int start_pos = scope->start_position(); | 4420 int start_pos = scope->start_position(); |
4624 int position = function_token_position != RelocInfo::kNoPosition | 4421 int position = function_token_position != RelocInfo::kNoPosition |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4670 CheckConflictingVarDeclarations(scope, CHECK_OK); | 4467 CheckConflictingVarDeclarations(scope, CHECK_OK); |
4671 } | 4468 } |
4672 | 4469 |
4673 FunctionLiteral* function_literal = | 4470 FunctionLiteral* function_literal = |
4674 factory()->NewFunctionLiteral(function_name, | 4471 factory()->NewFunctionLiteral(function_name, |
4675 scope, | 4472 scope, |
4676 body, | 4473 body, |
4677 materialized_literal_count, | 4474 materialized_literal_count, |
4678 expected_property_count, | 4475 expected_property_count, |
4679 handler_count, | 4476 handler_count, |
4680 only_simple_this_property_assignments, | |
4681 this_property_assignments, | |
4682 num_parameters, | 4477 num_parameters, |
4683 duplicate_parameters, | 4478 duplicate_parameters, |
4684 type, | 4479 type, |
4685 FunctionLiteral::kIsFunction, | 4480 FunctionLiteral::kIsFunction, |
4686 parenthesized, | 4481 parenthesized, |
4687 generator); | 4482 generator); |
4688 function_literal->set_function_token_position(function_token_position); | 4483 function_literal->set_function_token_position(function_token_position); |
4689 function_literal->set_ast_properties(&ast_properties); | 4484 function_literal->set_ast_properties(&ast_properties); |
4690 | 4485 |
4691 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal); | 4486 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal); |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6028 ASSERT(info()->isolate()->has_pending_exception()); | 5823 ASSERT(info()->isolate()->has_pending_exception()); |
6029 } else { | 5824 } else { |
6030 result = ParseProgram(); | 5825 result = ParseProgram(); |
6031 } | 5826 } |
6032 } | 5827 } |
6033 info()->SetFunction(result); | 5828 info()->SetFunction(result); |
6034 return (result != NULL); | 5829 return (result != NULL); |
6035 } | 5830 } |
6036 | 5831 |
6037 } } // namespace v8::internal | 5832 } } // namespace v8::internal |
OLD | NEW |