• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 panda::pandasm {
29 
30 struct Record {
31     std::string name = "";
32     bool conflict = false; /* Name conflicts with panda primitive types. Need special handle. */
33     extensions::Language 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, extensions::Language lang, size_t b_l, size_t b_r, std::string f_c, bool d, size_t l_n)
43         : name(std::move(s)),
44           language(lang),
45           metadata(extensions::MetadataExtension::CreateRecordMetadata(lang)),
46           file_location({f_c, b_l, b_r, l_n, d})
47     {
48     }
49 
RecordRecord50     Record(std::string s, extensions::Language lang)
51         : name(std::move(s)), language(lang), metadata(extensions::MetadataExtension::CreateRecordMetadata(lang))
52     {
53     }
54 
HasImplementationRecord55     bool HasImplementation() const
56     {
57         return !metadata->IsForeign();
58     }
59 };
60 
61 }  // namespace panda::pandasm
62 
63 #endif  // PANDA_ASSEMBLER_ASSEMBLY_RECORD_H_
64