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" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 | 253 |
254 DISALLOW_COPY_AND_ASSIGN(Tuple); | 254 DISALLOW_COPY_AND_ASSIGN(Tuple); |
255 }; | 255 }; |
256 | 256 |
257 | 257 |
258 class String { | 258 class String { |
259 public: | 259 public: |
260 static String* ReadFrom(Reader* reader); | 260 static String* ReadFrom(Reader* reader); |
261 static String* ReadFromImpl(Reader* reader); | 261 static String* ReadFromImpl(Reader* reader); |
262 | 262 |
263 explicit String(const char* contents) { | |
264 size_ = strlen(contents); | |
265 buffer_ = new uint8_t[size_]; // No trailing '\0'. | |
266 memmove(buffer_, contents, size_); | |
267 } | |
268 | |
263 String(const uint8_t* utf8, int length) { | 269 String(const uint8_t* utf8, int length) { |
264 buffer_ = new uint8_t[length]; | 270 buffer_ = new uint8_t[length]; |
265 size_ = length; | 271 size_ = length; |
266 memmove(buffer_, utf8, length); | 272 memmove(buffer_, utf8, length); |
267 } | 273 } |
268 ~String() { delete[] buffer_; } | 274 ~String() { delete[] buffer_; } |
269 | 275 |
270 uint8_t* buffer() { return buffer_; } | 276 uint8_t* buffer() { return buffer_; } |
271 int size() { return size_; } | 277 int size() { return size_; } |
272 | 278 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 | 396 |
391 // For a member (field, constructor, or procedure) return the canonical name | 397 // For a member (field, constructor, or procedure) return the canonical name |
392 // of the enclosing class or library. | 398 // of the enclosing class or library. |
393 CanonicalName* EnclosingName(); | 399 CanonicalName* EnclosingName(); |
394 | 400 |
395 static CanonicalName* NewRoot(); | 401 static CanonicalName* NewRoot(); |
396 | 402 |
397 private: | 403 private: |
398 CanonicalName(); | 404 CanonicalName(); |
399 | 405 |
406 CanonicalName* parent_; | |
407 String* name_; | |
408 MallocGrowableArray<CanonicalName*> children_; | |
400 bool is_referenced_; | 409 bool is_referenced_; |
401 Ref<CanonicalName> parent_; | |
402 Ref<String> name_; | |
403 MallocGrowableArray<CanonicalName*> children_; | |
404 | 410 |
405 DISALLOW_COPY_AND_ASSIGN(CanonicalName); | 411 DISALLOW_COPY_AND_ASSIGN(CanonicalName); |
406 }; | 412 }; |
407 | 413 |
408 | 414 |
409 class Node { | 415 class Node { |
410 public: | 416 public: |
411 virtual ~Node(); | 417 virtual ~Node(); |
412 | 418 |
413 enum NodeType { | 419 enum NodeType { |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
963 | 969 |
964 AsyncMarker async_marker() { return async_marker_; } | 970 AsyncMarker async_marker() { return async_marker_; } |
965 AsyncMarker dart_async_marker() { return dart_async_marker_; } | 971 AsyncMarker dart_async_marker() { return dart_async_marker_; } |
966 TypeParameterList& type_parameters() { return type_parameters_; } | 972 TypeParameterList& type_parameters() { return type_parameters_; } |
967 int required_parameter_count() { return required_parameter_count_; } | 973 int required_parameter_count() { return required_parameter_count_; } |
968 List<VariableDeclaration>& positional_parameters() { | 974 List<VariableDeclaration>& positional_parameters() { |
969 return positional_parameters_; | 975 return positional_parameters_; |
970 } | 976 } |
971 List<VariableDeclaration>& named_parameters() { return named_parameters_; } | 977 List<VariableDeclaration>& named_parameters() { return named_parameters_; } |
972 DartType* return_type() { return return_type_; } | 978 DartType* return_type() { return return_type_; } |
979 | |
973 Statement* body() { return body_; } | 980 Statement* body() { return body_; } |
981 void set_body(Statement* body) { body_ = body; } | |
kustermann
2017/04/05 11:47:07
This only works if body_ is NULL before (Child<Sta
Kevin Millikin (Google)
2017/04/25 18:20:29
Yes. We could assert, but since operator= does it
| |
982 | |
974 TokenPosition position() { return position_; } | 983 TokenPosition position() { return position_; } |
975 TokenPosition end_position() { return end_position_; } | 984 TokenPosition end_position() { return end_position_; } |
976 | 985 |
977 private: | 986 private: |
978 FunctionNode() | 987 FunctionNode() |
979 : position_(TokenPosition::kNoSource), | 988 : position_(TokenPosition::kNoSource), |
980 end_position_(TokenPosition::kNoSource) {} | 989 end_position_(TokenPosition::kNoSource) {} |
981 | 990 |
982 AsyncMarker async_marker_; | 991 AsyncMarker async_marker_; |
983 AsyncMarker dart_async_marker_; | 992 AsyncMarker dart_async_marker_; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1179 Child<Expression> receiver_; | 1188 Child<Expression> receiver_; |
1180 Ref<CanonicalName> target_reference_; // Member. | 1189 Ref<CanonicalName> target_reference_; // Member. |
1181 Child<Expression> value_; | 1190 Child<Expression> value_; |
1182 | 1191 |
1183 DISALLOW_COPY_AND_ASSIGN(DirectPropertySet); | 1192 DISALLOW_COPY_AND_ASSIGN(DirectPropertySet); |
1184 }; | 1193 }; |
1185 | 1194 |
1186 | 1195 |
1187 class StaticGet : public Expression { | 1196 class StaticGet : public Expression { |
1188 public: | 1197 public: |
1198 explicit StaticGet(CanonicalName* target) : target_reference_(target) {} | |
1199 | |
1189 static StaticGet* ReadFrom(Reader* reader); | 1200 static StaticGet* ReadFrom(Reader* reader); |
1190 | 1201 |
1191 virtual ~StaticGet(); | 1202 virtual ~StaticGet(); |
1192 | 1203 |
1193 DEFINE_CASTING_OPERATIONS(StaticGet); | 1204 DEFINE_CASTING_OPERATIONS(StaticGet); |
1194 | 1205 |
1195 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor); | 1206 virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor); |
1196 virtual void VisitChildren(Visitor* visitor); | 1207 virtual void VisitChildren(Visitor* visitor); |
1197 | 1208 |
1198 CanonicalName* target() { return target_reference_; } | 1209 CanonicalName* target() { return target_reference_; } |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2305 Child<Expression> condition_; | 2316 Child<Expression> condition_; |
2306 Child<Statement> then_; | 2317 Child<Statement> then_; |
2307 Child<Statement> otherwise_; | 2318 Child<Statement> otherwise_; |
2308 | 2319 |
2309 DISALLOW_COPY_AND_ASSIGN(IfStatement); | 2320 DISALLOW_COPY_AND_ASSIGN(IfStatement); |
2310 }; | 2321 }; |
2311 | 2322 |
2312 | 2323 |
2313 class ReturnStatement : public Statement { | 2324 class ReturnStatement : public Statement { |
2314 public: | 2325 public: |
2326 explicit ReturnStatement(Expression* expression) : expression_(expression) {} | |
2327 | |
2315 static ReturnStatement* ReadFrom(Reader* reader); | 2328 static ReturnStatement* ReadFrom(Reader* reader); |
2316 | 2329 |
2317 virtual ~ReturnStatement(); | 2330 virtual ~ReturnStatement(); |
2318 | 2331 |
2319 DEFINE_CASTING_OPERATIONS(ReturnStatement); | 2332 DEFINE_CASTING_OPERATIONS(ReturnStatement); |
2320 | 2333 |
2321 virtual void AcceptStatementVisitor(StatementVisitor* visitor); | 2334 virtual void AcceptStatementVisitor(StatementVisitor* visitor); |
2322 virtual void VisitChildren(Visitor* visitor); | 2335 virtual void VisitChildren(Visitor* visitor); |
2323 | 2336 |
2324 Expression* expression() { return expression_; } | 2337 Expression* expression() { return expression_; } |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3144 | 3157 |
3145 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, | 3158 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, |
3146 intptr_t buffer_length); | 3159 intptr_t buffer_length); |
3147 | 3160 |
3148 | 3161 |
3149 | 3162 |
3150 } // namespace dart | 3163 } // namespace dart |
3151 | 3164 |
3152 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 3165 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
3153 #endif // RUNTIME_VM_KERNEL_H_ | 3166 #endif // RUNTIME_VM_KERNEL_H_ |
OLD | NEW |