Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
constant_reader.h
Go to the documentation of this file.
1// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
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.
4
5#ifndef RUNTIME_VM_COMPILER_FRONTEND_CONSTANT_READER_H_
6#define RUNTIME_VM_COMPILER_FRONTEND_CONSTANT_READER_H_
7
8#if defined(DART_PRECOMPILED_RUNTIME)
9#error "AOT runtime should not use compiler sources (including header files)"
10#endif // defined(DART_PRECOMPILED_RUNTIME)
11
13#include "vm/hash_table.h"
14#include "vm/object.h"
15
16namespace dart {
17namespace kernel {
18
19// Reads and caches constants from the kernel constant pool.
21 public:
22 ConstantReader(KernelReaderHelper* helper, ActiveClass* active_class);
23
24 virtual ~ConstantReader() {}
25
26 bool IsPragmaInstanceConstant(intptr_t constant_index,
27 intptr_t* pragma_name_constant_index,
28 intptr_t* pragma_options_constant_index);
29 bool IsStringConstant(intptr_t constant_index, const char* name);
30 bool GetStringConstant(intptr_t constant_index, String* out_value);
31
32 InstancePtr ReadConstantInitializer();
33 InstancePtr ReadConstantExpression();
35
36 // Peeks to see if constant at the given index will evaluate to
37 // instance of the given clazz.
38 bool IsInstanceConstant(intptr_t constant_index, const Class& clazz);
39
40 // Reads a constant at the given index (possibly by recursing
41 // into sub-constants).
42 InstancePtr ReadConstant(intptr_t constant_index);
43
44 intptr_t NumConstants();
45
46 private:
47 InstancePtr ReadConstantInternal(intptr_t constant_index);
48 intptr_t NavigateToIndex(KernelReaderHelper* reader, intptr_t constant_index);
49 intptr_t NumConstants(KernelReaderHelper* reader);
50
51 ScriptPtr Script() {
52 if (active_class_ != nullptr) {
53 return active_class_->ActiveScript();
54 }
55 return Script::null();
56 }
57
58 KernelReaderHelper* helper_;
59 Zone* zone_;
60 TranslationHelper& translation_helper_;
61 ActiveClass* active_class_;
62 Object& result_;
63
64 DISALLOW_COPY_AND_ASSIGN(ConstantReader);
65};
66
67} // namespace kernel
68} // namespace dart
69
70#endif // RUNTIME_VM_COMPILER_FRONTEND_CONSTANT_READER_H_
static ObjectPtr null()
Definition object.h:433
bool IsStringConstant(intptr_t constant_index, const char *name)
bool IsInstanceConstant(intptr_t constant_index, const Class &clazz)
InstancePtr ReadConstant(intptr_t constant_index)
bool GetStringConstant(intptr_t constant_index, String *out_value)
bool IsPragmaInstanceConstant(intptr_t constant_index, intptr_t *pragma_name_constant_index, intptr_t *pragma_options_constant_index)
const char *const name
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition globals.h:581