1/* 2 * Copyright (c) 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_UTIL_CONCURRENT_H 17#define ES2PANDA_UTIL_CONCURRENT_H 18 19#include <util/ustring.h> 20 21namespace panda::es2panda::compiler { 22class PandaGen; 23} // namespace panda::es2panda::compiler 24 25namespace panda::es2panda::ir { 26class AstNode; 27class BlockStatement; 28class ScriptFunction; 29} // namespace panda::es2panda::ir 30 31namespace panda::es2panda::binder { 32class ScopeFindResult; 33} // namespace panda::es2panda::binder 34 35namespace panda::es2panda::lexer { 36class LineIndex; 37} // namespace panda::es2panda::lexer 38 39namespace panda::es2panda::parser { 40class Program; 41} 42 43namespace panda::es2panda::util { 44 45enum class ConcurrentInvalidFlag { 46 NOT_ORDINARY_FUNCTION = 1, 47 NOT_IMPORT_VARIABLE = 2 48}; 49 50class Concurrent { 51public: 52 Concurrent() = delete; 53 54 static void SetConcurrent(ir::ScriptFunction *func, const ir::AstNode *node, const lexer::LineIndex &lineIndex); 55 static void ThrowInvalidConcurrentFunction(const lexer::LineIndex &lineIndex, const ir::AstNode *expr, 56 ConcurrentInvalidFlag errFlag, util::StringView varName = ""); 57 static void CollectRelativeModule(const binder::ScopeFindResult &result, parser::Program *program); 58 static void ProcessConcurrent(const lexer::LineIndex &lineIndex, const ir::AstNode *node, 59 const binder::ScopeFindResult &result, parser::Program *program); 60}; 61 62} // namespace panda::es2panda::util 63 64#endif