| OLD | NEW |
| 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 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 return factory->NewNullLiteral(pos); | 800 return factory->NewNullLiteral(pos); |
| 801 case Token::TRUE_LITERAL: | 801 case Token::TRUE_LITERAL: |
| 802 return factory->NewBooleanLiteral(true, pos); | 802 return factory->NewBooleanLiteral(true, pos); |
| 803 case Token::FALSE_LITERAL: | 803 case Token::FALSE_LITERAL: |
| 804 return factory->NewBooleanLiteral(false, pos); | 804 return factory->NewBooleanLiteral(false, pos); |
| 805 case Token::SMI: { | 805 case Token::SMI: { |
| 806 int value = scanner->smi_value(); | 806 int value = scanner->smi_value(); |
| 807 return factory->NewSmiLiteral(value, pos); | 807 return factory->NewSmiLiteral(value, pos); |
| 808 } | 808 } |
| 809 case Token::NUMBER: { | 809 case Token::NUMBER: { |
| 810 bool is_float = scanner->IsFloat(); |
| 810 double value = scanner->DoubleValue(); | 811 double value = scanner->DoubleValue(); |
| 811 return factory->NewNumberLiteral(value, pos); | 812 return factory->NewNumberLiteral(value, pos, is_float); |
| 812 } | 813 } |
| 813 default: | 814 default: |
| 814 DCHECK(false); | 815 DCHECK(false); |
| 815 } | 816 } |
| 816 return NULL; | 817 return NULL; |
| 817 } | 818 } |
| 818 | 819 |
| 819 | 820 |
| 820 Expression* ParserTraits::ExpressionFromIdentifier(const AstRawString* name, | 821 Expression* ParserTraits::ExpressionFromIdentifier(const AstRawString* name, |
| 821 int start_position, | 822 int start_position, |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 info->closure()->context(), scope); | 1155 info->closure()->context(), scope); |
| 1155 } | 1156 } |
| 1156 original_scope_ = scope; | 1157 original_scope_ = scope; |
| 1157 AstNodeFactory function_factory(ast_value_factory()); | 1158 AstNodeFactory function_factory(ast_value_factory()); |
| 1158 FunctionState function_state(&function_state_, &scope_, scope, | 1159 FunctionState function_state(&function_state_, &scope_, scope, |
| 1159 shared_info->kind(), &function_factory); | 1160 shared_info->kind(), &function_factory); |
| 1160 DCHECK(is_sloppy(scope->language_mode()) || | 1161 DCHECK(is_sloppy(scope->language_mode()) || |
| 1161 is_strict(info->language_mode())); | 1162 is_strict(info->language_mode())); |
| 1162 DCHECK(info->language_mode() == shared_info->language_mode()); | 1163 DCHECK(info->language_mode() == shared_info->language_mode()); |
| 1163 scope->SetLanguageMode(shared_info->language_mode()); | 1164 scope->SetLanguageMode(shared_info->language_mode()); |
| 1165 scope->SetAsmMode(shared_info->asm_mode()); |
| 1164 FunctionLiteral::FunctionType function_type = shared_info->is_expression() | 1166 FunctionLiteral::FunctionType function_type = shared_info->is_expression() |
| 1165 ? (shared_info->is_anonymous() | 1167 ? (shared_info->is_anonymous() |
| 1166 ? FunctionLiteral::ANONYMOUS_EXPRESSION | 1168 ? FunctionLiteral::ANONYMOUS_EXPRESSION |
| 1167 : FunctionLiteral::NAMED_EXPRESSION) | 1169 : FunctionLiteral::NAMED_EXPRESSION) |
| 1168 : FunctionLiteral::DECLARATION; | 1170 : FunctionLiteral::DECLARATION; |
| 1169 bool ok = true; | 1171 bool ok = true; |
| 1170 | 1172 |
| 1171 if (shared_info->is_arrow()) { | 1173 if (shared_info->is_arrow()) { |
| 1172 Scope* scope = | 1174 Scope* scope = |
| 1173 NewScope(scope_, ARROW_SCOPE, FunctionKind::kArrowFunction); | 1175 NewScope(scope_, ARROW_SCOPE, FunctionKind::kArrowFunction); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 // regress/regress-crbug-135066.js to fail. | 1321 // regress/regress-crbug-135066.js to fail. |
| 1320 if (scope_->is_eval_scope()) mode_ = PARSE_EAGERLY; | 1322 if (scope_->is_eval_scope()) mode_ = PARSE_EAGERLY; |
| 1321 } else if (literal->raw_value()->AsString() == | 1323 } else if (literal->raw_value()->AsString() == |
| 1322 ast_value_factory()->use_asm_string() && | 1324 ast_value_factory()->use_asm_string() && |
| 1323 token_loc.end_pos - token_loc.beg_pos == | 1325 token_loc.end_pos - token_loc.beg_pos == |
| 1324 ast_value_factory()->use_asm_string()->length() + 2) { | 1326 ast_value_factory()->use_asm_string()->length() + 2) { |
| 1325 // Store the usage count; The actual use counter on the isolate is | 1327 // Store the usage count; The actual use counter on the isolate is |
| 1326 // incremented after parsing is done. | 1328 // incremented after parsing is done. |
| 1327 ++use_counts_[v8::Isolate::kUseAsm]; | 1329 ++use_counts_[v8::Isolate::kUseAsm]; |
| 1328 scope_->SetAsmModule(); | 1330 scope_->SetAsmModule(); |
| 1331 scope_->SetAsmMode(ASM_MODULE); |
| 1329 } | 1332 } |
| 1330 } else { | 1333 } else { |
| 1331 // End of the directive prologue. | 1334 // End of the directive prologue. |
| 1332 directive_prologue = false; | 1335 directive_prologue = false; |
| 1333 } | 1336 } |
| 1334 } | 1337 } |
| 1335 | 1338 |
| 1336 body->Add(stat, zone()); | 1339 body->Add(stat, zone()); |
| 1337 } | 1340 } |
| 1338 | 1341 |
| (...skipping 2805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4144 } | 4147 } |
| 4145 if (logger.calls_eval()) { | 4148 if (logger.calls_eval()) { |
| 4146 scope_->RecordEvalCall(); | 4149 scope_->RecordEvalCall(); |
| 4147 } | 4150 } |
| 4148 if (produce_cached_parse_data()) { | 4151 if (produce_cached_parse_data()) { |
| 4149 DCHECK(log_); | 4152 DCHECK(log_); |
| 4150 // Position right after terminal '}'. | 4153 // Position right after terminal '}'. |
| 4151 int body_end = scanner()->location().end_pos; | 4154 int body_end = scanner()->location().end_pos; |
| 4152 log_->LogFunction(function_block_pos, body_end, *materialized_literal_count, | 4155 log_->LogFunction(function_block_pos, body_end, *materialized_literal_count, |
| 4153 *expected_property_count, scope_->language_mode(), | 4156 *expected_property_count, scope_->language_mode(), |
| 4157 scope_->asm_mode(), |
| 4154 scope_->uses_super_property(), scope_->calls_eval()); | 4158 scope_->uses_super_property(), scope_->calls_eval()); |
| 4155 } | 4159 } |
| 4156 } | 4160 } |
| 4157 | 4161 |
| 4158 | 4162 |
| 4159 void Parser::AddAssertIsConstruct(ZoneList<Statement*>* body, int pos) { | 4163 void Parser::AddAssertIsConstruct(ZoneList<Statement*>* body, int pos) { |
| 4160 ZoneList<Expression*>* arguments = | 4164 ZoneList<Expression*>* arguments = |
| 4161 new (zone()) ZoneList<Expression*>(0, zone()); | 4165 new (zone()) ZoneList<Expression*>(0, zone()); |
| 4162 CallRuntime* construct_check = factory()->NewCallRuntime( | 4166 CallRuntime* construct_check = factory()->NewCallRuntime( |
| 4163 ast_value_factory()->is_construct_call_string(), | 4167 ast_value_factory()->is_construct_call_string(), |
| (...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5822 Expression* Parser::SpreadCallNew(Expression* function, | 5826 Expression* Parser::SpreadCallNew(Expression* function, |
| 5823 ZoneList<v8::internal::Expression*>* args, | 5827 ZoneList<v8::internal::Expression*>* args, |
| 5824 int pos) { | 5828 int pos) { |
| 5825 args->InsertAt(0, function, zone()); | 5829 args->InsertAt(0, function, zone()); |
| 5826 | 5830 |
| 5827 return factory()->NewCallRuntime( | 5831 return factory()->NewCallRuntime( |
| 5828 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 5832 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
| 5829 } | 5833 } |
| 5830 } // namespace internal | 5834 } // namespace internal |
| 5831 } // namespace v8 | 5835 } // namespace v8 |
| OLD | NEW |