• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-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_DEBUG_INFO_H
17 #define PANDA_DEBUG_INFO_H
18 
19 #include <string>
20 #include <limits>
21 
22 namespace ark::compiler {
23 
24 class InstDebugInfo {
25 public:
26     static constexpr uint32_t INVALID_LINE_NUMBER = std::numeric_limits<uint32_t>::max();
27     static constexpr uint32_t INVALID_FILE_INDEX = std::numeric_limits<uint32_t>::max();
28     static constexpr uint32_t INVALID_DIR_INDEX = std::numeric_limits<uint32_t>::max();
29 
InstDebugInfo(uint32_t dirIndex,uint32_t fileIndex,uint32_t lineNumber)30     InstDebugInfo(uint32_t dirIndex, uint32_t fileIndex, uint32_t lineNumber)
31         : dirIndex_(dirIndex), fileIndex_(fileIndex), lineNumber_(lineNumber)
32     {
33     }
34 
GetLineNumber()35     uint32_t GetLineNumber() const
36     {
37         return lineNumber_;
38     }
39 
GetFileIndex()40     uint32_t GetFileIndex() const
41     {
42         return fileIndex_;
43     }
44 
GetDirIndex()45     uint32_t GetDirIndex() const
46     {
47         return dirIndex_;
48     }
49 
GetOffset()50     size_t GetOffset() const
51     {
52         return offset_;
53     }
54 
SetOffset(size_t offset)55     void SetOffset(size_t offset)
56     {
57         offset_ = offset;
58     }
59 
60 private:
61     uint32_t dirIndex_ {INVALID_DIR_INDEX};
62     uint32_t fileIndex_ {INVALID_FILE_INDEX};
63     uint32_t lineNumber_ {INVALID_LINE_NUMBER};
64     size_t offset_ {0};
65 };
66 
67 }  // namespace ark::compiler
68 
69 #endif  // PANDA_DEBUG_INFO_H
70