|
| 1 | +# ------------------------------------------------------------------------------ |
| 2 | +# CodeHawk C Analyzer |
| 3 | +# Author: Henny Sipma |
| 4 | +# ------------------------------------------------------------------------------ |
| 5 | +# The MIT License (MIT) |
| 6 | +# |
| 7 | +# Copyright (c) 2025 Aarno Labs LLC |
| 8 | +# |
| 9 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 10 | +# of this software and associated documentation files (the "Software"), to deal |
| 11 | +# in the Software without restriction, including without limitation the rights |
| 12 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 13 | +# copies of the Software, and to permit persons to whom the Software is |
| 14 | +# furnished to do so, subject to the following conditions: |
| 15 | +# |
| 16 | +# The above copyright notice and this permission notice shall be included in all |
| 17 | +# copies or substantial portions of the Software. |
| 18 | +# |
| 19 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 22 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 23 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 24 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 25 | +# SOFTWARE. |
| 26 | +# ------------------------------------------------------------------------------ |
| 27 | + |
| 28 | +from typing import List, TYPE_CHECKING |
| 29 | + |
| 30 | +from chc.proof.CFunPODictionaryRecord import CFunPODictionaryRecord, podregistry |
| 31 | + |
| 32 | + |
| 33 | +from chc.util.IndexedTable import IndexedTableValue |
| 34 | + |
| 35 | + |
| 36 | +if TYPE_CHECKING: |
| 37 | + from chc.app.CCompInfo import CCompInfo |
| 38 | + from chc.app.CDictionary import CDictionary |
| 39 | + from chc.app.CTyp import CTyp |
| 40 | + from chc.proof.CFunPODictionary import CFunPODictionary |
| 41 | + |
| 42 | + |
| 43 | +class OutputParameterRejectionReason(CFunPODictionaryRecord): |
| 44 | + |
| 45 | + def __init__( |
| 46 | + self, pod: "CFunPODictionary", ixval: IndexedTableValue |
| 47 | + ) -> None: |
| 48 | + CFunPODictionaryRecord.__init__(self, pod, ixval) |
| 49 | + |
| 50 | + |
| 51 | +@podregistry.register_tag("a", OutputParameterRejectionReason) |
| 52 | +class OutputParameterRejectionReasonArrayStruct(OutputParameterRejectionReason): |
| 53 | + |
| 54 | + def __init__( |
| 55 | + self, pod: "CFunPODictionary", ixval: IndexedTableValue |
| 56 | + ) -> None: |
| 57 | + OutputParameterRejectionReason.__init__(self, pod, ixval) |
| 58 | + |
| 59 | + @property |
| 60 | + def compinfo(self) -> "CCompInfo": |
| 61 | + return self.cdecls.get_compinfo(self.args[0]) |
| 62 | + |
| 63 | + def __str__(self) -> str: |
| 64 | + return "Struct with embedded array: " + str(self.compinfo) |
| 65 | + |
| 66 | + |
| 67 | +@podregistry.register_tag("at", OutputParameterRejectionReason) |
| 68 | +class OutputParameterRejectionReasonArrayType(OutputParameterRejectionReason): |
| 69 | + |
| 70 | + def __init__( |
| 71 | + self, pod: "CFunPODictionary", ixval: IndexedTableValue |
| 72 | + ) -> None: |
| 73 | + OutputParameterRejectionReason.__init__(self, pod, ixval) |
| 74 | + |
| 75 | + @property |
| 76 | + def typ(self) -> "CTyp": |
| 77 | + return self.cdictionary.get_typ(self.args[0]) |
| 78 | + |
| 79 | + def __str__(self) -> str: |
| 80 | + return "rray type: " + str(self.typ) |
| 81 | + |
| 82 | + |
| 83 | +@podregistry.register_tag("c", OutputParameterRejectionReason) |
| 84 | +class OutputParameterRejectionReasonConstQualifier(OutputParameterRejectionReason): |
| 85 | + |
| 86 | + def __init__( |
| 87 | + self, pod: "CFunPODictionary", ixval: IndexedTableValue |
| 88 | + ) -> None: |
| 89 | + OutputParameterRejectionReason.__init__(self, pod, ixval) |
| 90 | + |
| 91 | + @property |
| 92 | + def typ(self) -> "CTyp": |
| 93 | + return self.cdictionary.get_typ(self.args[0]) |
| 94 | + |
| 95 | + def __str__(self) -> str: |
| 96 | + return "Const qualifier: " + str(self.typ) |
| 97 | + |
| 98 | + |
| 99 | +@podregistry.register_tag("o", OutputParameterRejectionReason) |
| 100 | +class OutputParameterRejectionReasonOtherReason(OutputParameterRejectionReason): |
| 101 | + |
| 102 | + def __init__( |
| 103 | + self, pod: "CFunPODictionary", ixval: IndexedTableValue |
| 104 | + ) -> None: |
| 105 | + OutputParameterRejectionReason.__init__(self, pod, ixval) |
| 106 | + |
| 107 | + @property |
| 108 | + def reason(self) -> str: |
| 109 | + return self.cdictionary.get_string(self.args[0]) |
| 110 | + |
| 111 | + def __str__(self) -> str: |
| 112 | + return "Other: " + str(self.reason) |
| 113 | + |
| 114 | + |
| 115 | +@podregistry.register_tag("p", OutputParameterRejectionReason) |
| 116 | +class OutputParameterRejectionReasonPointerPointer(OutputParameterRejectionReason): |
| 117 | + |
| 118 | + def __init__( |
| 119 | + self, pod: "CFunPODictionary", ixval: IndexedTableValue |
| 120 | + ) -> None: |
| 121 | + OutputParameterRejectionReason.__init__(self, pod, ixval) |
| 122 | + |
| 123 | + @property |
| 124 | + def typ(self) -> "CTyp": |
| 125 | + return self.cdictionary.get_typ(self.args[0]) |
| 126 | + |
| 127 | + def __str__(self) -> str: |
| 128 | + return "Pointer to pointer: " + str(self.typ) |
| 129 | + |
| 130 | + |
| 131 | +@podregistry.register_tag("r", OutputParameterRejectionReason) |
| 132 | +class OutputParameterRejectionReasonParameterRead(OutputParameterRejectionReason): |
| 133 | + |
| 134 | + def __init__( |
| 135 | + self, pod: "CFunPODictionary", ixval: IndexedTableValue |
| 136 | + ) -> None: |
| 137 | + OutputParameterRejectionReason.__init__(self, pod, ixval) |
| 138 | + |
| 139 | + @property |
| 140 | + def linenumber(self) -> int: |
| 141 | + return self.args[0] |
| 142 | + |
| 143 | + def __str__(self) -> str: |
| 144 | + return "Parameter is read at line " + str(self.linenumber) |
| 145 | + |
| 146 | + |
| 147 | +@podregistry.register_tag("s", OutputParameterRejectionReason) |
| 148 | +class OutputParameterRejectionReasonSystemStruct(OutputParameterRejectionReason): |
| 149 | + |
| 150 | + def __init__( |
| 151 | + self, pod: "CFunPODictionary", ixval: IndexedTableValue |
| 152 | + ) -> None: |
| 153 | + OutputParameterRejectionReason.__init__(self, pod, ixval) |
| 154 | + |
| 155 | + @property |
| 156 | + def compinfo(self) -> "CCompInfo": |
| 157 | + return self.cdecls.get_compinfo(self.args[0]) |
| 158 | + |
| 159 | + def __str__(self) -> str: |
| 160 | + return "Target type is a system struct: " + str(self.compinfo) |
| 161 | + |
| 162 | + |
| 163 | +@podregistry.register_tag("v", OutputParameterRejectionReason) |
| 164 | +class OutputParameterRejectionReasonVoidPointer(OutputParameterRejectionReason): |
| 165 | + |
| 166 | + def __init__( |
| 167 | + self, pod: "CFunPODictionary", ixval: IndexedTableValue |
| 168 | + ) -> None: |
| 169 | + OutputParameterRejectionReason.__init__(self, pod, ixval) |
| 170 | + |
| 171 | + def __str__(self) -> str: |
| 172 | + return "Void pointer" |
0 commit comments