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_H_ | 5 #ifndef RUNTIME_VM_KERNEL_H_ |
6 #define RUNTIME_VM_KERNEL_H_ | 6 #define RUNTIME_VM_KERNEL_H_ |
7 | 7 |
8 #if !defined(DART_PRECOMPILED_RUNTIME) | 8 #if !defined(DART_PRECOMPILED_RUNTIME) |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
11 #include "vm/globals.h" | 11 #include "vm/globals.h" |
12 #include "vm/growable_array.h" | 12 #include "vm/growable_array.h" |
13 #include "vm/token_position.h" | 13 #include "vm/token_position.h" |
14 | 14 |
15 | |
16 namespace dart { | 15 namespace dart { |
17 | 16 |
18 class Field; | 17 class Field; |
19 class ParsedFunction; | 18 class ParsedFunction; |
20 class Zone; | 19 class Zone; |
21 | 20 |
22 namespace kernel { | 21 namespace kernel { |
23 | 22 |
24 | |
25 class Reader; | 23 class Reader; |
26 | 24 |
27 | |
28 class StringIndex { | 25 class StringIndex { |
29 public: | 26 public: |
30 StringIndex() : value_(-1) {} | 27 StringIndex() : value_(-1) {} |
31 explicit StringIndex(int value) : value_(value) {} | 28 explicit StringIndex(int value) : value_(value) {} |
32 | 29 |
33 operator int() const { return value_; } | 30 operator int() const { return value_; } |
34 | 31 |
35 private: | 32 private: |
36 int value_; | 33 int value_; |
37 }; | 34 }; |
38 | 35 |
39 | |
40 class NameIndex { | 36 class NameIndex { |
41 public: | 37 public: |
42 NameIndex() : value_(-1) {} | 38 NameIndex() : value_(-1) {} |
43 explicit NameIndex(int value) : value_(value) {} | 39 explicit NameIndex(int value) : value_(value) {} |
44 | 40 |
45 operator int() const { return value_; } | 41 operator int() const { return value_; } |
46 | 42 |
47 private: | 43 private: |
48 int value_; | 44 int value_; |
49 }; | 45 }; |
50 | 46 |
51 | |
52 class Field { | 47 class Field { |
53 public: | 48 public: |
54 enum Flags { | 49 enum Flags { |
55 kFlagFinal = 1 << 0, | 50 kFlagFinal = 1 << 0, |
56 kFlagConst = 1 << 1, | 51 kFlagConst = 1 << 1, |
57 kFlagStatic = 1 << 2, | 52 kFlagStatic = 1 << 2, |
58 }; | 53 }; |
59 }; | 54 }; |
60 | 55 |
61 | |
62 class Constructor { | 56 class Constructor { |
63 public: | 57 public: |
64 enum Flags { | 58 enum Flags { |
65 kFlagConst = 1 << 0, | 59 kFlagConst = 1 << 0, |
66 kFlagExternal = 1 << 1, | 60 kFlagExternal = 1 << 1, |
67 }; | 61 }; |
68 }; | 62 }; |
69 | 63 |
70 | |
71 class Procedure { | 64 class Procedure { |
72 public: | 65 public: |
73 enum Flags { | 66 enum Flags { |
74 kFlagStatic = 1 << 0, | 67 kFlagStatic = 1 << 0, |
75 kFlagAbstract = 1 << 1, | 68 kFlagAbstract = 1 << 1, |
76 kFlagExternal = 1 << 2, | 69 kFlagExternal = 1 << 2, |
77 kFlagConst = 1 << 3, // Only for external const factories. | 70 kFlagConst = 1 << 3, // Only for external const factories. |
78 }; | 71 }; |
79 | 72 |
80 // Keep in sync with package:dynamo/lib/ast.dart:ProcedureKind | 73 // Keep in sync with package:dynamo/lib/ast.dart:ProcedureKind |
81 enum ProcedureKind { | 74 enum ProcedureKind { |
82 kMethod, | 75 kMethod, |
83 kGetter, | 76 kGetter, |
84 kSetter, | 77 kSetter, |
85 kOperator, | 78 kOperator, |
86 kFactory, | 79 kFactory, |
87 | 80 |
88 kIncompleteProcedure = 255 | 81 kIncompleteProcedure = 255 |
89 }; | 82 }; |
90 }; | 83 }; |
91 | 84 |
92 | |
93 class FunctionNode { | 85 class FunctionNode { |
94 public: | 86 public: |
95 enum AsyncMarker { | 87 enum AsyncMarker { |
96 kSync = 0, | 88 kSync = 0, |
97 kSyncStar = 1, | 89 kSyncStar = 1, |
98 kAsync = 2, | 90 kAsync = 2, |
99 kAsyncStar = 3, | 91 kAsyncStar = 3, |
100 kSyncYielding = 4, | 92 kSyncYielding = 4, |
101 }; | 93 }; |
102 }; | 94 }; |
103 | 95 |
104 class VariableDeclaration { | 96 class VariableDeclaration { |
105 public: | 97 public: |
106 enum Flags { | 98 enum Flags { |
107 kFlagFinal = 1 << 0, | 99 kFlagFinal = 1 << 0, |
108 kFlagConst = 1 << 1, | 100 kFlagConst = 1 << 1, |
109 }; | 101 }; |
110 }; | 102 }; |
111 | 103 |
112 class YieldStatement { | 104 class YieldStatement { |
113 public: | 105 public: |
114 enum { | 106 enum { |
115 kFlagYieldStar = 1 << 0, | 107 kFlagYieldStar = 1 << 0, |
116 kFlagNative = 1 << 1, | 108 kFlagNative = 1 << 1, |
117 }; | 109 }; |
118 }; | 110 }; |
119 | 111 |
120 | |
121 class LogicalExpression { | 112 class LogicalExpression { |
122 public: | 113 public: |
123 enum Operator { kAnd, kOr }; | 114 enum Operator { kAnd, kOr }; |
124 }; | 115 }; |
125 | 116 |
126 | |
127 class Program { | 117 class Program { |
128 public: | 118 public: |
129 static Program* ReadFrom(Reader* reader); | 119 static Program* ReadFrom(Reader* reader); |
130 | 120 |
131 NameIndex main_method() { return main_method_reference_; } | 121 NameIndex main_method() { return main_method_reference_; } |
132 intptr_t string_table_offset() { return string_table_offset_; } | 122 intptr_t string_table_offset() { return string_table_offset_; } |
133 intptr_t name_table_offset() { return name_table_offset_; } | 123 intptr_t name_table_offset() { return name_table_offset_; } |
134 const uint8_t* kernel_data() { return kernel_data_; } | 124 const uint8_t* kernel_data() { return kernel_data_; } |
135 intptr_t kernel_data_size() { return kernel_data_size_; } | 125 intptr_t kernel_data_size() { return kernel_data_size_; } |
136 intptr_t library_count() { return library_count_; } | 126 intptr_t library_count() { return library_count_; } |
137 | 127 |
138 private: | 128 private: |
139 Program() : kernel_data_(NULL), kernel_data_size_(-1) {} | 129 Program() : kernel_data_(NULL), kernel_data_size_(-1) {} |
140 | 130 |
141 NameIndex main_method_reference_; // Procedure. | 131 NameIndex main_method_reference_; // Procedure. |
142 intptr_t library_count_; | 132 intptr_t library_count_; |
143 | 133 |
144 // The offset from the start of the binary to the start of the string table. | 134 // The offset from the start of the binary to the start of the string table. |
145 intptr_t string_table_offset_; | 135 intptr_t string_table_offset_; |
146 | 136 |
147 // The offset from the start of the binary to the canonical name table. | 137 // The offset from the start of the binary to the canonical name table. |
148 intptr_t name_table_offset_; | 138 intptr_t name_table_offset_; |
149 | 139 |
150 const uint8_t* kernel_data_; | 140 const uint8_t* kernel_data_; |
151 intptr_t kernel_data_size_; | 141 intptr_t kernel_data_size_; |
152 | 142 |
153 DISALLOW_COPY_AND_ASSIGN(Program); | 143 DISALLOW_COPY_AND_ASSIGN(Program); |
154 }; | 144 }; |
155 | 145 |
156 | |
157 ParsedFunction* ParseStaticFieldInitializer(Zone* zone, | 146 ParsedFunction* ParseStaticFieldInitializer(Zone* zone, |
158 const dart::Field& field); | 147 const dart::Field& field); |
159 | 148 |
160 } // namespace kernel | 149 } // namespace kernel |
161 | 150 |
162 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, | 151 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, |
163 intptr_t buffer_length); | 152 intptr_t buffer_length); |
164 | 153 |
165 | |
166 } // namespace dart | 154 } // namespace dart |
167 | 155 |
168 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 156 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
169 #endif // RUNTIME_VM_KERNEL_H_ | 157 #endif // RUNTIME_VM_KERNEL_H_ |
OLD | NEW |