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

Side by Side Diff: src/parser.cc

Issue 929733003: for-of should throw if result object is not an object (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add strings and move runtime function Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ast-value-factory.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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 2907 matching lines...) Expand 10 before | Expand all | Expand 10 after
2918 Variable* iterator = scope_->DeclarationScope()->NewTemporary( 2918 Variable* iterator = scope_->DeclarationScope()->NewTemporary(
2919 ast_value_factory()->dot_iterator_string()); 2919 ast_value_factory()->dot_iterator_string());
2920 Variable* result = scope_->DeclarationScope()->NewTemporary( 2920 Variable* result = scope_->DeclarationScope()->NewTemporary(
2921 ast_value_factory()->dot_result_string()); 2921 ast_value_factory()->dot_result_string());
2922 2922
2923 Expression* assign_iterator; 2923 Expression* assign_iterator;
2924 Expression* next_result; 2924 Expression* next_result;
2925 Expression* result_done; 2925 Expression* result_done;
2926 Expression* assign_each; 2926 Expression* assign_each;
2927 2927
2928 // var iterator = subject[Symbol.iterator](); 2928 // iterator = subject[Symbol.iterator]()
2929 assign_iterator = factory()->NewAssignment( 2929 assign_iterator = factory()->NewAssignment(
2930 Token::ASSIGN, factory()->NewVariableProxy(iterator), 2930 Token::ASSIGN, factory()->NewVariableProxy(iterator),
2931 GetIterator(subject, factory()), subject->position()); 2931 GetIterator(subject, factory()), subject->position());
2932 2932
2933 // var result = iterator.next(); 2933 // !%_IsSpecObject(result = iterator.next()) &&
2934 // %ThrowIteratorResultNotAnObject(result)
2934 { 2935 {
2936 // result = iterator.next()
2935 Expression* iterator_proxy = factory()->NewVariableProxy(iterator); 2937 Expression* iterator_proxy = factory()->NewVariableProxy(iterator);
2936 Expression* next_literal = factory()->NewStringLiteral( 2938 Expression* next_literal = factory()->NewStringLiteral(
2937 ast_value_factory()->next_string(), RelocInfo::kNoPosition); 2939 ast_value_factory()->next_string(), RelocInfo::kNoPosition);
2938 Expression* next_property = factory()->NewProperty( 2940 Expression* next_property = factory()->NewProperty(
2939 iterator_proxy, next_literal, RelocInfo::kNoPosition); 2941 iterator_proxy, next_literal, RelocInfo::kNoPosition);
2940 ZoneList<Expression*>* next_arguments = 2942 ZoneList<Expression*>* next_arguments =
2941 new(zone()) ZoneList<Expression*>(0, zone()); 2943 new (zone()) ZoneList<Expression*>(0, zone());
2942 Expression* next_call = factory()->NewCall(next_property, next_arguments, 2944 Expression* next_call = factory()->NewCall(next_property, next_arguments,
2943 subject->position()); 2945 subject->position());
2944 Expression* result_proxy = factory()->NewVariableProxy(result); 2946 Expression* result_proxy = factory()->NewVariableProxy(result);
2945 next_result = factory()->NewAssignment(Token::ASSIGN, result_proxy, 2947 next_result = factory()->NewAssignment(Token::ASSIGN, result_proxy,
2946 next_call, subject->position()); 2948 next_call, subject->position());
2949
2950 // %_IsSpecObject(...)
2951 ZoneList<Expression*>* is_spec_object_args =
2952 new (zone()) ZoneList<Expression*>(1, zone());
2953 is_spec_object_args->Add(next_result, zone());
2954 Expression* is_spec_object_call = factory()->NewCallRuntime(
2955 ast_value_factory()->is_spec_object_string(),
2956 Runtime::FunctionForId(Runtime::kInlineIsSpecObject),
2957 is_spec_object_args, subject->position());
2958
2959 // %ThrowIteratorResultNotAnObject(result)
2960 Expression* result_proxy_again = factory()->NewVariableProxy(result);
2961 ZoneList<Expression*>* throw_arguments =
2962 new (zone()) ZoneList<Expression*>(1, zone());
2963 throw_arguments->Add(result_proxy_again, zone());
2964 Expression* throw_call = factory()->NewCallRuntime(
2965 ast_value_factory()->throw_iterator_result_not_an_object_string(),
2966 Runtime::FunctionForId(Runtime::kThrowIteratorResultNotAnObject),
2967 throw_arguments, subject->position());
2968
2969 next_result = factory()->NewBinaryOperation(
2970 Token::AND, factory()->NewUnaryOperation(
2971 Token::NOT, is_spec_object_call, subject->position()),
2972 throw_call, subject->position());
2947 } 2973 }
2948 2974
2949 // result.done 2975 // result.done
2950 { 2976 {
2951 Expression* done_literal = factory()->NewStringLiteral( 2977 Expression* done_literal = factory()->NewStringLiteral(
2952 ast_value_factory()->done_string(), RelocInfo::kNoPosition); 2978 ast_value_factory()->done_string(), RelocInfo::kNoPosition);
2953 Expression* result_proxy = factory()->NewVariableProxy(result); 2979 Expression* result_proxy = factory()->NewVariableProxy(result);
2954 result_done = factory()->NewProperty( 2980 result_done = factory()->NewProperty(
2955 result_proxy, done_literal, RelocInfo::kNoPosition); 2981 result_proxy, done_literal, RelocInfo::kNoPosition);
2956 } 2982 }
(...skipping 2506 matching lines...) Expand 10 before | Expand all | Expand 10 after
5463 } else { 5489 } else {
5464 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); 5490 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data());
5465 running_hash = StringHasher::ComputeRunningHash(running_hash, data, 5491 running_hash = StringHasher::ComputeRunningHash(running_hash, data,
5466 raw_string->length()); 5492 raw_string->length());
5467 } 5493 }
5468 } 5494 }
5469 5495
5470 return running_hash; 5496 return running_hash;
5471 } 5497 }
5472 } } // namespace v8::internal 5498 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast-value-factory.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698