• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 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 PANDA_ASSEMBLER_ASSEMBLY_RECORD_H
17 #define PANDA_ASSEMBLER_ASSEMBLY_RECORD_H
18 
19 #include <memory>
20 #include <optional>
21 #include <string>
22 #include <vector>
23 
24 #include "assembly-field.h"
25 #include "extensions/extensions.h"
26 #include "ide_helpers.h"
27 
28 namespace ark::pandasm {
29 
30 // NOLINTBEGIN(misc-non-private-member-variables-in-classes)
31 struct Record {
32     std::string name;
33     bool conflict = false; /* Name is conflict with panda primitive types. Need special handle. */
34     ark::panda_file::SourceLang language;
35     std::unique_ptr<RecordMetadata> metadata;
36     std::vector<Field> fieldList; /* class fields list */
37     size_t paramsNum = 0;
38     bool bodyPresence = false;
39     SourceLocation bodyLocation;
40     std::string sourceFile; /* The file in which the record is defined or empty */
41     std::optional<FileLocation> fileLocation;
42 
RecordRecord43     Record(std::string s, ark::panda_file::SourceLang lang, size_t bL, size_t bR, std::string fC, bool d, size_t lN)
44         : name(std::move(s)),
45           language(lang),
46           metadata(extensions::MetadataExtension::CreateRecordMetadata(lang)),
47           fileLocation({fC, bL, bR, lN, d})
48     {
49     }
50 
RecordRecord51     Record(std::string s, ark::panda_file::SourceLang lang)
52         : name(std::move(s)), language(lang), metadata(extensions::MetadataExtension::CreateRecordMetadata(lang))
53     {
54     }
55 
HasImplementationRecord56     bool HasImplementation() const
57     {
58         return !metadata->IsForeign();
59     }
60 };
61 // NOLINTEND(misc-non-private-member-variables-in-classes)
62 
63 }  // namespace ark::pandasm
64 
65 #endif  // PANDA_ASSEMBLER_ASSEMBLY_RECORD_H
66