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/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 Handle<ExternalTwoByteString>::cast(source), | 1059 Handle<ExternalTwoByteString>::cast(source), |
1060 shared_info->start_position(), shared_info->end_position())); | 1060 shared_info->start_position(), shared_info->end_position())); |
1061 } else if (source->IsExternalOneByteString()) { | 1061 } else if (source->IsExternalOneByteString()) { |
1062 stream.reset(new ExternalOneByteStringUtf16CharacterStream( | 1062 stream.reset(new ExternalOneByteStringUtf16CharacterStream( |
1063 Handle<ExternalOneByteString>::cast(source), | 1063 Handle<ExternalOneByteString>::cast(source), |
1064 shared_info->start_position(), shared_info->end_position())); | 1064 shared_info->start_position(), shared_info->end_position())); |
1065 } else { | 1065 } else { |
1066 stream.reset(new GenericStringUtf16CharacterStream( | 1066 stream.reset(new GenericStringUtf16CharacterStream( |
1067 source, shared_info->start_position(), shared_info->end_position())); | 1067 source, shared_info->start_position(), shared_info->end_position())); |
1068 } | 1068 } |
1069 result = ParseLazy(isolate, info, stream.get()); | 1069 result = DoParseLazy(isolate, info, stream.get()); |
1070 } | 1070 } |
1071 | 1071 |
1072 if (FLAG_trace_parse && result != NULL) { | 1072 if (FLAG_trace_parse && result != NULL) { |
1073 double ms = timer.Elapsed().InMillisecondsF(); | 1073 double ms = timer.Elapsed().InMillisecondsF(); |
1074 std::unique_ptr<char[]> name_chars = result->debug_name()->ToCString(); | 1074 std::unique_ptr<char[]> name_chars = result->debug_name()->ToCString(); |
1075 PrintF("[parsing function: %s - took %0.3f ms]\n", name_chars.get(), ms); | 1075 PrintF("[parsing function: %s - took %0.3f ms]\n", name_chars.get(), ms); |
1076 } | 1076 } |
1077 return result; | 1077 return result; |
1078 } | 1078 } |
1079 | 1079 |
1080 static FunctionLiteral::FunctionType ComputeFunctionType( | 1080 static FunctionLiteral::FunctionType ComputeFunctionType( |
1081 Handle<SharedFunctionInfo> shared_info) { | 1081 Handle<SharedFunctionInfo> shared_info) { |
1082 if (shared_info->is_declaration()) { | 1082 if (shared_info->is_declaration()) { |
1083 return FunctionLiteral::kDeclaration; | 1083 return FunctionLiteral::kDeclaration; |
1084 } else if (shared_info->is_named_expression()) { | 1084 } else if (shared_info->is_named_expression()) { |
1085 return FunctionLiteral::kNamedExpression; | 1085 return FunctionLiteral::kNamedExpression; |
1086 } else if (IsConciseMethod(shared_info->kind()) || | 1086 } else if (IsConciseMethod(shared_info->kind()) || |
1087 IsAccessorFunction(shared_info->kind())) { | 1087 IsAccessorFunction(shared_info->kind())) { |
1088 return FunctionLiteral::kAccessorOrMethod; | 1088 return FunctionLiteral::kAccessorOrMethod; |
1089 } | 1089 } |
1090 return FunctionLiteral::kAnonymousExpression; | 1090 return FunctionLiteral::kAnonymousExpression; |
1091 } | 1091 } |
1092 | 1092 |
1093 FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info, | 1093 FunctionLiteral* Parser::DoParseLazy(Isolate* isolate, ParseInfo* info, |
1094 Utf16CharacterStream* source) { | 1094 Utf16CharacterStream* source) { |
1095 Handle<SharedFunctionInfo> shared_info = info->shared_info(); | 1095 Handle<SharedFunctionInfo> shared_info = info->shared_info(); |
1096 scanner_.Initialize(source); | 1096 scanner_.Initialize(source); |
1097 DCHECK_NULL(scope_state_); | 1097 DCHECK_NULL(scope_state_); |
1098 DCHECK_NULL(target_stack_); | 1098 DCHECK_NULL(target_stack_); |
1099 | 1099 |
1100 Handle<String> name(String::cast(shared_info->name())); | 1100 Handle<String> name(String::cast(shared_info->name())); |
1101 DCHECK(ast_value_factory()); | 1101 DCHECK(ast_value_factory()); |
1102 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); | 1102 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); |
1103 const AstRawString* raw_name = ast_value_factory()->GetString(name); | 1103 const AstRawString* raw_name = ast_value_factory()->GetString(name); |
1104 fni_->PushEnclosingName(raw_name); | 1104 fni_->PushEnclosingName(raw_name); |
(...skipping 5982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7087 node->Print(Isolate::Current()); | 7087 node->Print(Isolate::Current()); |
7088 } | 7088 } |
7089 #endif // DEBUG | 7089 #endif // DEBUG |
7090 | 7090 |
7091 #undef CHECK_OK | 7091 #undef CHECK_OK |
7092 #undef CHECK_OK_VOID | 7092 #undef CHECK_OK_VOID |
7093 #undef CHECK_FAILED | 7093 #undef CHECK_FAILED |
7094 | 7094 |
7095 } // namespace internal | 7095 } // namespace internal |
7096 } // namespace v8 | 7096 } // namespace v8 |
OLD | NEW |