• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2025 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 #include <iostream>
17 #include <ostream>
18 #include <string>
19 
20 #include "os/library_loader.h"
21 
22 #include "public/es2panda_lib.h"
23 #include "util.h"
24 
25 // NOLINTBEGIN
26 
27 static es2panda_Impl *impl = nullptr;
28 
main(int argc,char ** argv)29 int main(int argc, char **argv)
30 {
31     if (argc < MIN_ARGC) {
32         return INVALID_ARGC_ERROR_CODE;
33     }
34 
35     if (GetImpl() == nullptr) {
36         return NULLPTR_IMPL_ERROR_CODE;
37     }
38     impl = GetImpl();
39     std::cout << "LOAD SUCCESS" << std::endl;
40 
41     const char **args = const_cast<const char **>(&(argv[1]));
42     auto config = impl->CreateConfig(argc - 1, args);
43     auto context = impl->CreateContextFromFile(config, argv[argc - 1]);
44     if (context == nullptr) {
45         std::cerr << "FAILED TO CREATE CONTEXT" << std::endl;
46         return NULLPTR_CONTEXT_ERROR_CODE;
47     }
48 
49     impl->ProceedToState(context, ES2PANDA_STATE_PARSED);
50     CheckForErrors("PARSE", context);
51 
52     impl->ProceedToState(context, ES2PANDA_STATE_BOUND);
53     CheckForErrors("BOUND", context);
54 
55     impl->ProceedToState(context, ES2PANDA_STATE_CHECKED);
56     CheckForErrors("CHECKED", context);
57 
58     impl->AstNodeRecheck(context, impl->ProgramAst(context, impl->ContextProgram(context)));
59 
60     impl->ProceedToState(context, ES2PANDA_STATE_LOWERED);
61     CheckForErrors("LOWERED", context);
62 
63     impl->ProceedToState(context, ES2PANDA_STATE_ASM_GENERATED);
64     CheckForErrors("ASM", context);
65 
66     impl->ProceedToState(context, ES2PANDA_STATE_BIN_GENERATED);
67     CheckForErrors("BIN", context);
68     impl->DestroyConfig(config);
69 
70     return 0;
71 }
72 
73 // NOLINTEND
74