• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
21 namespace panda::es2panda::compiler {
22 class PandaGen;
23 } // namespace panda::es2panda::compiler
24 
25 namespace panda::es2panda::ir {
26 class AstNode;
27 class BlockStatement;
28 class ScriptFunction;
29 } // namespace panda::es2panda::ir
30 
31 namespace panda::es2panda::binder {
32 class ScopeFindResult;
33 } // namespace panda::es2panda::binder
34 
35 namespace panda::es2panda::lexer {
36 class LineIndex;
37 }
38 
39 namespace panda::es2panda::util {
40 
41 enum class ConcurrentInvalidFlag {
42     NOT_ORDINARY_FUNCTION = 1,
43     NOT_IMPORT_VARIABLE = 2
44 };
45 
46 class Concurrent {
47 public:
48     Concurrent() = delete;
49 
50     static void SetConcurrent(ir::ScriptFunction *func, const ir::AstNode *node, const lexer::LineIndex &lineIndex);
51     static void ThrowInvalidConcurrentFunction(const lexer::LineIndex &lineIndex, const ir::AstNode *expr,
52                                                ConcurrentInvalidFlag errFlag, util::StringView varName = "");
53     static void VerifyImportVarForConcurrentFunction(const lexer::LineIndex &lineIndex, const ir::AstNode *node,
54                                             const binder::ScopeFindResult &result);
55 };
56 
57 } // namespace panda::es2panda::util
58 
59 #endif