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_TO_IL_H_ | 5 #ifndef RUNTIME_VM_KERNEL_TO_IL_H_ |
6 #define RUNTIME_VM_KERNEL_TO_IL_H_ | 6 #define RUNTIME_VM_KERNEL_TO_IL_H_ |
7 | 7 |
8 #if !defined(DART_PRECOMPILED_RUNTIME) | 8 #if !defined(DART_PRECOMPILED_RUNTIME) |
9 | 9 |
10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 // Access to strings. | 283 // Access to strings. |
284 const TypedData& string_offsets() { return string_offsets_; } | 284 const TypedData& string_offsets() { return string_offsets_; } |
285 void SetStringOffsets(const TypedData& string_offsets); | 285 void SetStringOffsets(const TypedData& string_offsets); |
286 | 286 |
287 const TypedData& string_data() { return string_data_; } | 287 const TypedData& string_data() { return string_data_; } |
288 void SetStringData(const TypedData& string_data); | 288 void SetStringData(const TypedData& string_data); |
289 | 289 |
290 const TypedData& canonical_names() { return canonical_names_; } | 290 const TypedData& canonical_names() { return canonical_names_; } |
291 void SetCanonicalNames(const TypedData& canonical_names); | 291 void SetCanonicalNames(const TypedData& canonical_names); |
292 | 292 |
293 intptr_t StringOffset(intptr_t string_index) const; | 293 intptr_t StringOffset(StringIndex index) const; |
294 intptr_t StringSize(intptr_t string_index) const; | 294 intptr_t StringSize(StringIndex index) const; |
295 uint8_t CharacterAt(intptr_t string_index, intptr_t index); | 295 uint8_t CharacterAt(StringIndex string_index, intptr_t index); |
296 bool StringEquals(intptr_t string_index, const char* other); | 296 bool StringEquals(StringIndex string_index, const char* other); |
297 | 297 |
298 // Accessors and predicates for canonical names. | 298 // Accessors and predicates for canonical names. |
299 intptr_t CanonicalNameParent(intptr_t name); | 299 NameIndex CanonicalNameParent(NameIndex name); |
300 intptr_t CanonicalNameString(intptr_t name); | 300 StringIndex CanonicalNameString(NameIndex name); |
301 bool IsAdministrative(intptr_t name); | 301 bool IsAdministrative(NameIndex name); |
302 bool IsPrivate(intptr_t name); | 302 bool IsPrivate(NameIndex name); |
303 bool IsRoot(intptr_t name); | 303 bool IsRoot(NameIndex name); |
304 bool IsLibrary(intptr_t name); | 304 bool IsLibrary(NameIndex name); |
305 bool IsClass(intptr_t name); | 305 bool IsClass(NameIndex name); |
306 bool IsMember(intptr_t name); | 306 bool IsMember(NameIndex name); |
307 bool IsField(intptr_t name); | 307 bool IsField(NameIndex name); |
308 bool IsConstructor(intptr_t name); | 308 bool IsConstructor(NameIndex name); |
309 bool IsProcedure(intptr_t name); | 309 bool IsProcedure(NameIndex name); |
310 bool IsMethod(intptr_t name); | 310 bool IsMethod(NameIndex name); |
311 bool IsGetter(intptr_t name); | 311 bool IsGetter(NameIndex name); |
312 bool IsSetter(intptr_t name); | 312 bool IsSetter(NameIndex name); |
313 bool IsFactory(intptr_t name); | 313 bool IsFactory(NameIndex name); |
314 | 314 |
315 // For a member (field, constructor, or procedure) return the canonical name | 315 // For a member (field, constructor, or procedure) return the canonical name |
316 // of the enclosing class or library. | 316 // of the enclosing class or library. |
317 intptr_t EnclosingName(intptr_t name); | 317 NameIndex EnclosingName(NameIndex name); |
318 | 318 |
319 RawInstance* Canonicalize(const Instance& instance); | 319 RawInstance* Canonicalize(const Instance& instance); |
320 | 320 |
321 const dart::String& DartString(const char* content) { | 321 const dart::String& DartString(const char* content) { |
322 return DartString(content, allocation_space_); | 322 return DartString(content, allocation_space_); |
323 } | 323 } |
324 const dart::String& DartString(const char* content, Heap::Space space); | 324 const dart::String& DartString(const char* content, Heap::Space space); |
325 | 325 |
326 dart::String& DartString(intptr_t string_index) { | 326 dart::String& DartString(StringIndex index) { |
327 return DartString(string_index, allocation_space_); | 327 return DartString(index, allocation_space_); |
328 } | 328 } |
329 dart::String& DartString(intptr_t string_index, Heap::Space space); | 329 dart::String& DartString(StringIndex string_index, Heap::Space space); |
330 | 330 |
331 dart::String& DartString(const uint8_t* utf8_array, intptr_t len) { | 331 dart::String& DartString(const uint8_t* utf8_array, intptr_t len) { |
332 return DartString(utf8_array, len, allocation_space_); | 332 return DartString(utf8_array, len, allocation_space_); |
333 } | 333 } |
334 dart::String& DartString(const uint8_t* utf8_array, | 334 dart::String& DartString(const uint8_t* utf8_array, |
335 intptr_t len, | 335 intptr_t len, |
336 Heap::Space space); | 336 Heap::Space space); |
337 | 337 |
338 const dart::String& DartSymbol(const char* content) const; | 338 const dart::String& DartSymbol(const char* content) const; |
339 dart::String& DartSymbol(intptr_t string_index) const; | 339 dart::String& DartSymbol(StringIndex string_index) const; |
340 dart::String& DartSymbol(const uint8_t* utf8_array, intptr_t len) const; | 340 dart::String& DartSymbol(const uint8_t* utf8_array, intptr_t len) const; |
341 | 341 |
342 const dart::String& DartClassName(intptr_t kernel_class); | 342 const dart::String& DartClassName(NameIndex kernel_class); |
343 | 343 |
344 const dart::String& DartConstructorName(intptr_t constructor); | 344 const dart::String& DartConstructorName(NameIndex constructor); |
345 | 345 |
346 const dart::String& DartProcedureName(intptr_t procedure); | 346 const dart::String& DartProcedureName(NameIndex procedure); |
347 | 347 |
348 const dart::String& DartSetterName(intptr_t setter); | 348 const dart::String& DartSetterName(NameIndex setter); |
349 const dart::String& DartSetterName(Name* setter_name); | 349 const dart::String& DartSetterName(Name* setter_name); |
350 | 350 |
351 const dart::String& DartGetterName(intptr_t getter); | 351 const dart::String& DartGetterName(NameIndex getter); |
352 const dart::String& DartGetterName(Name* getter_name); | 352 const dart::String& DartGetterName(Name* getter_name); |
353 | 353 |
354 const dart::String& DartFieldName(Name* kernel_name); | 354 const dart::String& DartFieldName(Name* kernel_name); |
355 | 355 |
356 const dart::String& DartInitializerName(Name* kernel_name); | 356 const dart::String& DartInitializerName(Name* kernel_name); |
357 | 357 |
358 const dart::String& DartMethodName(intptr_t method); | 358 const dart::String& DartMethodName(NameIndex method); |
359 const dart::String& DartMethodName(Name* method_name); | 359 const dart::String& DartMethodName(Name* method_name); |
360 | 360 |
361 const dart::String& DartFactoryName(intptr_t factory); | 361 const dart::String& DartFactoryName(NameIndex factory); |
362 | 362 |
363 const Array& ArgumentNames(List<NamedExpression>* named); | 363 const Array& ArgumentNames(List<NamedExpression>* named); |
364 | 364 |
365 // A subclass overrides these when reading in the Kernel program in order to | 365 // A subclass overrides these when reading in the Kernel program in order to |
366 // support recursive type expressions (e.g. for "implements X" ... | 366 // support recursive type expressions (e.g. for "implements X" ... |
367 // annotations). | 367 // annotations). |
368 virtual RawLibrary* LookupLibraryByKernelLibrary(intptr_t library); | 368 virtual RawLibrary* LookupLibraryByKernelLibrary(NameIndex library); |
369 virtual RawClass* LookupClassByKernelClass(intptr_t klass); | 369 virtual RawClass* LookupClassByKernelClass(NameIndex klass); |
370 | 370 |
371 RawField* LookupFieldByKernelField(intptr_t field); | 371 RawField* LookupFieldByKernelField(NameIndex field); |
372 RawFunction* LookupStaticMethodByKernelProcedure(intptr_t procedure); | 372 RawFunction* LookupStaticMethodByKernelProcedure(NameIndex procedure); |
373 RawFunction* LookupConstructorByKernelConstructor(intptr_t constructor); | 373 RawFunction* LookupConstructorByKernelConstructor(NameIndex constructor); |
374 dart::RawFunction* LookupConstructorByKernelConstructor( | 374 dart::RawFunction* LookupConstructorByKernelConstructor( |
375 const dart::Class& owner, | 375 const dart::Class& owner, |
376 intptr_t constructor); | 376 NameIndex constructor); |
377 | 377 |
378 dart::Type& GetCanonicalType(const dart::Class& klass); | 378 dart::Type& GetCanonicalType(const dart::Class& klass); |
379 | 379 |
380 void ReportError(const char* format, ...); | 380 void ReportError(const char* format, ...); |
381 void ReportError(const Error& prev_error, const char* format, ...); | 381 void ReportError(const Error& prev_error, const char* format, ...); |
382 | 382 |
383 private: | 383 private: |
384 // This will mangle [name_to_modify] if necessary and make the result a symbol | 384 // This will mangle [name_to_modify] if necessary and make the result a symbol |
385 // if asked. The result will be available in [name_to_modify] and it is also | 385 // if asked. The result will be available in [name_to_modify] and it is also |
386 // returned. If the name is private, the canonical name [parent] will be used | 386 // returned. If the name is private, the canonical name [parent] will be used |
387 // to get the import URI of the library where the name is visible. | 387 // to get the import URI of the library where the name is visible. |
388 dart::String& ManglePrivateName(intptr_t parent, | 388 dart::String& ManglePrivateName(NameIndex parent, |
389 dart::String* name_to_modify, | 389 dart::String* name_to_modify, |
390 bool symbolize = true); | 390 bool symbolize = true); |
391 | 391 |
392 const dart::String& DartSetterName(intptr_t parent, intptr_t setter); | 392 const dart::String& DartSetterName(NameIndex parent, StringIndex setter); |
393 const dart::String& DartGetterName(intptr_t parent, intptr_t getter); | 393 const dart::String& DartGetterName(NameIndex parent, StringIndex getter); |
394 const dart::String& DartMethodName(intptr_t parent, intptr_t method); | 394 const dart::String& DartMethodName(NameIndex parent, StringIndex method); |
395 | 395 |
396 Thread* thread_; | 396 Thread* thread_; |
397 Zone* zone_; | 397 Zone* zone_; |
398 Isolate* isolate_; | 398 Isolate* isolate_; |
399 Heap::Space allocation_space_; | 399 Heap::Space allocation_space_; |
400 | 400 |
401 TypedData& string_offsets_; | 401 TypedData& string_offsets_; |
402 TypedData& string_data_; | 402 TypedData& string_data_; |
403 TypedData& canonical_names_; | 403 TypedData& canonical_names_; |
404 }; | 404 }; |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 | 858 |
859 TargetEntryInstr* BuildTargetEntry(); | 859 TargetEntryInstr* BuildTargetEntry(); |
860 JoinEntryInstr* BuildJoinEntry(); | 860 JoinEntryInstr* BuildJoinEntry(); |
861 JoinEntryInstr* BuildJoinEntry(intptr_t try_index); | 861 JoinEntryInstr* BuildJoinEntry(intptr_t try_index); |
862 | 862 |
863 Fragment TranslateArguments(Arguments* node, Array* argument_names); | 863 Fragment TranslateArguments(Arguments* node, Array* argument_names); |
864 ArgumentArray GetArguments(int count); | 864 ArgumentArray GetArguments(int count); |
865 | 865 |
866 Fragment TranslateInitializers(Class* kernel_class, | 866 Fragment TranslateInitializers(Class* kernel_class, |
867 List<Initializer>* initialiers); | 867 List<Initializer>* initialiers); |
868 Fragment TranslateFieldInitializer(intptr_t canonical_name, Expression* init); | 868 Fragment TranslateFieldInitializer(NameIndex canonical_name, |
| 869 Expression* init); |
869 | 870 |
870 Fragment TranslateStatement(Statement* statement); | 871 Fragment TranslateStatement(Statement* statement); |
871 Fragment TranslateCondition(Expression* expression, bool* negate); | 872 Fragment TranslateCondition(Expression* expression, bool* negate); |
872 Fragment TranslateExpression(Expression* expression); | 873 Fragment TranslateExpression(Expression* expression); |
873 | 874 |
874 Fragment TranslateFinallyFinalizers(TryFinallyBlock* outer_finally, | 875 Fragment TranslateFinallyFinalizers(TryFinallyBlock* outer_finally, |
875 intptr_t target_context_depth); | 876 intptr_t target_context_depth); |
876 | 877 |
877 Fragment TranslateFunctionNode(FunctionNode* node, TreeNode* parent); | 878 Fragment TranslateFunctionNode(FunctionNode* node, TreeNode* parent); |
878 | 879 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 Fragment AssertAssignable(const dart::AbstractType& dst_type, | 989 Fragment AssertAssignable(const dart::AbstractType& dst_type, |
989 const dart::String& dst_name); | 990 const dart::String& dst_name); |
990 | 991 |
991 template <class Invocation> | 992 template <class Invocation> |
992 bool RecognizeComparisonWithNull(Token::Kind token_kind, Invocation* node); | 993 bool RecognizeComparisonWithNull(Token::Kind token_kind, Invocation* node); |
993 | 994 |
994 bool NeedsDebugStepCheck(const Function& function, TokenPosition position); | 995 bool NeedsDebugStepCheck(const Function& function, TokenPosition position); |
995 bool NeedsDebugStepCheck(Value* value, TokenPosition position); | 996 bool NeedsDebugStepCheck(Value* value, TokenPosition position); |
996 Fragment DebugStepCheck(TokenPosition position); | 997 Fragment DebugStepCheck(TokenPosition position); |
997 | 998 |
998 dart::RawFunction* LookupMethodByMember(intptr_t target, | 999 dart::RawFunction* LookupMethodByMember(NameIndex target, |
999 const dart::String& method_name); | 1000 const dart::String& method_name); |
1000 | 1001 |
1001 LocalVariable* MakeTemporary(); | 1002 LocalVariable* MakeTemporary(); |
1002 LocalVariable* MakeNonTemporary(const dart::String& symbol); | 1003 LocalVariable* MakeNonTemporary(const dart::String& symbol); |
1003 | 1004 |
1004 intptr_t CurrentTryIndex(); | 1005 intptr_t CurrentTryIndex(); |
1005 intptr_t AllocateTryIndex() { return next_used_try_index_++; } | 1006 intptr_t AllocateTryIndex() { return next_used_try_index_++; } |
1006 | 1007 |
1007 void AddVariable(VariableDeclaration* declaration, LocalVariable* variable); | 1008 void AddVariable(VariableDeclaration* declaration, LocalVariable* variable); |
1008 void AddParameter(VariableDeclaration* declaration, | 1009 void AddParameter(VariableDeclaration* declaration, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 namespace kernel { | 1161 namespace kernel { |
1161 | 1162 |
1162 RawObject* EvaluateMetadata(const dart::Field& metadata_field); | 1163 RawObject* EvaluateMetadata(const dart::Field& metadata_field); |
1163 RawObject* BuildParameterDescriptor(const Function& function); | 1164 RawObject* BuildParameterDescriptor(const Function& function); |
1164 | 1165 |
1165 } // namespace kernel | 1166 } // namespace kernel |
1166 } // namespace dart | 1167 } // namespace dart |
1167 | 1168 |
1168 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 1169 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
1169 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ | 1170 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ |
OLD | NEW |