| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/kernel_reader.h" | 5 #include "vm/kernel_reader.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/kernel_binary.h" | 10 #include "vm/kernel_binary.h" |
| 11 #include "vm/kernel_binary_flowgraph.h" | 11 #include "vm/kernel_binary_flowgraph.h" |
| 12 #include "vm/kernel_to_il.h" |
| 12 #include "vm/longjump.h" | 13 #include "vm/longjump.h" |
| 13 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
| 14 #include "vm/parser.h" | 15 #include "vm/parser.h" |
| 15 #include "vm/symbols.h" | 16 #include "vm/symbols.h" |
| 16 | 17 |
| 17 #if !defined(DART_PRECOMPILED_RUNTIME) | 18 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 18 namespace dart { | 19 namespace dart { |
| 19 namespace kernel { | 20 namespace kernel { |
| 20 | 21 |
| 21 #define Z (zone_) | 22 #define Z (zone_) |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 }; | 875 }; |
| 875 intptr_t kind = static_cast<int>(procedure_kind); | 876 intptr_t kind = static_cast<int>(procedure_kind); |
| 876 if (kind == Procedure::kIncompleteProcedure) { | 877 if (kind == Procedure::kIncompleteProcedure) { |
| 877 return RawFunction::kSignatureFunction; | 878 return RawFunction::kSignatureFunction; |
| 878 } else { | 879 } else { |
| 879 ASSERT(0 <= kind && kind <= Procedure::kFactory); | 880 ASSERT(0 <= kind && kind <= Procedure::kFactory); |
| 880 return static_cast<RawFunction::Kind>(lookuptable[kind]); | 881 return static_cast<RawFunction::Kind>(lookuptable[kind]); |
| 881 } | 882 } |
| 882 } | 883 } |
| 883 | 884 |
| 885 bool KernelReader::FieldHasFunctionLiteralInitializer(const dart::Field& field, |
| 886 TokenPosition* start, |
| 887 TokenPosition* end) { |
| 888 dart::Zone* zone = Thread::Current()->zone(); |
| 889 const Script& script = Script::Handle(zone, field.Script()); |
| 890 |
| 891 TranslationHelper translation_helper( |
| 892 Thread::Current(), script.kernel_string_offsets(), |
| 893 script.kernel_string_data(), script.kernel_canonical_names()); |
| 894 |
| 895 kernel::StreamingFlowGraphBuilder* builder = |
| 896 new kernel::StreamingFlowGraphBuilder(&translation_helper, zone, |
| 897 script.kernel_data(), |
| 898 script.kernel_data_size()); |
| 899 |
| 900 kernel::FieldHelper field_helper(builder, field.kernel_offset()); |
| 901 field_helper.ReadUntilExcluding(kernel::FieldHelper::kEnd, true); |
| 902 bool result = field_helper.FieldHasFunctionLiteralInitializer(start, end); |
| 903 |
| 904 delete builder; |
| 905 return result; |
| 906 } |
| 907 |
| 884 ParsedFunction* ParseStaticFieldInitializer(Zone* zone, | 908 ParsedFunction* ParseStaticFieldInitializer(Zone* zone, |
| 885 const dart::Field& field) { | 909 const dart::Field& field) { |
| 886 Thread* thread = Thread::Current(); | 910 Thread* thread = Thread::Current(); |
| 887 | 911 |
| 888 dart::String& init_name = dart::String::Handle(zone, field.name()); | 912 dart::String& init_name = dart::String::Handle(zone, field.name()); |
| 889 init_name = Symbols::FromConcat(thread, Symbols::InitPrefix(), init_name); | 913 init_name = Symbols::FromConcat(thread, Symbols::InitPrefix(), init_name); |
| 890 | 914 |
| 891 // Create a static initializer. | 915 // Create a static initializer. |
| 892 const Object& owner = Object::Handle(field.RawOwner()); | 916 const Object& owner = Object::Handle(field.RawOwner()); |
| 893 const Function& initializer_fun = Function::ZoneHandle( | 917 const Function& initializer_fun = Function::ZoneHandle( |
| 894 zone, | 918 zone, |
| 895 dart::Function::New(init_name, RawFunction::kImplicitStaticFinalGetter, | 919 dart::Function::New(init_name, RawFunction::kImplicitStaticFinalGetter, |
| 896 true, // is_static | 920 true, // is_static |
| 897 false, // is_const | 921 false, // is_const |
| 898 false, // is_abstract | 922 false, // is_abstract |
| 899 false, // is_external | 923 false, // is_external |
| 900 false, // is_native | 924 false, // is_native |
| 901 owner, TokenPosition::kNoSource)); | 925 owner, TokenPosition::kNoSource)); |
| 902 initializer_fun.set_kernel_offset(field.kernel_offset()); | 926 initializer_fun.set_kernel_offset(field.kernel_offset()); |
| 903 initializer_fun.set_result_type(AbstractType::Handle(zone, field.type())); | 927 initializer_fun.set_result_type(AbstractType::Handle(zone, field.type())); |
| 904 initializer_fun.set_is_debuggable(false); | 928 initializer_fun.set_is_debuggable(false); |
| 905 initializer_fun.set_is_reflectable(false); | 929 initializer_fun.set_is_reflectable(false); |
| 906 initializer_fun.set_is_inlinable(false); | 930 initializer_fun.set_is_inlinable(false); |
| 907 return new (zone) ParsedFunction(thread, initializer_fun); | 931 return new (zone) ParsedFunction(thread, initializer_fun); |
| 908 } | 932 } |
| 909 | 933 |
| 910 } // namespace kernel | 934 } // namespace kernel |
| 911 } // namespace dart | 935 } // namespace dart |
| 912 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 936 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |