1 /** 2 * Copyright (c) 2021-2022 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 31 namespace panda::es2panda::compiler { 32 class Phase; 33 } // namespace panda::es2panda::compiler 34 35 namespace panda::es2panda::public_lib { 36 struct ConfigImpl { 37 util::Options *options; 38 }; 39 40 struct Context { 41 ConfigImpl *config = nullptr; 42 std::string sourceFileName; 43 std::string input; 44 SourceFile const *sourceFile = nullptr; 45 ArenaAllocator *allocator = nullptr; 46 compiler::CompileQueue *queue = nullptr; 47 std::vector<util::Plugin> const *plugins = nullptr; 48 std::vector<compiler::Phase *> phases; 49 size_t currentPhase = 0; 50 51 parser::Program *parserProgram = nullptr; 52 parser::ParserImpl *parser = nullptr; 53 checker::Checker *checker = nullptr; 54 checker::SemanticAnalyzer *analyzer = nullptr; 55 compiler::CompilerContext *compilerContext = nullptr; 56 compiler::Emitter *emitter = nullptr; 57 pandasm::Program *program = nullptr; 58 59 es2panda_ContextState state = ES2PANDA_STATE_NEW; 60 std::string errorMessage; 61 lexer::SourcePosition errorPos; 62 }; 63 } // namespace panda::es2panda::public_lib 64 65 #endif 66