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

Side by Side Diff: src/parsing/parser.cc

Issue 1479293002: Rename %_IsSpecObject to %_IsJSReceiver. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/parser.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/ast-literal-reindexer.h" 9 #include "src/ast/ast-literal-reindexer.h"
10 #include "src/ast/scopeinfo.h" 10 #include "src/ast/scopeinfo.h"
(...skipping 2836 matching lines...) Expand 10 before | Expand all | Expand 10 after
2847 2847
2848 if (IsSubclassConstructor(function_state_->kind())) { 2848 if (IsSubclassConstructor(function_state_->kind())) {
2849 // For subclass constructors we need to return this in case of undefined 2849 // For subclass constructors we need to return this in case of undefined
2850 // and throw an exception in case of a non object. 2850 // and throw an exception in case of a non object.
2851 // 2851 //
2852 // return expr; 2852 // return expr;
2853 // 2853 //
2854 // Is rewritten as: 2854 // Is rewritten as:
2855 // 2855 //
2856 // return (temp = expr) === undefined ? this : 2856 // return (temp = expr) === undefined ? this :
2857 // %_IsSpecObject(temp) ? temp : throw new TypeError(...); 2857 // %_IsJSReceiver(temp) ? temp : throw new TypeError(...);
2858 Variable* temp = scope_->NewTemporary( 2858 Variable* temp = scope_->NewTemporary(
2859 ast_value_factory()->empty_string()); 2859 ast_value_factory()->empty_string());
2860 Assignment* assign = factory()->NewAssignment( 2860 Assignment* assign = factory()->NewAssignment(
2861 Token::ASSIGN, factory()->NewVariableProxy(temp), return_value, pos); 2861 Token::ASSIGN, factory()->NewVariableProxy(temp), return_value, pos);
2862 2862
2863 Expression* throw_expression = 2863 Expression* throw_expression =
2864 NewThrowTypeError(MessageTemplate::kDerivedConstructorReturn, 2864 NewThrowTypeError(MessageTemplate::kDerivedConstructorReturn,
2865 ast_value_factory()->empty_string(), pos); 2865 ast_value_factory()->empty_string(), pos);
2866 2866
2867 // %_IsSpecObject(temp) 2867 // %_IsJSReceiver(temp)
2868 ZoneList<Expression*>* is_spec_object_args = 2868 ZoneList<Expression*>* is_spec_object_args =
2869 new (zone()) ZoneList<Expression*>(1, zone()); 2869 new (zone()) ZoneList<Expression*>(1, zone());
2870 is_spec_object_args->Add(factory()->NewVariableProxy(temp), zone()); 2870 is_spec_object_args->Add(factory()->NewVariableProxy(temp), zone());
2871 Expression* is_spec_object_call = factory()->NewCallRuntime( 2871 Expression* is_spec_object_call = factory()->NewCallRuntime(
2872 Runtime::kInlineIsSpecObject, is_spec_object_args, pos); 2872 Runtime::kInlineIsJSReceiver, is_spec_object_args, pos);
2873 2873
2874 // %_IsSpecObject(temp) ? temp : throw_expression 2874 // %_IsJSReceiver(temp) ? temp : throw_expression
2875 Expression* is_object_conditional = factory()->NewConditional( 2875 Expression* is_object_conditional = factory()->NewConditional(
2876 is_spec_object_call, factory()->NewVariableProxy(temp), 2876 is_spec_object_call, factory()->NewVariableProxy(temp),
2877 throw_expression, pos); 2877 throw_expression, pos);
2878 2878
2879 // temp === undefined 2879 // temp === undefined
2880 Expression* is_undefined = factory()->NewCompareOperation( 2880 Expression* is_undefined = factory()->NewCompareOperation(
2881 Token::EQ_STRICT, assign, 2881 Token::EQ_STRICT, assign,
2882 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), pos); 2882 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), pos);
2883 2883
2884 // is_undefined ? this : is_object_conditional 2884 // is_undefined ? this : is_object_conditional
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
3274 Expect(Token::LPAREN, CHECK_OK); 3274 Expect(Token::LPAREN, CHECK_OK);
3275 Expression* cond = ParseExpression(true, CHECK_OK); 3275 Expression* cond = ParseExpression(true, CHECK_OK);
3276 Expect(Token::RPAREN, CHECK_OK); 3276 Expect(Token::RPAREN, CHECK_OK);
3277 Statement* body = ParseSubStatement(NULL, CHECK_OK); 3277 Statement* body = ParseSubStatement(NULL, CHECK_OK);
3278 3278
3279 if (loop != NULL) loop->Initialize(cond, body); 3279 if (loop != NULL) loop->Initialize(cond, body);
3280 return loop; 3280 return loop;
3281 } 3281 }
3282 3282
3283 3283
3284 // !%_IsSpecObject(result = iterator.next()) && 3284 // !%_IsJSReceiver(result = iterator.next()) &&
3285 // %ThrowIteratorResultNotAnObject(result) 3285 // %ThrowIteratorResultNotAnObject(result)
3286 Expression* Parser::BuildIteratorNextResult(Expression* iterator, 3286 Expression* Parser::BuildIteratorNextResult(Expression* iterator,
3287 Variable* result, int pos) { 3287 Variable* result, int pos) {
3288 Expression* next_literal = factory()->NewStringLiteral( 3288 Expression* next_literal = factory()->NewStringLiteral(
3289 ast_value_factory()->next_string(), RelocInfo::kNoPosition); 3289 ast_value_factory()->next_string(), RelocInfo::kNoPosition);
3290 Expression* next_property = 3290 Expression* next_property =
3291 factory()->NewProperty(iterator, next_literal, RelocInfo::kNoPosition); 3291 factory()->NewProperty(iterator, next_literal, RelocInfo::kNoPosition);
3292 ZoneList<Expression*>* next_arguments = 3292 ZoneList<Expression*>* next_arguments =
3293 new (zone()) ZoneList<Expression*>(0, zone()); 3293 new (zone()) ZoneList<Expression*>(0, zone());
3294 Expression* next_call = 3294 Expression* next_call =
3295 factory()->NewCall(next_property, next_arguments, pos); 3295 factory()->NewCall(next_property, next_arguments, pos);
3296 Expression* result_proxy = factory()->NewVariableProxy(result); 3296 Expression* result_proxy = factory()->NewVariableProxy(result);
3297 Expression* left = 3297 Expression* left =
3298 factory()->NewAssignment(Token::ASSIGN, result_proxy, next_call, pos); 3298 factory()->NewAssignment(Token::ASSIGN, result_proxy, next_call, pos);
3299 3299
3300 // %_IsSpecObject(...) 3300 // %_IsJSReceiver(...)
3301 ZoneList<Expression*>* is_spec_object_args = 3301 ZoneList<Expression*>* is_spec_object_args =
3302 new (zone()) ZoneList<Expression*>(1, zone()); 3302 new (zone()) ZoneList<Expression*>(1, zone());
3303 is_spec_object_args->Add(left, zone()); 3303 is_spec_object_args->Add(left, zone());
3304 Expression* is_spec_object_call = factory()->NewCallRuntime( 3304 Expression* is_spec_object_call = factory()->NewCallRuntime(
3305 Runtime::kInlineIsSpecObject, is_spec_object_args, pos); 3305 Runtime::kInlineIsJSReceiver, is_spec_object_args, pos);
3306 3306
3307 // %ThrowIteratorResultNotAnObject(result) 3307 // %ThrowIteratorResultNotAnObject(result)
3308 Expression* result_proxy_again = factory()->NewVariableProxy(result); 3308 Expression* result_proxy_again = factory()->NewVariableProxy(result);
3309 ZoneList<Expression*>* throw_arguments = 3309 ZoneList<Expression*>* throw_arguments =
3310 new (zone()) ZoneList<Expression*>(1, zone()); 3310 new (zone()) ZoneList<Expression*>(1, zone());
3311 throw_arguments->Add(result_proxy_again, zone()); 3311 throw_arguments->Add(result_proxy_again, zone());
3312 Expression* throw_call = factory()->NewCallRuntime( 3312 Expression* throw_call = factory()->NewCallRuntime(
3313 Runtime::kThrowIteratorResultNotAnObject, throw_arguments, pos); 3313 Runtime::kThrowIteratorResultNotAnObject, throw_arguments, pos);
3314 3314
3315 return factory()->NewBinaryOperation( 3315 return factory()->NewBinaryOperation(
(...skipping 18 matching lines...) Expand all
3334 Expression* assign_iterator; 3334 Expression* assign_iterator;
3335 Expression* next_result; 3335 Expression* next_result;
3336 Expression* result_done; 3336 Expression* result_done;
3337 Expression* assign_each; 3337 Expression* assign_each;
3338 3338
3339 // iterator = subject[Symbol.iterator]() 3339 // iterator = subject[Symbol.iterator]()
3340 assign_iterator = factory()->NewAssignment( 3340 assign_iterator = factory()->NewAssignment(
3341 Token::ASSIGN, factory()->NewVariableProxy(iterator), 3341 Token::ASSIGN, factory()->NewVariableProxy(iterator),
3342 GetIterator(subject, factory()), subject->position()); 3342 GetIterator(subject, factory()), subject->position());
3343 3343
3344 // !%_IsSpecObject(result = iterator.next()) && 3344 // !%_IsJSReceiver(result = iterator.next()) &&
3345 // %ThrowIteratorResultNotAnObject(result) 3345 // %ThrowIteratorResultNotAnObject(result)
3346 { 3346 {
3347 // result = iterator.next() 3347 // result = iterator.next()
3348 Expression* iterator_proxy = factory()->NewVariableProxy(iterator); 3348 Expression* iterator_proxy = factory()->NewVariableProxy(iterator);
3349 next_result = 3349 next_result =
3350 BuildIteratorNextResult(iterator_proxy, result, subject->position()); 3350 BuildIteratorNextResult(iterator_proxy, result, subject->position());
3351 } 3351 }
3352 3352
3353 // result.done 3353 // result.done
3354 { 3354 {
(...skipping 3100 matching lines...) Expand 10 before | Expand all | Expand 10 after
6455 } 6455 }
6456 6456
6457 6457
6458 void Parser::RaiseLanguageMode(LanguageMode mode) { 6458 void Parser::RaiseLanguageMode(LanguageMode mode) {
6459 SetLanguageMode(scope_, 6459 SetLanguageMode(scope_,
6460 static_cast<LanguageMode>(scope_->language_mode() | mode)); 6460 static_cast<LanguageMode>(scope_->language_mode() | mode));
6461 } 6461 }
6462 6462
6463 } // namespace internal 6463 } // namespace internal
6464 } // namespace v8 6464 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698