1/** 2 * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#ifndef ES2PANDA_PUBLIC_PUBLIC_H 17#define ES2PANDA_PUBLIC_PUBLIC_H 18 19#include "public/es2panda_lib.h" 20 21#include "assembler/assembly-program.h" 22#include "libpandabase/mem/arena_allocator.h" 23 24#include "es2panda.h" 25#include "compiler/core/compileQueue.h" 26#include "parser/ETSparser.h" 27#include "checker/checker.h" 28#include "compiler/core/emitter.h" 29#include "util/options.h" 30 31namespace ark::es2panda::compiler { 32class Phase; 33} // namespace ark::es2panda::compiler 34 35namespace ark::es2panda::public_lib { 36struct ConfigImpl { 37 const util::Options *options; 38}; 39 40struct Context { 41 using CodeGenCb = 42 std::function<void(public_lib::Context *context, varbinder::FunctionScope *, compiler::ProgramElement *)>; 43 44 ConfigImpl *config = nullptr; 45 std::string sourceFileName; 46 std::string input; 47 SourceFile const *sourceFile = nullptr; 48 ArenaAllocator *allocator = nullptr; 49 compiler::CompileQueue *queue = nullptr; 50 std::vector<util::Plugin> const *plugins = nullptr; 51 std::vector<compiler::Phase *> phases; 52 std::vector<compiler::LiteralBuffer> contextLiterals; 53 CodeGenCb codeGenCb; 54 size_t currentPhase = 0; 55 56 parser::Program *parserProgram = nullptr; 57 parser::ParserImpl *parser = nullptr; 58 checker::Checker *checker = nullptr; 59 checker::SemanticAnalyzer *analyzer = nullptr; 60 compiler::Emitter *emitter = nullptr; 61 pandasm::Program *program = nullptr; 62 63 es2panda_ContextState state = ES2PANDA_STATE_NEW; 64 std::string errorMessage; 65 lexer::SourcePosition errorPos; 66}; 67} // namespace ark::es2panda::public_lib 68 69#endif 70