Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::kernel::TranslationHelper Class Reference

#include <kernel_translation_helper.h>

Inheritance diagram for dart::kernel::TranslationHelper:
dart::kernel::BuildingTranslationHelper

Public Member Functions

 TranslationHelper (Thread *thread)
 
 TranslationHelper (Thread *thread, Heap::Space space)
 
virtual ~TranslationHelper ()
 
void Reset ()
 
void InitFromKernelProgramInfo (const KernelProgramInfo &info)
 
Threadthread ()
 
Zonezone ()
 
IsolateGroupisolate_group ()
 
Heap::Space allocation_space ()
 
const TypedDatastring_offsets () const
 
void SetStringOffsets (const TypedData &string_offsets)
 
const TypedDataViewstring_data () const
 
void SetStringData (const TypedDataView &string_data)
 
const TypedDatacanonical_names () const
 
void SetCanonicalNames (const TypedData &canonical_names)
 
const TypedDataViewmetadata_payloads () const
 
void SetMetadataPayloads (const TypedDataView &metadata_payloads)
 
const TypedDataViewmetadata_mappings () const
 
void SetMetadataMappings (const TypedDataView &metadata_mappings)
 
const Arrayconstants ()
 
void SetConstants (const Array &constants)
 
const TypedDataViewconstants_table () const
 
void SetConstantsTable (const TypedDataView &constants_table)
 
void SetKernelProgramInfo (const KernelProgramInfo &info)
 
const KernelProgramInfoGetKernelProgramInfo () const
 
intptr_t StringOffset (StringIndex index) const
 
intptr_t StringSize (StringIndex index) const
 
uint8_t * StringBuffer (StringIndex index) const
 
uint8_t CharacterAt (StringIndex string_index, intptr_t index)
 
bool StringEquals (StringIndex string_index, const char *other)
 
NameIndex CanonicalNameParent (NameIndex name)
 
StringIndex CanonicalNameString (NameIndex name)
 
bool IsAdministrative (NameIndex name)
 
bool IsPrivate (NameIndex name)
 
bool IsRoot (NameIndex name)
 
bool IsLibrary (NameIndex name)
 
bool IsClass (NameIndex name)
 
bool IsMember (NameIndex name)
 
bool IsConstructor (NameIndex name)
 
bool IsProcedure (NameIndex name)
 
bool IsMethod (NameIndex name)
 
bool IsGetter (NameIndex name)
 
bool IsSetter (NameIndex name)
 
bool IsFactory (NameIndex name)
 
bool IsField (NameIndex name)
 
NameIndex EnclosingName (NameIndex name)
 
InstancePtr Canonicalize (const Instance &instance)
 
const StringDartString (const char *content)
 
const StringDartString (const char *content, Heap::Space space)
 
StringDartString (StringIndex index)
 
StringDartString (StringIndex string_index, Heap::Space space)
 
StringDartString (const uint8_t *utf8_array, intptr_t len, Heap::Space space)
 
const StringDartString (const GrowableHandlePtrArray< const String > &pieces)
 
const StringDartSymbolPlain (const char *content) const
 
StringDartSymbolPlain (StringIndex string_index) const
 
const StringDartSymbolObfuscate (const char *content) const
 
StringDartSymbolObfuscate (StringIndex string_index) const
 
StringDartIdentifier (const Library &lib, StringIndex string_index)
 
const StringDartClassName (NameIndex kernel_class)
 
const StringDartConstructorName (NameIndex constructor)
 
const StringDartProcedureName (NameIndex procedure)
 
const StringDartSetterName (NameIndex setter)
 
const StringDartSetterName (NameIndex parent, StringIndex setter)
 
const StringDartGetterName (NameIndex getter)
 
const StringDartGetterName (NameIndex parent, StringIndex getter)
 
const StringDartFieldName (NameIndex field)
 
const StringDartFieldName (NameIndex parent, StringIndex field)
 
const StringDartMethodName (NameIndex method)
 
const StringDartMethodName (NameIndex parent, StringIndex method)
 
const StringDartFactoryName (NameIndex factory)
 
DART_NORETURN void LookupFailed (NameIndex name)
 
DART_NORETURN void LookupFailed (StringIndex name)
 
virtual LibraryPtr LookupLibraryByKernelLibrary (NameIndex library, bool required=true)
 
virtual ClassPtr LookupClassByKernelClass (NameIndex klass, bool required=true)
 
ClassPtr LookupClassByKernelClassOrLibrary (NameIndex kernel_name, bool required=true)
 
FieldPtr LookupFieldByKernelField (NameIndex field, bool required=true)
 
FieldPtr LookupFieldByKernelGetterOrSetter (NameIndex field, bool required=true)
 
FunctionPtr LookupStaticMethodByKernelProcedure (NameIndex procedure, bool required=true)
 
FunctionPtr LookupConstructorByKernelConstructor (NameIndex constructor, bool required=true)
 
FunctionPtr LookupConstructorByKernelConstructor (const Class &owner, NameIndex constructor, bool required=true)
 
FunctionPtr LookupConstructorByKernelConstructor (const Class &owner, StringIndex constructor_name, bool required=true)
 
FunctionPtr LookupMethodByMember (NameIndex target, const String &method_name, bool required=true)
 
ObjectPtr LookupMemberByMember (NameIndex kernel_name, bool required=true)
 
FunctionPtr LookupDynamicFunction (const Class &klass, const String &name)
 
TypeGetDeclarationType (const Class &klass)
 
void SetupFieldAccessorFunction (const Class &klass, const Function &function, const AbstractType &field_type)
 
void ReportError (const char *format,...) PRINTF_ATTRIBUTE(2
 
void void ReportError (const Script &script, const TokenPosition position, const char *format,...) PRINTF_ATTRIBUTE(4
 
void void void ReportError (const Error &prev_error, const char *format,...) PRINTF_ATTRIBUTE(3
 
void void void void ReportError (const Error &prev_error, const Script &script, const TokenPosition position, const char *format,...) PRINTF_ATTRIBUTE(5
 
void void void void void SetExpressionEvaluationFunction (const Function &function)
 
const FunctionGetExpressionEvaluationFunction ()
 
void SetExpressionEvaluationClass (const Class &cls)
 
const ClassGetExpressionEvaluationClass ()
 
void SetExpressionEvaluationRealClass (const Class &real_class)
 
const ClassGetExpressionEvaluationRealClass ()
 

Detailed Description

Definition at line 25 of file kernel_translation_helper.h.

Constructor & Destructor Documentation

◆ TranslationHelper() [1/2]

dart::kernel::TranslationHelper::TranslationHelper ( Thread thread)
explicit

Definition at line 27 of file kernel_translation_helper.cc.

28 : thread_(thread),
29 zone_(thread->zone()),
30 isolate_group_(thread->isolate_group()),
31 allocation_space_(Heap::kNew),
32 string_offsets_(TypedData::Handle(Z)),
33 string_data_(TypedDataView::Handle(Z)),
34 canonical_names_(TypedData::Handle(Z)),
35 metadata_payloads_(TypedDataView::Handle(Z)),
36 metadata_mappings_(TypedDataView::Handle(Z)),
37 constants_(Array::Handle(Z)),
38 constants_table_(TypedDataView::Handle(Z)),
40 name_index_handle_(Smi::Handle(Z)) {}
@ kNew
Definition: heap.h:38
static Object & Handle()
Definition: object.h:407
Zone * zone() const
Definition: thread_state.h:37
IsolateGroup * isolate_group() const
Definition: thread.h:541

◆ TranslationHelper() [2/2]

dart::kernel::TranslationHelper::TranslationHelper ( Thread thread,
Heap::Space  space 
)

Definition at line 42 of file kernel_translation_helper.cc.

43 : thread_(thread),
44 zone_(thread->zone()),
45 isolate_group_(thread->isolate_group()),
46 allocation_space_(space),
47 string_offsets_(TypedData::Handle(Z)),
48 string_data_(TypedDataView::Handle(Z)),
49 canonical_names_(TypedData::Handle(Z)),
50 metadata_payloads_(TypedDataView::Handle(Z)),
51 metadata_mappings_(TypedDataView::Handle(Z)),
52 constants_(Array::Handle(Z)),
53 constants_table_(TypedDataView::Handle(Z)),
55 name_index_handle_(Smi::Handle(Z)) {}

◆ ~TranslationHelper()

virtual dart::kernel::TranslationHelper::~TranslationHelper ( )
inlinevirtual

Definition at line 31 of file kernel_translation_helper.h.

31{}

Member Function Documentation

◆ allocation_space()

Heap::Space dart::kernel::TranslationHelper::allocation_space ( )
inline

Definition at line 43 of file kernel_translation_helper.h.

43{ return allocation_space_; }

◆ canonical_names()

const TypedData & dart::kernel::TranslationHelper::canonical_names ( ) const
inline

Definition at line 52 of file kernel_translation_helper.h.

52{ return canonical_names_; }

◆ Canonicalize()

InstancePtr dart::kernel::TranslationHelper::Canonicalize ( const Instance instance)

Definition at line 308 of file kernel_translation_helper.cc.

308 {
309 if (instance.IsNull()) return instance.ptr();
310
311 return instance.Canonicalize(thread());
312}
VkInstance instance
Definition: main.cc:48

◆ CanonicalNameParent()

NameIndex dart::kernel::TranslationHelper::CanonicalNameParent ( NameIndex  name)

Definition at line 164 of file kernel_translation_helper.cc.

164 {
165 // Canonical names are pairs of 4-byte parent and string indexes, so the size
166 // of an entry is 8 bytes. The parent is biased: 0 represents the root name
167 // and N+1 represents the name with index N.
168 return NameIndex(static_cast<intptr_t>(canonical_names_.GetUint32(8 * name)) -
169 1);
170}
const char *const name

◆ CanonicalNameString()

StringIndex dart::kernel::TranslationHelper::CanonicalNameString ( NameIndex  name)

Definition at line 172 of file kernel_translation_helper.cc.

172 {
173 return StringIndex(canonical_names_.GetUint32((8 * name) + 4));
174}

◆ CharacterAt()

uint8_t dart::kernel::TranslationHelper::CharacterAt ( StringIndex  string_index,
intptr_t  index 
)

Definition at line 136 of file kernel_translation_helper.cc.

137 {
138 ASSERT(index < StringSize(string_index));
139 return string_data_.GetUint8(StringOffset(string_index) + index);
140}
intptr_t StringSize(StringIndex index) const
intptr_t StringOffset(StringIndex index) const
#define ASSERT(E)

◆ constants()

const Array & dart::kernel::TranslationHelper::constants ( )
inline

Definition at line 62 of file kernel_translation_helper.h.

62{ return constants_; }

◆ constants_table()

const TypedDataView & dart::kernel::TranslationHelper::constants_table ( ) const
inline

Definition at line 66 of file kernel_translation_helper.h.

66{ return constants_table_; }

◆ DartClassName()

const String & dart::kernel::TranslationHelper::DartClassName ( NameIndex  kernel_class)

Definition at line 390 of file kernel_translation_helper.cc.

390 {
391 ASSERT(IsClass(kernel_class));
392 String& name = DartString(CanonicalNameString(kernel_class));
393 return ManglePrivateName(CanonicalNameParent(kernel_class), &name);
394}
const String & DartString(const char *content)
NameIndex CanonicalNameParent(NameIndex name)
StringIndex CanonicalNameString(NameIndex name)

◆ DartConstructorName()

const String & dart::kernel::TranslationHelper::DartConstructorName ( NameIndex  constructor)

Definition at line 396 of file kernel_translation_helper.cc.

396 {
397 ASSERT(IsConstructor(constructor));
398 return DartFactoryName(constructor);
399}
const String & DartFactoryName(NameIndex factory)

◆ DartFactoryName()

const String & dart::kernel::TranslationHelper::DartFactoryName ( NameIndex  factory)

Definition at line 483 of file kernel_translation_helper.cc.

483 {
484 ASSERT(IsConstructor(factory) || IsFactory(factory));
485 GrowableHandlePtrArray<const String> pieces(Z, 3);
486 pieces.Add(DartClassName(EnclosingName(factory)));
487 pieces.Add(Symbols::Dot());
488 // [DartMethodName] will mangle the name.
489 pieces.Add(DartMethodName(factory));
490 return String::ZoneHandle(Z, Symbols::FromConcatAll(thread_, pieces));
491}
static Object & ZoneHandle()
Definition: object.h:419
static StringPtr FromConcatAll(Thread *thread, const GrowableHandlePtrArray< const String > &strs)
Definition: symbols.cc:262
static const String & Dot()
Definition: symbols.h:613
const String & DartClassName(NameIndex kernel_class)
const String & DartMethodName(NameIndex method)

◆ DartFieldName() [1/2]

const String & dart::kernel::TranslationHelper::DartFieldName ( NameIndex  field)

Definition at line 462 of file kernel_translation_helper.cc.

462 {
464}
const String & DartFieldName(NameIndex field)

◆ DartFieldName() [2/2]

const String & dart::kernel::TranslationHelper::DartFieldName ( NameIndex  parent,
StringIndex  field 
)

Definition at line 466 of file kernel_translation_helper.cc.

467 {
468 String& name = DartString(field);
469 return ManglePrivateName(parent, &name);
470}

◆ DartGetterName() [1/2]

const String & dart::kernel::TranslationHelper::DartGetterName ( NameIndex  getter)

Definition at line 449 of file kernel_translation_helper.cc.

449 {
450 return DartGetterName(CanonicalNameParent(getter),
451 CanonicalNameString(getter));
452}
const String & DartGetterName(NameIndex getter)

◆ DartGetterName() [2/2]

const String & dart::kernel::TranslationHelper::DartGetterName ( NameIndex  parent,
StringIndex  getter 
)

Definition at line 454 of file kernel_translation_helper.cc.

455 {
456 String& name = DartString(getter);
457 ManglePrivateName(parent, &name);
459 return name;
460}
static StringPtr GetterSymbol(const String &field_name)
Definition: object.cc:11796

◆ DartIdentifier()

String & dart::kernel::TranslationHelper::DartIdentifier ( const Library lib,
StringIndex  string_index 
)

Definition at line 383 of file kernel_translation_helper.cc.

384 {
385 String& name = DartString(string_index);
386 ManglePrivateName(lib, &name);
387 return name;
388}

◆ DartMethodName() [1/2]

const String & dart::kernel::TranslationHelper::DartMethodName ( NameIndex  method)

Definition at line 472 of file kernel_translation_helper.cc.

472 {
473 return DartMethodName(CanonicalNameParent(method),
474 CanonicalNameString(method));
475}

◆ DartMethodName() [2/2]

const String & dart::kernel::TranslationHelper::DartMethodName ( NameIndex  parent,
StringIndex  method 
)

Definition at line 477 of file kernel_translation_helper.cc.

478 {
479 String& name = DartString(method);
480 return ManglePrivateName(parent, &name);
481}

◆ DartProcedureName()

const String & dart::kernel::TranslationHelper::DartProcedureName ( NameIndex  procedure)

Definition at line 401 of file kernel_translation_helper.cc.

401 {
402 ASSERT(IsProcedure(procedure) || IsConstructor(procedure));
403 if (IsSetter(procedure)) {
404 return DartSetterName(procedure);
405 } else if (IsGetter(procedure)) {
406 return DartGetterName(procedure);
407 } else if (IsFactory(procedure)) {
408 return DartFactoryName(procedure);
409 } else if (IsMethod(procedure)) {
410 return DartMethodName(procedure);
411 } else {
412 ASSERT(IsConstructor(procedure));
413 return DartConstructorName(procedure);
414 }
415}
const String & DartSetterName(NameIndex setter)
const String & DartConstructorName(NameIndex constructor)

◆ DartSetterName() [1/2]

const String & dart::kernel::TranslationHelper::DartSetterName ( NameIndex  parent,
StringIndex  setter 
)

Definition at line 422 of file kernel_translation_helper.cc.

423 {
424 // The names flowing into [setter] are coming from the Kernel file:
425 // * user-defined setters: `fieldname=`
426 // * property-set expressions: `fieldname`
427 //
428 // The VM uses `get:fieldname` and `set:fieldname`.
429 //
430 // => In order to be consistent, we remove the `=` always and adopt the VM
431 // conventions.
432 intptr_t size = StringSize(setter);
433 ASSERT(size > 0);
434 if (CharacterAt(setter, size - 1) == '=') {
435 --size;
436 }
437 uint8_t* buffer = Z->Alloc<uint8_t>(size);
438 {
439 NoSafepointScope no_safepoint;
440 memmove(buffer, StringBuffer(setter), size);
441 }
442 String& name =
443 String::ZoneHandle(Z, String::FromUTF8(buffer, size, allocation_space_));
444 ManglePrivateName(parent, &name);
446 return name;
447}
static StringPtr SetterSymbol(const String &field_name)
Definition: object.cc:11808
static StringPtr FromUTF8(const uint8_t *utf8_array, intptr_t array_len, Heap::Space space=Heap::kNew)
Definition: object.cc:23705
uint8_t * StringBuffer(StringIndex index) const
uint8_t CharacterAt(StringIndex string_index, intptr_t index)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ DartSetterName() [2/2]

const String & dart::kernel::TranslationHelper::DartSetterName ( NameIndex  setter)

Definition at line 417 of file kernel_translation_helper.cc.

417 {
418 return DartSetterName(CanonicalNameParent(setter),
419 CanonicalNameString(setter));
420}

◆ DartString() [1/6]

const String & dart::kernel::TranslationHelper::DartString ( const char *  content)
inline

Definition at line 106 of file kernel_translation_helper.h.

106 {
107 return DartString(content, allocation_space_);
108 }
union flutter::testing::@2836::KeyboardChange::@76 content

◆ DartString() [2/6]

const String & dart::kernel::TranslationHelper::DartString ( const char *  content,
Heap::Space  space 
)

Definition at line 314 of file kernel_translation_helper.cc.

315 {
316 return String::ZoneHandle(Z, String::New(content, space));
317}
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition: object.cc:23698

◆ DartString() [3/6]

const String & dart::kernel::TranslationHelper::DartString ( const GrowableHandlePtrArray< const String > &  pieces)

Definition at line 336 of file kernel_translation_helper.cc.

337 {
338 return String::ZoneHandle(Z, Symbols::FromConcatAll(thread_, pieces));
339}

◆ DartString() [4/6]

String & dart::kernel::TranslationHelper::DartString ( const uint8_t *  utf8_array,
intptr_t  len,
Heap::Space  space 
)

Definition at line 330 of file kernel_translation_helper.cc.

332 {
333 return String::ZoneHandle(Z, String::FromUTF8(utf8_array, len, space));
334}

◆ DartString() [5/6]

String & dart::kernel::TranslationHelper::DartString ( StringIndex  index)
inline

Definition at line 111 of file kernel_translation_helper.h.

111 {
112 return DartString(index, allocation_space_);
113 }

◆ DartString() [6/6]

String & dart::kernel::TranslationHelper::DartString ( StringIndex  string_index,
Heap::Space  space 
)

Definition at line 319 of file kernel_translation_helper.cc.

320 {
321 intptr_t length = StringSize(string_index);
322 uint8_t* buffer = Z->Alloc<uint8_t>(length);
323 {
324 NoSafepointScope no_safepoint;
325 memmove(buffer, StringBuffer(string_index), length);
326 }
328}
size_t length

◆ DartSymbolObfuscate() [1/2]

const String & dart::kernel::TranslationHelper::DartSymbolObfuscate ( const char *  content) const

Definition at line 357 of file kernel_translation_helper.cc.

358 {
359 String& result = String::ZoneHandle(Z, Symbols::New(thread_, content));
360 if (IG->obfuscate()) {
361 Obfuscator obfuscator(thread_, String::Handle(Z));
362 result = obfuscator.Rename(result, true);
363 }
364 return result;
365}
static StringPtr New(Thread *thread, const char *cstr)
Definition: symbols.h:723
GAsyncResult * result
#define IG

◆ DartSymbolObfuscate() [2/2]

String & dart::kernel::TranslationHelper::DartSymbolObfuscate ( StringIndex  string_index) const

Definition at line 367 of file kernel_translation_helper.cc.

367 {
368 intptr_t length = StringSize(string_index);
369 uint8_t* buffer = Z->Alloc<uint8_t>(length);
370 {
371 NoSafepointScope no_safepoint;
372 memmove(buffer, StringBuffer(string_index), length);
373 }
374 String& result =
376 if (IG->obfuscate()) {
377 Obfuscator obfuscator(thread_, String::Handle(Z));
378 result = obfuscator.Rename(result, true);
379 }
380 return result;
381}
static StringPtr FromUTF8(Thread *thread, const uint8_t *utf8_array, intptr_t len)
Definition: symbols.cc:196

◆ DartSymbolPlain() [1/2]

const String & dart::kernel::TranslationHelper::DartSymbolPlain ( const char *  content) const

Definition at line 341 of file kernel_translation_helper.cc.

341 {
342 return String::ZoneHandle(Z, Symbols::New(thread_, content));
343}

◆ DartSymbolPlain() [2/2]

String & dart::kernel::TranslationHelper::DartSymbolPlain ( StringIndex  string_index) const

Definition at line 345 of file kernel_translation_helper.cc.

345 {
346 intptr_t length = StringSize(string_index);
347 uint8_t* buffer = Z->Alloc<uint8_t>(length);
348 {
349 NoSafepointScope no_safepoint;
350 memmove(buffer, StringBuffer(string_index), length);
351 }
352 String& result =
354 return result;
355}

◆ EnclosingName()

NameIndex dart::kernel::TranslationHelper::EnclosingName ( NameIndex  name)

Definition at line 298 of file kernel_translation_helper.cc.

298 {
300 NameIndex enclosing = CanonicalNameParent(CanonicalNameParent(name));
301 if (IsPrivate(name)) {
302 enclosing = CanonicalNameParent(enclosing);
303 }
304 ASSERT(IsLibrary(enclosing) || IsClass(enclosing));
305 return enclosing;
306}

◆ GetDeclarationType()

Type & dart::kernel::TranslationHelper::GetDeclarationType ( const Class klass)

Definition at line 779 of file kernel_translation_helper.cc.

779 {
780 ASSERT(!klass.IsNull());
781 // Forward expression evaluation class to a real class when
782 // creating types.
783 if (GetExpressionEvaluationClass().ptr() == klass.ptr()) {
784 ASSERT(GetExpressionEvaluationRealClass().ptr() != klass.ptr());
786 }
787 ASSERT(klass.id() != kIllegalCid);
788 // Note that if cls is _Closure, the returned type will be _Closure,
789 // and not the signature type.
791 if (klass.is_type_finalized()) {
792 type = klass.DeclarationType();
793 } else {
794 // Note that the type argument vector is not yet extended.
795 TypeArguments& type_args = TypeArguments::Handle(Z);
796 const intptr_t num_type_params = klass.NumTypeParameters();
797 if (num_type_params > 0) {
798 type_args = TypeArguments::New(num_type_params);
799 TypeParameter& type_param = TypeParameter::Handle();
800 for (intptr_t i = 0; i < num_type_params; i++) {
801 type_param = klass.TypeParameterAt(i);
802 type_args.SetTypeAt(i, type_param);
803 }
804 }
805 type = Type::New(klass, type_args, Nullability::kNonNullable);
806 }
807 return type;
808}
GLenum type
ObjectPtr ptr() const
Definition: object.h:332
static TypeArgumentsPtr New(intptr_t len, Heap::Space space=Heap::kOld)
Definition: object.cc:7675
static TypePtr New(const Class &clazz, const TypeArguments &arguments, Nullability nullability=Nullability::kNonNullable, Heap::Space space=Heap::kOld)
Type & GetDeclarationType(const Class &klass)
@ kIllegalCid
Definition: class_id.h:214

◆ GetExpressionEvaluationClass()

const Class & dart::kernel::TranslationHelper::GetExpressionEvaluationClass ( )
inline

Definition at line 215 of file kernel_translation_helper.h.

215 {
216 if (expression_evaluation_class_ == nullptr) {
217 return Class::null_class();
218 }
219 return *expression_evaluation_class_;
220 }

◆ GetExpressionEvaluationFunction()

const Function & dart::kernel::TranslationHelper::GetExpressionEvaluationFunction ( )
inline

Definition at line 204 of file kernel_translation_helper.h.

204 {
205 if (expression_evaluation_function_ == nullptr) {
206 return Function::null_function();
207 }
208 return *expression_evaluation_function_;
209 }

◆ GetExpressionEvaluationRealClass()

const Class & dart::kernel::TranslationHelper::GetExpressionEvaluationRealClass ( )
inline

Definition at line 226 of file kernel_translation_helper.h.

226 {
227 if (expression_evaluation_real_class_ == nullptr) {
228 return Class::null_class();
229 }
230 return *expression_evaluation_real_class_;
231 }

◆ GetKernelProgramInfo()

const KernelProgramInfo & dart::kernel::TranslationHelper::GetKernelProgramInfo ( ) const
inline

Definition at line 70 of file kernel_translation_helper.h.

70{ return info_; }

◆ InitFromKernelProgramInfo()

void dart::kernel::TranslationHelper::InitFromKernelProgramInfo ( const KernelProgramInfo info)

Definition at line 66 of file kernel_translation_helper.cc.

67 {
68 if (info.IsNull()) {
69 // If there is no kernel data available then do not bother initializing!
70 // This can happen with few special functions like
71 // NoSuchMethodDispatcher and InvokeFieldDispatcher.
72 return;
73 }
74 SetStringOffsets(TypedData::Handle(Z, info.string_offsets()));
76 SetCanonicalNames(TypedData::Handle(Z, info.canonical_names()));
77 SetMetadataPayloads(TypedDataView::Handle(Z, info.metadata_payloads()));
78 SetMetadataMappings(TypedDataView::Handle(Z, info.metadata_mappings()));
79 SetConstants(Array::Handle(Z, info.constants()));
80 SetConstantsTable(TypedDataView::Handle(Z, info.constants_table()));
82}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
void SetConstantsTable(const TypedDataView &constants_table)
void SetCanonicalNames(const TypedData &canonical_names)
void SetMetadataMappings(const TypedDataView &metadata_mappings)
void SetKernelProgramInfo(const KernelProgramInfo &info)
void SetStringOffsets(const TypedData &string_offsets)
void SetConstants(const Array &constants)
void SetStringData(const TypedDataView &string_data)
void SetMetadataPayloads(const TypedDataView &metadata_payloads)

◆ IsAdministrative()

bool dart::kernel::TranslationHelper::IsAdministrative ( NameIndex  name)

Definition at line 176 of file kernel_translation_helper.cc.

176 {
177 // Administrative names start with '@'.
178 StringIndex name_string = CanonicalNameString(name);
179 return (StringSize(name_string) > 0) && (CharacterAt(name_string, 0) == '@');
180}

◆ IsClass()

bool dart::kernel::TranslationHelper::IsClass ( NameIndex  name)

Definition at line 197 of file kernel_translation_helper.cc.

197 {
198 // Classes have the library as their parent and are not an administrative
199 // name starting with @.
200 return !IsAdministrative(name) && !IsRoot(name) &&
202}

◆ IsConstructor()

bool dart::kernel::TranslationHelper::IsConstructor ( NameIndex  name)

Definition at line 208 of file kernel_translation_helper.cc.

208 {
209 // Constructors with private names have the import URI of the library where
210 // they are visible as the parent and the string "@constructors" as the
211 // parent's parent. Constructors with non-private names have the string
212 // "@constructors" as the parent.
213 if (IsRoot(name)) {
214 return false;
215 }
216 NameIndex kind = CanonicalNameParent(name);
217 if (IsPrivate(name)) {
218 kind = CanonicalNameParent(kind);
219 }
220 return StringEquals(CanonicalNameString(kind), "@constructors");
221}
bool StringEquals(StringIndex string_index, const char *other)

◆ IsFactory()

bool dart::kernel::TranslationHelper::IsFactory ( NameIndex  name)

Definition at line 269 of file kernel_translation_helper.cc.

269 {
270 // Factories with private names have the import URI of the library where they
271 // are visible as the parent and the string "@factories" as the parent's
272 // parent. Factories with non-private names have the string "@factories" as
273 // the parent.
274 if (IsRoot(name)) {
275 return false;
276 }
277 NameIndex kind = CanonicalNameParent(name);
278 if (IsPrivate(name)) {
279 kind = CanonicalNameParent(kind);
280 }
281 return StringEquals(CanonicalNameString(kind), "@factories");
282}

◆ IsField()

bool dart::kernel::TranslationHelper::IsField ( NameIndex  name)

Definition at line 284 of file kernel_translation_helper.cc.

284 {
285 // Fields with private names have the import URI of the library where they
286 // are visible as the parent and the string "@fields" as the parent's parent.
287 // Fields with non-private names have the string "@fields" as the parent.
288 if (IsRoot(name)) {
289 return false;
290 }
291 NameIndex kind = CanonicalNameParent(name);
292 if (IsPrivate(name)) {
293 kind = CanonicalNameParent(kind);
294 }
295 return StringEquals(CanonicalNameString(kind), "@fields");
296}

◆ IsGetter()

bool dart::kernel::TranslationHelper::IsGetter ( NameIndex  name)

Definition at line 241 of file kernel_translation_helper.cc.

241 {
242 // Getters with private names have the import URI of the library where they
243 // are visible as the parent and the string "@getters" as the parent's parent.
244 // Getters with non-private names have the string "@getters" as the parent.
245 if (IsRoot(name)) {
246 return false;
247 }
248 NameIndex kind = CanonicalNameParent(name);
249 if (IsPrivate(name)) {
250 kind = CanonicalNameParent(kind);
251 }
252 return StringEquals(CanonicalNameString(kind), "@getters");
253}

◆ IsLibrary()

bool dart::kernel::TranslationHelper::IsLibrary ( NameIndex  name)

Definition at line 192 of file kernel_translation_helper.cc.

192 {
193 // Libraries are the only canonical names with the root as their parent.
195}

◆ IsMember()

bool dart::kernel::TranslationHelper::IsMember ( NameIndex  name)

Definition at line 204 of file kernel_translation_helper.cc.

204 {
206}

◆ IsMethod()

bool dart::kernel::TranslationHelper::IsMethod ( NameIndex  name)

Definition at line 227 of file kernel_translation_helper.cc.

227 {
228 // Methods with private names have the import URI of the library where they
229 // are visible as the parent and the string "@methods" as the parent's parent.
230 // Methods with non-private names have the string "@methods" as the parent.
231 if (IsRoot(name)) {
232 return false;
233 }
234 NameIndex kind = CanonicalNameParent(name);
235 if (IsPrivate(name)) {
236 kind = CanonicalNameParent(kind);
237 }
238 return StringEquals(CanonicalNameString(kind), "@methods");
239}

◆ isolate_group()

IsolateGroup * dart::kernel::TranslationHelper::isolate_group ( )
inline

Definition at line 41 of file kernel_translation_helper.h.

41{ return isolate_group_; }

◆ IsPrivate()

bool dart::kernel::TranslationHelper::IsPrivate ( NameIndex  name)

Definition at line 182 of file kernel_translation_helper.cc.

182 {
183 // Private names start with '_'.
184 StringIndex name_string = CanonicalNameString(name);
185 return (StringSize(name_string) > 0) && (CharacterAt(name_string, 0) == '_');
186}

◆ IsProcedure()

bool dart::kernel::TranslationHelper::IsProcedure ( NameIndex  name)

Definition at line 223 of file kernel_translation_helper.cc.

223 {
224 return IsMethod(name) || IsGetter(name) || IsSetter(name) || IsFactory(name);
225}

◆ IsRoot()

bool dart::kernel::TranslationHelper::IsRoot ( NameIndex  name)

Definition at line 188 of file kernel_translation_helper.cc.

188 {
189 return name == -1;
190}

◆ IsSetter()

bool dart::kernel::TranslationHelper::IsSetter ( NameIndex  name)

Definition at line 255 of file kernel_translation_helper.cc.

255 {
256 // Setters with private names have the import URI of the library where they
257 // are visible as the parent and the string "@setters" as the parent's parent.
258 // Setters with non-private names have the string "@setters" as the parent.
259 if (IsRoot(name)) {
260 return false;
261 }
262 NameIndex kind = CanonicalNameParent(name);
263 if (IsPrivate(name)) {
264 kind = CanonicalNameParent(kind);
265 }
266 return StringEquals(CanonicalNameString(kind), "@setters");
267}

◆ LookupClassByKernelClass()

ClassPtr dart::kernel::TranslationHelper::LookupClassByKernelClass ( NameIndex  klass,
bool  required = true 
)
virtual

Reimplemented in dart::kernel::BuildingTranslationHelper.

Definition at line 542 of file kernel_translation_helper.cc.

543 {
544 ASSERT(IsClass(kernel_class));
545 {
546 name_index_handle_ = Smi::New(kernel_class);
547 ClassPtr raw_class = info_.LookupClass(thread_, name_index_handle_);
548 NoSafepointScope no_safepoint_scope(thread_);
549 if (raw_class != Class::null()) {
550 return raw_class;
551 }
552 }
553
554 const String& class_name = DartClassName(kernel_class);
555 NameIndex kernel_library = CanonicalNameParent(kernel_class);
556 Library& library = Library::Handle(
557 Z, LookupLibraryByKernelLibrary(kernel_library, /*required=*/false));
558 if (library.IsNull()) {
559 if (required) {
560 LookupFailed(kernel_class);
561 }
562 return Class::null();
563 }
564 const Class& klass =
565 Class::Handle(Z, library.LookupClassAllowPrivate(class_name));
566 if (klass.IsNull()) {
567 if (required) {
568 LookupFailed(kernel_class);
569 }
570 return Class::null();
571 }
572 name_index_handle_ = Smi::New(kernel_class);
573 return info_.InsertClass(thread_, name_index_handle_, klass);
574}
ClassPtr LookupClass(Thread *thread, const Smi &name_index) const
Definition: object.cc:15183
ClassPtr InsertClass(Thread *thread, const Smi &name_index, const Class &klass) const
Definition: object.cc:15205
static ObjectPtr null()
Definition: object.h:433
static SmiPtr New(intptr_t value)
Definition: object.h:10006
DART_NORETURN void LookupFailed(NameIndex name)
virtual LibraryPtr LookupLibraryByKernelLibrary(NameIndex library, bool required=true)
const char *const class_name

◆ LookupClassByKernelClassOrLibrary()

ClassPtr dart::kernel::TranslationHelper::LookupClassByKernelClassOrLibrary ( NameIndex  kernel_name,
bool  required = true 
)

Definition at line 576 of file kernel_translation_helper.cc.

578 {
579 if (IsLibrary(kernel_name)) {
580 const auto& library =
581 Library::Handle(Z, LookupLibraryByKernelLibrary(kernel_name, required));
582 if (library.IsNull()) {
583 return Class::null();
584 }
585 return library.toplevel_class();
586 } else {
587 ASSERT(IsClass(kernel_name));
588 return LookupClassByKernelClass(kernel_name, required);
589 }
590}
virtual ClassPtr LookupClassByKernelClass(NameIndex klass, bool required=true)

◆ LookupConstructorByKernelConstructor() [1/3]

FunctionPtr dart::kernel::TranslationHelper::LookupConstructorByKernelConstructor ( const Class owner,
NameIndex  constructor,
bool  required = true 
)

Definition at line 682 of file kernel_translation_helper.cc.

685 {
686 ASSERT(IsConstructor(constructor));
687 const auto& error = owner.EnsureIsFinalized(thread_);
689 Function& function = Function::Handle(
690 Z, owner.LookupConstructorAllowPrivate(DartConstructorName(constructor)));
691 if (function.IsNull() && required) {
692 LookupFailed(constructor);
693 }
694 return function.ptr();
695}
const uint8_t uint32_t uint32_t GError ** error
Dart_NativeFunction function
Definition: fuchsia.cc:51

◆ LookupConstructorByKernelConstructor() [2/3]

FunctionPtr dart::kernel::TranslationHelper::LookupConstructorByKernelConstructor ( const Class owner,
StringIndex  constructor_name,
bool  required = true 
)

Definition at line 697 of file kernel_translation_helper.cc.

700 {
701 GrowableHandlePtrArray<const String> pieces(Z, 3);
702 pieces.Add(String::Handle(Z, owner.Name()));
703 pieces.Add(Symbols::Dot());
704 String& name = DartSymbolPlain(constructor_name);
705 pieces.Add(ManglePrivateName(Library::Handle(owner.library()), &name));
706
707 String& new_name =
709 const auto& error = owner.EnsureIsFinalized(thread_);
711 FunctionPtr function = owner.LookupConstructorAllowPrivate(new_name);
712 if (function == Object::null() && required) {
713 LookupFailed(constructor_name);
714 }
715 return function;
716}
const String & DartSymbolPlain(const char *content) const

◆ LookupConstructorByKernelConstructor() [3/3]

FunctionPtr dart::kernel::TranslationHelper::LookupConstructorByKernelConstructor ( NameIndex  constructor,
bool  required = true 
)

Definition at line 664 of file kernel_translation_helper.cc.

666 {
667 ASSERT(IsConstructor(constructor));
668 Class& klass = Class::Handle(
669 Z,
670 LookupClassByKernelClass(EnclosingName(constructor), /*required=*/false));
671 Function& function = Function::Handle(Z);
672 if (!klass.IsNull()) {
674 /*required=*/false);
675 }
676 if (function.IsNull() && required) {
677 LookupFailed(constructor);
678 }
679 return function.ptr();
680}
FunctionPtr LookupConstructorByKernelConstructor(NameIndex constructor, bool required=true)

◆ LookupDynamicFunction()

FunctionPtr dart::kernel::TranslationHelper::LookupDynamicFunction ( const Class klass,
const String name 
)

Definition at line 764 of file kernel_translation_helper.cc.

765 {
766 // Search the superclass chain for the selector.
767 Class& iterate_klass = Class::Handle(Z, klass.ptr());
768 while (!iterate_klass.IsNull()) {
769 FunctionPtr function =
770 iterate_klass.LookupDynamicFunctionAllowPrivate(name);
771 if (function != Object::null()) {
772 return function;
773 }
774 iterate_klass = iterate_klass.SuperClass();
775 }
776 return Function::null();
777}

◆ LookupFailed() [1/2]

void dart::kernel::TranslationHelper::LookupFailed ( NameIndex  name)

Definition at line 493 of file kernel_translation_helper.cc.

493 {
494 String& message = String::Handle(String::New("Lookup failed: "));
497 while (!IsRoot(name)) {
501 }
502 Report::LongJump(LanguageError::Handle(LanguageError::New(message)));
503}
static DART_NORETURN void LongJump(const Error &error)
Definition: report.cc:86
static StringPtr Concat(const String &str1, const String &str2, Heap::Space space=Heap::kNew)
Definition: object.cc:24037
Win32Message message

◆ LookupFailed() [2/2]

void dart::kernel::TranslationHelper::LookupFailed ( StringIndex  name)

Definition at line 505 of file kernel_translation_helper.cc.

505 {
506 const String& message = String::Handle(String::Concat(
507 String::Handle(String::New("Lookup failed: ")), DartString(name)));
508 Report::LongJump(LanguageError::Handle(LanguageError::New(message)));
509}

◆ LookupFieldByKernelField()

FieldPtr dart::kernel::TranslationHelper::LookupFieldByKernelField ( NameIndex  field,
bool  required = true 
)

Definition at line 592 of file kernel_translation_helper.cc.

593 {
594 ASSERT(IsField(kernel_field));
595 NameIndex enclosing = EnclosingName(kernel_field);
596
597 const Class& klass = Class::Handle(
598 Z, LookupClassByKernelClassOrLibrary(enclosing, /*required=*/false));
599 if (klass.IsNull()) {
600 if (required) {
601 LookupFailed(kernel_field);
602 }
603 return Field::null();
604 }
605 Field& field = Field::Handle(
606 Z, klass.LookupFieldAllowPrivate(
608 if (field.IsNull() && required) {
609 LookupFailed(kernel_field);
610 }
611 return field.ptr();
612}
ClassPtr LookupClassByKernelClassOrLibrary(NameIndex kernel_name, bool required=true)
const String & DartSymbolObfuscate(const char *content) const

◆ LookupFieldByKernelGetterOrSetter()

FieldPtr dart::kernel::TranslationHelper::LookupFieldByKernelGetterOrSetter ( NameIndex  field,
bool  required = true 
)

Definition at line 614 of file kernel_translation_helper.cc.

616 {
617 ASSERT(IsGetter(kernel_field) || IsSetter(kernel_field));
618 NameIndex enclosing = EnclosingName(kernel_field);
619
620 const Class& klass = Class::Handle(
621 Z, LookupClassByKernelClassOrLibrary(enclosing, /*required=*/false));
622 if (klass.IsNull()) {
623 if (required) {
624 LookupFailed(kernel_field);
625 }
626 return Field::null();
627 }
628 const Field& field = Field::Handle(
629 Z, klass.LookupFieldAllowPrivate(
631 if (field.IsNull() && required) {
632 LookupFailed(kernel_field);
633 }
634 return field.ptr();
635}

◆ LookupLibraryByKernelLibrary()

LibraryPtr dart::kernel::TranslationHelper::LookupLibraryByKernelLibrary ( NameIndex  library,
bool  required = true 
)
virtual

Reimplemented in dart::kernel::BuildingTranslationHelper.

Definition at line 511 of file kernel_translation_helper.cc.

513 {
514 // We only use the string and don't rely on having any particular parent.
515 // This ASSERT is just a sanity check.
516 ASSERT(IsLibrary(kernel_library) ||
517 IsAdministrative(CanonicalNameParent(kernel_library)));
518 {
519 name_index_handle_ = Smi::New(kernel_library);
520 LibraryPtr raw_lib = info_.LookupLibrary(thread_, name_index_handle_);
521 NoSafepointScope no_safepoint_scope(thread_);
522 if (raw_lib != Library::null()) {
523 return raw_lib;
524 }
525 }
526
527 const String& library_name =
528 DartSymbolPlain(CanonicalNameString(kernel_library));
529 ASSERT(!library_name.IsNull());
530 const Library& library =
531 Library::Handle(Z, Library::LookupLibrary(thread_, library_name));
532 if (library.IsNull()) {
533 if (required) {
534 LookupFailed(kernel_library);
535 }
536 return Library::null();
537 }
538 name_index_handle_ = Smi::New(kernel_library);
539 return info_.InsertLibrary(thread_, name_index_handle_, library);
540}
LibraryPtr LookupLibrary(Thread *thread, const Smi &name_index) const
Definition: object.cc:15134
LibraryPtr InsertLibrary(Thread *thread, const Smi &name_index, const Library &lib) const
Definition: object.cc:15156
static LibraryPtr LookupLibrary(Thread *thread, const String &url)
Definition: object.cc:14599

◆ LookupMemberByMember()

ObjectPtr dart::kernel::TranslationHelper::LookupMemberByMember ( NameIndex  kernel_name,
bool  required = true 
)

Definition at line 734 of file kernel_translation_helper.cc.

735 {
736 // The parent is either a library or a class.
737 NameIndex enclosing = EnclosingName(kernel_name);
738 const Class& klass = Class::Handle(
739 Z, LookupClassByKernelClassOrLibrary(enclosing, /*required=*/false));
740 if (klass.IsNull()) {
741 if (required) {
742 LookupFailed(kernel_name);
743 }
744 return Object::null();
745 }
746
747 Object& member = Object::Handle(Z);
748 if (IsField(kernel_name)) {
749 member = klass.LookupFieldAllowPrivate(
751 } else {
752 const String& procedure_name = DartProcedureName(kernel_name);
753
754 const auto& error = klass.EnsureIsFinalized(thread_);
756 member = klass.LookupFunctionAllowPrivate(procedure_name);
757 }
758 if (member.IsNull() && required) {
759 LookupFailed(kernel_name);
760 }
761 return member.ptr();
762}
const String & DartProcedureName(NameIndex procedure)

◆ LookupMethodByMember()

FunctionPtr dart::kernel::TranslationHelper::LookupMethodByMember ( NameIndex  target,
const String method_name,
bool  required = true 
)

Definition at line 718 of file kernel_translation_helper.cc.

720 {
721 NameIndex kernel_class = EnclosingName(target);
722 Class& klass = Class::Handle(
723 Z, LookupClassByKernelClass(kernel_class, /*required=*/false));
724 Function& function = Function::Handle(Z);
725 if (!klass.IsNull() && klass.EnsureIsFinalized(thread_) == Error::null()) {
726 function = klass.LookupFunctionAllowPrivate(method_name);
727 }
728 if (function.IsNull() && required) {
730 }
731 return function.ptr();
732}
uint32_t * target

◆ LookupStaticMethodByKernelProcedure()

FunctionPtr dart::kernel::TranslationHelper::LookupStaticMethodByKernelProcedure ( NameIndex  procedure,
bool  required = true 
)

Definition at line 637 of file kernel_translation_helper.cc.

639 {
640 const String& procedure_name = DartProcedureName(procedure);
641
642 // The parent is either a library or a class (in which case the procedure is a
643 // static method).
644 NameIndex enclosing = EnclosingName(procedure);
645 const Class& klass = Class::Handle(
646 Z, LookupClassByKernelClassOrLibrary(enclosing, /*required=*/false));
647 if (klass.IsNull()) {
648 if (required) {
649 LookupFailed(procedure);
650 }
651 return Function::null();
652 }
653
654 const auto& error = klass.EnsureIsFinalized(thread_);
656 Function& function =
657 Function::Handle(Z, klass.LookupFunctionAllowPrivate(procedure_name));
658 if (function.IsNull() && required) {
659 LookupFailed(procedure);
660 }
661 return function.ptr();
662}

◆ metadata_mappings()

const TypedDataView & dart::kernel::TranslationHelper::metadata_mappings ( ) const
inline

Definition at line 58 of file kernel_translation_helper.h.

58{ return metadata_mappings_; }

◆ metadata_payloads()

const TypedDataView & dart::kernel::TranslationHelper::metadata_payloads ( ) const
inline

Definition at line 55 of file kernel_translation_helper.h.

55{ return metadata_payloads_; }

◆ ReportError() [1/4]

void dart::kernel::TranslationHelper::ReportError ( const char *  format,
  ... 
)

Definition at line 840 of file kernel_translation_helper.cc.

840 {
841 const Script& null_script = Script::Handle(Z);
842
843 va_list args;
845 Report::MessageV(Report::kError, null_script, TokenPosition::kNoSource,
847 va_end(args);
848 UNREACHABLE();
849}
#define UNREACHABLE()
Definition: assert.h:248
static void static void MessageV(Kind kind, const Script &script, TokenPosition token_pos, bool report_after_token, const char *format, va_list args)
Definition: report.cc:135
static constexpr bool AtLocation
Definition: report.h:29
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
uint32_t uint32_t * format
va_start(args, format)
va_end(args)

◆ ReportError() [2/4]

void dart::kernel::TranslationHelper::ReportError ( const Error prev_error,
const char *  format,
  ... 
)

Definition at line 863 of file kernel_translation_helper.cc.

865 {
866 const Script& null_script = Script::Handle(Z);
867
868 va_list args;
870 Report::LongJumpV(prev_error, null_script, TokenPosition::kNoSource, format,
871 args);
872 va_end(args);
873 UNREACHABLE();
874}
static DART_NORETURN void static DART_NORETURN void LongJumpV(const Error &prev_error, const Script &script, TokenPosition token_pos, const char *format, va_list args)
Definition: report.cc:103

◆ ReportError() [3/4]

void dart::kernel::TranslationHelper::ReportError ( const Error prev_error,
const Script script,
const TokenPosition  position,
const char *  format,
  ... 
)

Definition at line 876 of file kernel_translation_helper.cc.

880 {
881 va_list args;
883 Report::LongJumpV(prev_error, script, position, format, args);
884 va_end(args);
885 UNREACHABLE();
886}

◆ ReportError() [4/4]

void dart::kernel::TranslationHelper::ReportError ( const Script script,
const TokenPosition  position,
const char *  format,
  ... 
)

Definition at line 851 of file kernel_translation_helper.cc.

854 {
855 va_list args;
858 args);
859 va_end(args);
860 UNREACHABLE();
861}

◆ Reset()

void dart::kernel::TranslationHelper::Reset ( )

Definition at line 57 of file kernel_translation_helper.cc.

57 {
58 string_offsets_ = TypedData::null();
59 string_data_ = TypedDataView::null();
60 canonical_names_ = TypedData::null();
61 metadata_payloads_ = TypedDataView::null();
62 metadata_mappings_ = TypedDataView::null();
63 constants_ = Array::null();
64}

◆ SetCanonicalNames()

void dart::kernel::TranslationHelper::SetCanonicalNames ( const TypedData canonical_names)

Definition at line 94 of file kernel_translation_helper.cc.

94 {
95 ASSERT(canonical_names_.IsNull());
96 canonical_names_ = canonical_names.ptr();
97}
bool IsNull() const
Definition: object.h:363
const TypedData & canonical_names() const

◆ SetConstants()

void dart::kernel::TranslationHelper::SetConstants ( const Array constants)

Definition at line 112 of file kernel_translation_helper.cc.

112 {
113 ASSERT(constants_.IsNull() ||
114 (constants.IsNull() || constants.Length() == 0));
115 constants_ = constants.ptr();
116}
intptr_t Length() const
Definition: object.h:10829

◆ SetConstantsTable()

void dart::kernel::TranslationHelper::SetConstantsTable ( const TypedDataView constants_table)

Definition at line 118 of file kernel_translation_helper.cc.

119 {
120 ASSERT(constants_table_.IsNull());
121 constants_table_ = constants_table.ptr();
122}
const TypedDataView & constants_table() const

◆ SetExpressionEvaluationClass()

void dart::kernel::TranslationHelper::SetExpressionEvaluationClass ( const Class cls)
inline

Definition at line 210 of file kernel_translation_helper.h.

210 {
211 ASSERT(expression_evaluation_class_ == nullptr);
212 ASSERT(!cls.IsNull());
213 expression_evaluation_class_ = &Class::Handle(zone_, cls.ptr());
214 }

◆ SetExpressionEvaluationFunction()

void void void void void dart::kernel::TranslationHelper::SetExpressionEvaluationFunction ( const Function function)
inline

Definition at line 200 of file kernel_translation_helper.h.

200 {
201 ASSERT(expression_evaluation_function_ == nullptr);
202 expression_evaluation_function_ = &Function::Handle(zone_, function.ptr());
203 }

◆ SetExpressionEvaluationRealClass()

void dart::kernel::TranslationHelper::SetExpressionEvaluationRealClass ( const Class real_class)
inline

Definition at line 221 of file kernel_translation_helper.h.

221 {
222 ASSERT(expression_evaluation_real_class_ == nullptr);
223 ASSERT(!real_class.IsNull());
224 expression_evaluation_real_class_ = &Class::Handle(zone_, real_class.ptr());
225 }

◆ SetKernelProgramInfo()

void dart::kernel::TranslationHelper::SetKernelProgramInfo ( const KernelProgramInfo info)

Definition at line 124 of file kernel_translation_helper.cc.

124 {
125 info_ = info.ptr();
126}

◆ SetMetadataMappings()

void dart::kernel::TranslationHelper::SetMetadataMappings ( const TypedDataView metadata_mappings)

Definition at line 106 of file kernel_translation_helper.cc.

107 {
108 ASSERT(metadata_mappings_.IsNull());
109 metadata_mappings_ = metadata_mappings.ptr();
110}
const TypedDataView & metadata_mappings() const

◆ SetMetadataPayloads()

void dart::kernel::TranslationHelper::SetMetadataPayloads ( const TypedDataView metadata_payloads)

Definition at line 99 of file kernel_translation_helper.cc.

100 {
101 ASSERT(metadata_payloads_.IsNull());
103 metadata_payloads_ = metadata_payloads.ptr();
104}
void * DataAddr(intptr_t byte_offset) const
Definition: object.h:11571
static constexpr bool IsAligned(T x, uintptr_t alignment, uintptr_t offset=0)
Definition: utils.h:92
const TypedDataView & metadata_payloads() const
constexpr intptr_t kWordSize
Definition: globals.h:509

◆ SetStringData()

void dart::kernel::TranslationHelper::SetStringData ( const TypedDataView string_data)

Definition at line 89 of file kernel_translation_helper.cc.

89 {
90 ASSERT(string_data_.IsNull());
91 string_data_ = string_data.ptr();
92}
const TypedDataView & string_data() const

◆ SetStringOffsets()

void dart::kernel::TranslationHelper::SetStringOffsets ( const TypedData string_offsets)

Definition at line 84 of file kernel_translation_helper.cc.

84 {
85 ASSERT(string_offsets_.IsNull());
86 string_offsets_ = string_offsets.ptr();
87}
const TypedData & string_offsets() const

◆ SetupFieldAccessorFunction()

void dart::kernel::TranslationHelper::SetupFieldAccessorFunction ( const Class klass,
const Function function,
const AbstractType field_type 
)

Definition at line 810 of file kernel_translation_helper.cc.

813 {
814 bool is_setter = function.IsImplicitSetterFunction();
815 bool is_method = !function.IsStaticFunction();
816 intptr_t parameter_count = (is_method ? 1 : 0) + (is_setter ? 1 : 0);
817
818 const FunctionType& signature = FunctionType::Handle(Z, function.signature());
819 signature.SetNumOptionalParameters(0, false);
820 signature.set_num_fixed_parameters(parameter_count);
821 if (parameter_count > 0) {
822 signature.set_parameter_types(
823 Array::Handle(Z, Array::New(parameter_count, Heap::kOld)));
824 }
825 function.CreateNameArray();
826
827 intptr_t pos = 0;
828 if (is_method) {
829 signature.SetParameterTypeAt(pos, GetDeclarationType(klass));
830 function.SetParameterNameAt(pos, Symbols::This());
831 pos++;
832 }
833 if (is_setter) {
834 signature.SetParameterTypeAt(pos, field_type);
835 function.SetParameterNameAt(pos, Symbols::Value());
836 pos++;
837 }
838}
SkPoint pos
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition: object.h:10959
@ kOld
Definition: heap.h:39
static const String & This()
Definition: symbols.h:692

◆ string_data()

const TypedDataView & dart::kernel::TranslationHelper::string_data ( ) const
inline

Definition at line 49 of file kernel_translation_helper.h.

49{ return string_data_; }

◆ string_offsets()

const TypedData & dart::kernel::TranslationHelper::string_offsets ( ) const
inline

Definition at line 46 of file kernel_translation_helper.h.

46{ return string_offsets_; }

◆ StringBuffer()

uint8_t * dart::kernel::TranslationHelper::StringBuffer ( StringIndex  index) const

Definition at line 142 of file kernel_translation_helper.cc.

142 {
143 // Though this implementation appears like it could be replaced by
144 // string_data_.DataAddr(StringOffset(string_index)), it can't quite. If the
145 // last string in the string table is a zero length string, then the latter
146 // expression will try to return the address that is one past the backing
147 // store of the string_data_ table. Though this is safe in C++ as long as the
148 // address is not dereferenced, it will trigger the assert in
149 // ExternalTypedData::DataAddr.
150 ASSERT(Thread::Current()->no_safepoint_scope_depth() > 0);
151 return reinterpret_cast<uint8_t*>(string_data_.DataAddr(0)) +
152 StringOffset(string_index);
153}
static Thread * Current()
Definition: thread.h:362

◆ StringEquals()

bool dart::kernel::TranslationHelper::StringEquals ( StringIndex  string_index,
const char *  other 
)

Definition at line 155 of file kernel_translation_helper.cc.

156 {
157 intptr_t length = strlen(other);
158 if (length != StringSize(string_index)) return false;
159
160 NoSafepointScope no_safepoint;
161 return memcmp(StringBuffer(string_index), other, length) == 0;
162}

◆ StringOffset()

intptr_t dart::kernel::TranslationHelper::StringOffset ( StringIndex  index) const

Definition at line 128 of file kernel_translation_helper.cc.

128 {
129 return string_offsets_.GetUint32(index << 2);
130}

◆ StringSize()

intptr_t dart::kernel::TranslationHelper::StringSize ( StringIndex  index) const

Definition at line 132 of file kernel_translation_helper.cc.

132 {
133 return StringOffset(StringIndex(index + 1)) - StringOffset(index);
134}

◆ thread()

Thread * dart::kernel::TranslationHelper::thread ( )
inline

Definition at line 37 of file kernel_translation_helper.h.

37{ return thread_; }

◆ zone()

Zone * dart::kernel::TranslationHelper::zone ( )
inline

Definition at line 39 of file kernel_translation_helper.h.

39{ return zone_; }

The documentation for this class was generated from the following files: