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