• 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 } // namespace panda::es2panda::lexer
38 
39 namespace panda::es2panda::parser {
40 class Program;
41 }
42 
43 namespace panda::es2panda::util {
44 
45 enum class ConcurrentInvalidFlag {
46     NOT_ORDINARY_FUNCTION = 1,
47     NOT_IMPORT_VARIABLE = 2
48 };
49 
50 class Concurrent {
51 public:
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