From 80036b664e9c7537356a26d01f26e5d52a8a7be5 Mon Sep 17 00:00:00 2001 From: Leonardo Date: Tue, 26 Nov 2024 17:05:59 +0100 Subject: [PATCH] hlmem: Add type id to print and allow doing locate on type ids (#727) --- other/haxelib/hlmem/Memory.hx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/other/haxelib/hlmem/Memory.hx b/other/haxelib/hlmem/Memory.hx index e70d33bad..f555677ac 100644 --- a/other/haxelib/hlmem/Memory.hx +++ b/other/haxelib/hlmem/Memory.hx @@ -53,8 +53,10 @@ class Stats { } public static function getTypeString(mem : Memory, id : Int){ - var t = mem.types[id & 0xFFFFFF]; + var tid = id & 0xFFFFFF; + var t = mem.types[tid]; var tstr = t.toString(); + tstr += Memory.withColor("#" + tid, 35); var fid = id >>> 24; if( fid > 0 ) { var f = t.memFieldsNames[fid-1]; @@ -767,7 +769,16 @@ class Memory { function locate( tstr : String, up = 0 ) { var ctx = new Stats(this); - var lt = resolveType(tstr); + var lt = null; + if (StringTools.startsWith(tstr, "#")) { + var id = Std.parseInt(tstr.substr(1, tstr.length)); + if (id != null && id >= 0) { + lt = types[id]; + } + } else { + lt = resolveType(tstr); + } + if( lt == null ) return ctx; inline function isVirtualField(t) { t >>>= 24; return t == 1 || t == 2; }