1// Copyright (c) 2019, 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_BYTECODE_SCOPE_BUILDER_H_
6#define RUNTIME_VM_COMPILER_FRONTEND_BYTECODE_SCOPE_BUILDER_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
12#include "vm/object.h"
13#include "vm/parser.h" // For ParsedFunction.
14#include "vm/scopes.h"
15
16namespace dart {
17namespace kernel {
18
19// Builds scopes, populates parameters and local variables for
20// certain functions declared in bytecode.
21class BytecodeScopeBuilder : public ValueObject {
22 public:
23 explicit BytecodeScopeBuilder(ParsedFunction* parsed_function);
24
25 void BuildScopes();
26
27 private:
28 void AddParameters(const Function& function,
29 LocalVariable::TypeCheckMode mode);
30 LocalVariable* MakeVariable(const String& name, const AbstractType& type);
31 LocalVariable* MakeReceiverVariable(bool is_parameter);
32
33 ParsedFunction* parsed_function_;
34 Zone* zone_;
35 LocalScope* scope_;
36};
37
38} // namespace kernel
39} // namespace dart
40
41#endif // RUNTIME_VM_COMPILER_FRONTEND_BYTECODE_SCOPE_BUILDER_H_
42