Skip to content

Commit 63ac468

Browse files
committed
TypedDataSegment: clean up type of fixed suffix
1 parent 3da628b commit 63ac468

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

oi/FuncGen.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,23 +278,38 @@ void FuncGen::DefineTopLevelGetSizeRefTyped(std::string& testCode,
278278
pointers.initialize();
279279
pointers.add((uintptr_t)&t);
280280
auto data = reinterpret_cast<uintptr_t*>(dataBase);
281+
282+
// TODO: Replace these with types::st::Uint64 once the VarInt decoding
283+
// logic is moved out of OIDebugger and into new TreeBuilder.
281284
data[0] = oidMagicId;
282285
data[1] = cookieValue;
283286
data[2] = 0;
287+
284288
size_t dataSegOffset = 3 * sizeof(uintptr_t);
285289
JLOG("%1% @");
286290
JLOGPTR(&t);
287-
using DataBufferType = OIInternal::TypeHandler<DataBuffer::DataSegment, OIInternal::__ROOT_TYPE__>::type;
288-
DataBufferType db = DataBuffer::DataSegment(dataSegOffset);
289-
types::st::Unit<DataBuffer::DataSegment> out = OIInternal::getSizeType<DataBuffer::DataSegment>(t, db);
290-
types::st::Unit<DataBuffer::DataSegment> final = out.template cast<types::st::Pair<
291+
292+
using ContentType = OIInternal::TypeHandler<DataBuffer::DataSegment, OIInternal::__ROOT_TYPE__>::type;
293+
using SuffixType = types::st::Pair<
291294
DataBuffer::DataSegment,
292295
types::st::VarInt<DataBuffer::DataSegment>,
293296
types::st::VarInt<DataBuffer::DataSegment>
294-
>>()
297+
>;
298+
using DataBufferType = types::st::Pair<
299+
DataBuffer::DataSegment,
300+
ContentType,
301+
SuffixType
302+
>;
303+
304+
DataBufferType db = DataBuffer::DataSegment(dataSegOffset);
305+
SuffixType suffix = db.delegate([&t](auto ret) {
306+
return OIInternal::getSizeType<DataBuffer::DataSegment>(t, ret);
307+
});
308+
types::st::Unit<DataBuffer::DataSegment> end = suffix
295309
.write(123456789)
296310
.write(123456789);
297-
dataSegOffset = final.offset();
311+
312+
dataSegOffset = end.offset();
298313
data[2] = dataSegOffset;
299314
dataBase += dataSegOffset;
300315
}

0 commit comments

Comments
 (0)