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 #if !defined(DART_PRECOMPILED_RUNTIME) |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 void Insert(KernelType* node, VmType* object) { map_[node] = object; } | 48 void Insert(KernelType* node, VmType* object) { map_[node] = object; } |
49 | 49 |
50 private: | 50 private: |
51 typedef typename std::map<KernelType*, VmType*> MapType; | 51 typedef typename std::map<KernelType*, VmType*> MapType; |
52 MapType map_; | 52 MapType map_; |
53 }; | 53 }; |
54 | 54 |
55 class KernelReader { | 55 class KernelReader { |
56 public: | 56 public: |
57 KernelReader(const uint8_t* buffer, intptr_t len) | 57 explicit KernelReader(Program* program); |
58 : thread_(dart::Thread::Current()), | |
59 zone_(thread_->zone()), | |
60 isolate_(thread_->isolate()), | |
61 scripts_(Array::ZoneHandle(zone_)), | |
62 program_(NULL), | |
63 translation_helper_(this, thread_, zone_, isolate_), | |
64 type_translator_(&translation_helper_, | |
65 &active_class_, | |
66 /*finalize=*/false), | |
67 buffer_(buffer), | |
68 buffer_length_(len) {} | |
69 | |
70 // Returns either pointer to a program or null. | |
71 Program* ReadPrecompiledProgram(); | |
72 | 58 |
73 // Returns either a library or a failure object. | 59 // Returns either a library or a failure object. |
74 dart::Object& ReadProgram(); | 60 dart::Object& ReadProgram(); |
75 | 61 |
76 static void SetupFunctionParameters(TranslationHelper translation_helper_, | 62 static void SetupFunctionParameters(TranslationHelper translation_helper_, |
77 DartTypeTranslator type_translator_, | 63 DartTypeTranslator type_translator_, |
78 const dart::Class& owner, | 64 const dart::Class& owner, |
79 const dart::Function& function, | 65 const dart::Function& function, |
80 FunctionNode* kernel_function, | 66 FunctionNode* kernel_function, |
81 bool is_method, | 67 bool is_method, |
(...skipping 23 matching lines...) Expand all Loading... |
105 Field* kernel_field); | 91 Field* kernel_field); |
106 | 92 |
107 void SetupFieldAccessorFunction(const dart::Class& klass, | 93 void SetupFieldAccessorFunction(const dart::Class& klass, |
108 const dart::Function& function); | 94 const dart::Function& function); |
109 | 95 |
110 dart::Library& LookupLibrary(Library* library); | 96 dart::Library& LookupLibrary(Library* library); |
111 dart::Class& LookupClass(Class* klass); | 97 dart::Class& LookupClass(Class* klass); |
112 | 98 |
113 dart::RawFunction::Kind GetFunctionType(Procedure* kernel_procedure); | 99 dart::RawFunction::Kind GetFunctionType(Procedure* kernel_procedure); |
114 | 100 |
| 101 Program* program_; |
| 102 |
115 dart::Thread* thread_; | 103 dart::Thread* thread_; |
116 dart::Zone* zone_; | 104 dart::Zone* zone_; |
117 dart::Isolate* isolate_; | 105 dart::Isolate* isolate_; |
118 Array& scripts_; | 106 Array& scripts_; |
119 Program* program_; | |
120 ActiveClass active_class_; | 107 ActiveClass active_class_; |
121 BuildingTranslationHelper translation_helper_; | 108 BuildingTranslationHelper translation_helper_; |
122 DartTypeTranslator type_translator_; | 109 DartTypeTranslator type_translator_; |
123 | 110 |
124 const uint8_t* buffer_; | |
125 intptr_t buffer_length_; | |
126 | |
127 Mapping<Library, dart::Library> libraries_; | 111 Mapping<Library, dart::Library> libraries_; |
128 Mapping<Class, dart::Class> classes_; | 112 Mapping<Class, dart::Class> classes_; |
129 }; | 113 }; |
130 | 114 |
131 } // namespace kernel | 115 } // namespace kernel |
132 } // namespace dart | 116 } // namespace dart |
133 | 117 |
134 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 118 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
135 #endif // RUNTIME_VM_KERNEL_READER_H_ | 119 #endif // RUNTIME_VM_KERNEL_READER_H_ |
OLD | NEW |