• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-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 ASSEMBLER_ASSEMBLY_RECORD_H
17 #define 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 panda::pandasm {
29 
30 struct Record {
31     std::string name = "";
32     bool conflict = false; /* Name is conflict with panda primitive types. Need special handle. */
33     panda::panda_file::SourceLang language;
34     std::unique_ptr<RecordMetadata> metadata;
35     std::vector<Field> field_list; /* class fields list */
36     size_t params_num = 0;
37     bool body_presence = false;
38     SourceLocation body_location;
39     std::string source_file; /* The file in which the record is defined or empty */
40     std::optional<FileLocation> file_location;
41 
RecordRecord42     Record(std::string s, panda::panda_file::SourceLang lang, size_t b_l, size_t b_r, std::string f_c, bool d,
43            size_t l_n)
44         : name(std::move(s)),
45           language(lang),
46           metadata(extensions::MetadataExtension::CreateRecordMetadata(lang)),
47           file_location({f_c, b_l, b_r, l_n, d})
48     {
49     }
50 
RecordRecord51     Record(std::string s, panda::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 
62 }  // namespace panda::pandasm
63 
64 #endif  // ASSEMBLER_ASSEMBLY_RECORD_H
65