Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: runtime/vm/kernel_reader.h

Issue 2860823002: Introduce classes for string and name indexes (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/kernel_binary_flowgraph.cc ('k') | runtime/vm/kernel_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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(intptr_t library); 26 virtual RawLibrary* LookupLibraryByKernelLibrary(NameIndex library);
27 virtual RawClass* LookupClassByKernelClass(intptr_t klass); 27 virtual RawClass* LookupClassByKernelClass(NameIndex klass);
28 28
29 private: 29 private:
30 KernelReader* reader_; 30 KernelReader* reader_;
31 }; 31 };
32 32
33 template <typename VmType> 33 template <typename VmType>
34 class Mapping { 34 class Mapping {
35 public: 35 public:
36 bool Lookup(intptr_t canonical_name, VmType** handle) { 36 bool Lookup(intptr_t canonical_name, VmType** handle) {
37 typename MapType::Pair* pair = map_.LookupPair(canonical_name); 37 typename MapType::Pair* pair = map_.LookupPair(canonical_name);
(...skipping 24 matching lines...) Expand all
62 static void SetupFunctionParameters(TranslationHelper translation_helper_, 62 static void SetupFunctionParameters(TranslationHelper translation_helper_,
63 DartTypeTranslator type_translator_, 63 DartTypeTranslator type_translator_,
64 const dart::Class& owner, 64 const dart::Class& owner,
65 const dart::Function& function, 65 const dart::Function& function,
66 FunctionNode* kernel_function, 66 FunctionNode* kernel_function,
67 bool is_method, 67 bool is_method,
68 bool is_closure); 68 bool is_closure);
69 69
70 void ReadLibrary(Library* kernel_library); 70 void ReadLibrary(Library* kernel_library);
71 71
72 const dart::String& DartSymbol(intptr_t string_index) { 72 const dart::String& DartSymbol(StringIndex index) {
73 return translation_helper_.DartSymbol(string_index); 73 return translation_helper_.DartSymbol(index);
74 } 74 }
75 75
76 uint8_t CharacterAt(intptr_t string_index, intptr_t index); 76 uint8_t CharacterAt(StringIndex string_index, intptr_t index);
77 77
78 private: 78 private:
79 friend class BuildingTranslationHelper; 79 friend class BuildingTranslationHelper;
80 80
81 void ReadPreliminaryClass(dart::Class* klass, Class* kernel_klass); 81 void ReadPreliminaryClass(dart::Class* klass, Class* kernel_klass);
82 dart::Class& ReadClass(const dart::Library& library, 82 dart::Class& ReadClass(const dart::Library& library,
83 const dart::Class& toplevel_class, 83 const dart::Class& toplevel_class,
84 Class* kernel_klass); 84 Class* kernel_klass);
85 void ReadProcedure(const dart::Library& library, 85 void ReadProcedure(const dart::Library& library,
86 const dart::Class& owner, 86 const dart::Class& owner,
87 Procedure* procedure, 87 Procedure* procedure,
88 Class* kernel_klass = NULL); 88 Class* kernel_klass = NULL);
89 89
90 RawArray* MakeFunctionsArray(); 90 RawArray* MakeFunctionsArray();
91 91
92 // If klass's script is not the script at the uri index, return a PatchClass 92 // If klass's script is not the script at the uri index, return a PatchClass
93 // for klass whose script corresponds to the uri index. 93 // for klass whose script corresponds to the uri index.
94 // Otherwise return klass. 94 // Otherwise return klass.
95 const Object& ClassForScriptAt(const dart::Class& klass, 95 const Object& ClassForScriptAt(const dart::Class& klass,
96 intptr_t source_uri_index); 96 intptr_t source_uri_index);
97 Script& ScriptAt(intptr_t source_uri_index, intptr_t import_uri = -1); 97 Script& ScriptAt(intptr_t source_uri_index,
98 StringIndex import_uri = StringIndex());
98 99
99 void GenerateFieldAccessors(const dart::Class& klass, 100 void GenerateFieldAccessors(const dart::Class& klass,
100 const dart::Field& field, 101 const dart::Field& field,
101 Field* kernel_field); 102 Field* kernel_field);
102 103
103 void SetupFieldAccessorFunction(const dart::Class& klass, 104 void SetupFieldAccessorFunction(const dart::Class& klass,
104 const dart::Function& function); 105 const dart::Function& function);
105 106
106 dart::Library& LookupLibrary(intptr_t library); 107 dart::Library& LookupLibrary(NameIndex library);
107 dart::Class& LookupClass(intptr_t klass); 108 dart::Class& LookupClass(NameIndex klass);
108 109
109 dart::RawFunction::Kind GetFunctionType(Procedure* kernel_procedure); 110 dart::RawFunction::Kind GetFunctionType(Procedure* kernel_procedure);
110 111
111 Program* program_; 112 Program* program_;
112 113
113 dart::Thread* thread_; 114 dart::Thread* thread_;
114 dart::Zone* zone_; 115 dart::Zone* zone_;
115 dart::Isolate* isolate_; 116 dart::Isolate* isolate_;
116 Array& scripts_; 117 Array& scripts_;
117 ActiveClass active_class_; 118 ActiveClass active_class_;
118 BuildingTranslationHelper translation_helper_; 119 BuildingTranslationHelper translation_helper_;
119 DartTypeTranslator type_translator_; 120 DartTypeTranslator type_translator_;
120 121
121 Mapping<dart::Library> libraries_; 122 Mapping<dart::Library> libraries_;
122 Mapping<dart::Class> classes_; 123 Mapping<dart::Class> classes_;
123 124
124 GrowableArray<const dart::Function*> functions_; 125 GrowableArray<const dart::Function*> functions_;
125 GrowableArray<const dart::Field*> fields_; 126 GrowableArray<const dart::Field*> fields_;
126 }; 127 };
127 128
128 } // namespace kernel 129 } // namespace kernel
129 } // namespace dart 130 } // namespace dart
130 131
131 #endif // !defined(DART_PRECOMPILED_RUNTIME) 132 #endif // !defined(DART_PRECOMPILED_RUNTIME)
132 #endif // RUNTIME_VM_KERNEL_READER_H_ 133 #endif // RUNTIME_VM_KERNEL_READER_H_
OLDNEW
« no previous file with comments | « runtime/vm/kernel_binary_flowgraph.cc ('k') | runtime/vm/kernel_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698