| 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 |
| 11 #include "vm/kernel.h" | 11 #include "vm/kernel.h" |
| 12 #include "vm/kernel_to_il.h" | 12 #include "vm/kernel_to_il.h" |
| 13 #include "vm/object.h" | 13 #include "vm/object.h" |
| 14 | 14 |
| 15 namespace dart { | 15 namespace dart { |
| 16 namespace kernel { | 16 namespace kernel { |
| 17 | 17 |
| 18 class KernelReader; | 18 class KernelReader; |
| 19 | 19 |
| 20 class BuildingTranslationHelper : public TranslationHelper { | 20 class BuildingTranslationHelper : public TranslationHelper { |
| 21 public: | 21 public: |
| 22 BuildingTranslationHelper(KernelReader* reader, dart::Thread* thread) | 22 BuildingTranslationHelper(KernelReader* reader, dart::Thread* thread) |
| 23 : TranslationHelper(thread), reader_(reader) {} | 23 : TranslationHelper(thread), reader_(reader) {} |
| 24 virtual ~BuildingTranslationHelper() {} | 24 virtual ~BuildingTranslationHelper() {} |
| 25 | 25 |
| 26 virtual RawLibrary* LookupLibraryByKernelLibrary(CanonicalName* library); | 26 virtual RawLibrary* LookupLibraryByKernelLibrary(intptr_t library); |
| 27 virtual RawClass* LookupClassByKernelClass(CanonicalName* klass); | 27 virtual RawClass* LookupClassByKernelClass(intptr_t klass); |
| 28 | 28 |
| 29 private: | 29 private: |
| 30 KernelReader* reader_; | 30 KernelReader* reader_; |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 template <typename KernelType, typename VmType> | 33 template <typename VmType> |
| 34 class Mapping { | 34 class Mapping { |
| 35 public: | 35 public: |
| 36 bool Lookup(KernelType* node, VmType** handle) { | 36 bool Lookup(intptr_t canonical_name, VmType** handle) { |
| 37 typename MapType::Pair* pair = map_.LookupPair(node); | 37 typename MapType::Pair* pair = map_.LookupPair(canonical_name); |
| 38 if (pair != NULL) { | 38 if (pair != NULL) { |
| 39 *handle = pair->value; | 39 *handle = pair->value; |
| 40 return true; | 40 return true; |
| 41 } | 41 } |
| 42 return false; | 42 return false; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void Insert(KernelType* node, VmType* object) { map_.Insert(node, object); } | 45 void Insert(intptr_t canonical_name, VmType* object) { |
| 46 map_.Insert(canonical_name, object); |
| 47 } |
| 46 | 48 |
| 47 private: | 49 private: |
| 48 typedef MallocMap<KernelType, VmType*> MapType; | 50 typedef IntMap<VmType*> MapType; |
| 49 MapType map_; | 51 MapType map_; |
| 50 }; | 52 }; |
| 51 | 53 |
| 52 class KernelReader { | 54 class KernelReader { |
| 53 public: | 55 public: |
| 54 explicit KernelReader(Program* program); | 56 explicit KernelReader(Program* program); |
| 55 | 57 |
| 56 // Returns the library containing the main procedure, null if there | 58 // Returns the library containing the main procedure, null if there |
| 57 // was no main procedure, or a failure object if there was an error. | 59 // was no main procedure, or a failure object if there was an error. |
| 58 dart::Object& ReadProgram(); | 60 dart::Object& ReadProgram(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 intptr_t source_uri_index); | 96 intptr_t source_uri_index); |
| 95 Script& ScriptAt(intptr_t source_uri_index, intptr_t import_uri = -1); | 97 Script& ScriptAt(intptr_t source_uri_index, intptr_t import_uri = -1); |
| 96 | 98 |
| 97 void GenerateFieldAccessors(const dart::Class& klass, | 99 void GenerateFieldAccessors(const dart::Class& klass, |
| 98 const dart::Field& field, | 100 const dart::Field& field, |
| 99 Field* kernel_field); | 101 Field* kernel_field); |
| 100 | 102 |
| 101 void SetupFieldAccessorFunction(const dart::Class& klass, | 103 void SetupFieldAccessorFunction(const dart::Class& klass, |
| 102 const dart::Function& function); | 104 const dart::Function& function); |
| 103 | 105 |
| 104 dart::Library& LookupLibrary(CanonicalName* library); | 106 dart::Library& LookupLibrary(intptr_t library); |
| 105 dart::Class& LookupClass(CanonicalName* klass); | 107 dart::Class& LookupClass(intptr_t klass); |
| 106 | 108 |
| 107 dart::RawFunction::Kind GetFunctionType(Procedure* kernel_procedure); | 109 dart::RawFunction::Kind GetFunctionType(Procedure* kernel_procedure); |
| 108 | 110 |
| 109 Program* program_; | 111 Program* program_; |
| 110 | 112 |
| 111 dart::Thread* thread_; | 113 dart::Thread* thread_; |
| 112 dart::Zone* zone_; | 114 dart::Zone* zone_; |
| 113 dart::Isolate* isolate_; | 115 dart::Isolate* isolate_; |
| 114 Array& scripts_; | 116 Array& scripts_; |
| 115 ActiveClass active_class_; | 117 ActiveClass active_class_; |
| 116 BuildingTranslationHelper translation_helper_; | 118 BuildingTranslationHelper translation_helper_; |
| 117 DartTypeTranslator type_translator_; | 119 DartTypeTranslator type_translator_; |
| 118 | 120 |
| 119 Mapping<CanonicalName, dart::Library> libraries_; | 121 Mapping<dart::Library> libraries_; |
| 120 Mapping<CanonicalName, dart::Class> classes_; | 122 Mapping<dart::Class> classes_; |
| 121 | 123 |
| 122 GrowableArray<const dart::Function*> functions_; | 124 GrowableArray<const dart::Function*> functions_; |
| 123 GrowableArray<const dart::Field*> fields_; | 125 GrowableArray<const dart::Field*> fields_; |
| 124 }; | 126 }; |
| 125 | 127 |
| 126 } // namespace kernel | 128 } // namespace kernel |
| 127 } // namespace dart | 129 } // namespace dart |
| 128 | 130 |
| 129 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 131 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 130 #endif // RUNTIME_VM_KERNEL_READER_H_ | 132 #endif // RUNTIME_VM_KERNEL_READER_H_ |
| OLD | NEW |