MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / proftext

Function proftext

tests/coverage_live_v2_support.py:170–200  ·  view source on GitHub ↗

Read the pinned LLVM frontend text grammar independently of project imports.

(data)

Source from the content-addressed store, hash-verified

168
169
170def proftext(data):
171 """Read the pinned LLVM frontend text grammar independently of project imports."""
172 require(data and b"\r" not in data and b"\x00" not in data, "invalid proftext bytes")
173 lines = data.split(b"\n")
174 require(lines[-1] == b"", "proftext lacks final LF")
175 records, position = {}, 0
176 while position < len(lines) - 1:
177 require(position + 6 < len(lines), "truncated proftext header")
178 name, hash_label, hash_text, size_label, size_text, values_label = lines[position:position + 6]
179 require(bool(name) and hash_label == b"# Func Hash:" and size_label == b"# Num Counters:"
180 and values_label == b"# Counter Values:", "unsupported proftext record")
181 require(re.fullmatch(rb"0|[1-9][0-9]*", hash_text) is not None,
182 "noncanonical native function hash")
183 require(re.fullmatch(rb"[1-9][0-9]*", size_text) is not None,
184 "noncanonical native counter count")
185 hash_value, count = int(hash_text), int(size_text)
186 require(hash_value < 2**64 and count <= 1000000, "proftext numeric bound")
187 begin, end = position + 6, position + 6 + count
188 require(end < len(lines) - 1 and lines[end] == b"", "proftext record terminator")
189 values = []
190 for value in lines[begin:end]:
191 require(re.fullmatch(rb"0|[1-9][0-9]*", value) is not None,
192 "noncanonical native counter")
193 values.append(int(value))
194 require(values[-1] < 2**64, "native counter overflow")
195 key = (name, hash_value)
196 require(key not in records, "duplicate native identity")
197 records[key] = tuple(values)
198 position = end + 1
199 require(bool(records), "empty native universe")
200 return records
201
202
203def profile_wire(data, image, universe):

Callers 1

convertFunction · 0.90

Calls 1

requireFunction · 0.70

Tested by

no test coverage detected