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 #ifndef RUNTIME_VM_KERNEL_READER_H_ | 5 #ifndef RUNTIME_VM_KERNEL_READER_H_ |
6 #define RUNTIME_VM_KERNEL_READER_H_ | 6 #define RUNTIME_VM_KERNEL_READER_H_ |
7 | 7 |
| 8 #if !defined(DART_PRECOMPILED_RUNTIME) |
8 #include <map> | 9 #include <map> |
9 | 10 |
10 #include "vm/kernel.h" | 11 #include "vm/kernel.h" |
11 #include "vm/kernel_to_il.h" | 12 #include "vm/kernel_to_il.h" |
12 #include "vm/object.h" | 13 #include "vm/object.h" |
13 | 14 |
14 namespace dart { | 15 namespace dart { |
15 namespace kernel { | 16 namespace kernel { |
16 | 17 |
17 class KernelReader; | 18 class KernelReader; |
18 | 19 |
19 class BuildingTranslationHelper : public TranslationHelper { | 20 class BuildingTranslationHelper : public TranslationHelper { |
20 public: | 21 public: |
21 BuildingTranslationHelper(KernelReader* reader, | 22 BuildingTranslationHelper(KernelReader* reader, |
22 dart::Thread* thread, | 23 dart::Thread* thread, |
23 dart::Zone* zone, | 24 dart::Zone* zone, |
24 Isolate* isolate) | 25 Isolate* isolate) |
25 : TranslationHelper(thread, zone, isolate), reader_(reader) {} | 26 : TranslationHelper(thread, zone, isolate), reader_(reader) {} |
26 virtual ~BuildingTranslationHelper() {} | 27 virtual ~BuildingTranslationHelper() {} |
27 | 28 |
28 virtual void SetFinalize(bool finalize); | |
29 | |
30 virtual RawLibrary* LookupLibraryByKernelLibrary(Library* library); | 29 virtual RawLibrary* LookupLibraryByKernelLibrary(Library* library); |
31 virtual RawClass* LookupClassByKernelClass(Class* klass); | 30 virtual RawClass* LookupClassByKernelClass(Class* klass); |
32 | 31 |
33 private: | 32 private: |
34 KernelReader* reader_; | 33 KernelReader* reader_; |
35 }; | 34 }; |
36 | 35 |
37 template <typename KernelType, typename VmType> | 36 template <typename KernelType, typename VmType> |
38 class Mapping { | 37 class Mapping { |
39 public: | 38 public: |
(...skipping 13 matching lines...) Expand all Loading... |
53 MapType map_; | 52 MapType map_; |
54 }; | 53 }; |
55 | 54 |
56 class KernelReader { | 55 class KernelReader { |
57 public: | 56 public: |
58 KernelReader(const uint8_t* buffer, intptr_t len, bool bootstrapping = false) | 57 KernelReader(const uint8_t* buffer, intptr_t len, bool bootstrapping = false) |
59 : thread_(dart::Thread::Current()), | 58 : thread_(dart::Thread::Current()), |
60 zone_(thread_->zone()), | 59 zone_(thread_->zone()), |
61 isolate_(thread_->isolate()), | 60 isolate_(thread_->isolate()), |
62 translation_helper_(this, thread_, zone_, isolate_), | 61 translation_helper_(this, thread_, zone_, isolate_), |
63 type_translator_(&translation_helper_, &active_class_, !bootstrapping), | 62 type_translator_(&translation_helper_, |
| 63 &active_class_, |
| 64 /*finalize=*/false), |
64 bootstrapping_(bootstrapping), | 65 bootstrapping_(bootstrapping), |
65 finalize_(!bootstrapping), | |
66 buffer_(buffer), | 66 buffer_(buffer), |
67 buffer_length_(len) {} | 67 buffer_length_(len) {} |
68 | 68 |
69 // Returns either a library or a failure object. | 69 // Returns either a library or a failure object. |
70 dart::Object& ReadProgram(); | 70 dart::Object& ReadProgram(); |
71 | 71 |
72 static void SetupFunctionParameters(TranslationHelper translation_helper_, | 72 static void SetupFunctionParameters(TranslationHelper translation_helper_, |
73 DartTypeTranslator type_translator_, | 73 DartTypeTranslator type_translator_, |
74 const dart::Class& owner, | 74 const dart::Class& owner, |
75 const dart::Function& function, | 75 const dart::Function& function, |
76 FunctionNode* kernel_function, | 76 FunctionNode* kernel_function, |
77 bool is_method, | 77 bool is_method, |
78 bool is_closure); | 78 bool is_closure); |
79 | 79 |
80 void ReadLibrary(Library* kernel_library); | 80 void ReadLibrary(Library* kernel_library); |
81 | 81 |
82 private: | 82 private: |
83 friend class BuildingTranslationHelper; | 83 friend class BuildingTranslationHelper; |
84 | 84 |
85 void ReadPreliminaryClass(dart::Class* klass, Class* kernel_klass); | 85 void ReadPreliminaryClass(dart::Class* klass, Class* kernel_klass); |
86 void ReadClass(const dart::Library& library, Class* kernel_klass); | 86 dart::Class& ReadClass(const dart::Library& library, Class* kernel_klass); |
87 void ReadProcedure(const dart::Library& library, | 87 void ReadProcedure(const dart::Library& library, |
88 const dart::Class& owner, | 88 const dart::Class& owner, |
89 Procedure* procedure, | 89 Procedure* procedure, |
90 Class* kernel_klass = NULL); | 90 Class* kernel_klass = NULL); |
91 | 91 |
92 void GenerateFieldAccessors(const dart::Class& klass, | 92 void GenerateFieldAccessors(const dart::Class& klass, |
93 const dart::Field& field, | 93 const dart::Field& field, |
94 Field* kernel_field); | 94 Field* kernel_field); |
95 | 95 |
96 void SetupFieldAccessorFunction(const dart::Class& klass, | 96 void SetupFieldAccessorFunction(const dart::Class& klass, |
97 const dart::Function& function); | 97 const dart::Function& function); |
98 | 98 |
99 dart::Library& LookupLibrary(Library* library); | 99 dart::Library& LookupLibrary(Library* library); |
100 dart::Class& LookupClass(Class* klass); | 100 dart::Class& LookupClass(Class* klass); |
101 | 101 |
102 dart::RawFunction::Kind GetFunctionType(Procedure* kernel_procedure); | 102 dart::RawFunction::Kind GetFunctionType(Procedure* kernel_procedure); |
103 | 103 |
104 dart::Thread* thread_; | 104 dart::Thread* thread_; |
105 dart::Zone* zone_; | 105 dart::Zone* zone_; |
106 dart::Isolate* isolate_; | 106 dart::Isolate* isolate_; |
107 ActiveClass active_class_; | 107 ActiveClass active_class_; |
108 BuildingTranslationHelper translation_helper_; | 108 BuildingTranslationHelper translation_helper_; |
109 DartTypeTranslator type_translator_; | 109 DartTypeTranslator type_translator_; |
110 | 110 |
111 bool bootstrapping_; | 111 bool bootstrapping_; |
112 | 112 |
113 // Should created classes be finalized when they are created? | |
114 bool finalize_; | |
115 | |
116 const uint8_t* buffer_; | 113 const uint8_t* buffer_; |
117 intptr_t buffer_length_; | 114 intptr_t buffer_length_; |
118 | 115 |
119 Mapping<Library, dart::Library> libraries_; | 116 Mapping<Library, dart::Library> libraries_; |
120 Mapping<Class, dart::Class> classes_; | 117 Mapping<Class, dart::Class> classes_; |
121 }; | 118 }; |
122 | 119 |
123 } // namespace kernel | 120 } // namespace kernel |
124 } // namespace dart | 121 } // namespace dart |
125 | 122 |
| 123 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
126 #endif // RUNTIME_VM_KERNEL_READER_H_ | 124 #endif // RUNTIME_VM_KERNEL_READER_H_ |
OLD | NEW |