From 072a63c846f6cd90cdac99df4a151e24382dc779 Mon Sep 17 00:00:00 2001 From: Partouf Date: Fri, 16 Mar 2018 17:26:30 +0100 Subject: [PATCH] refactor and extra regex --- lib/demangler.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/demangler.js b/lib/demangler.js index b5ceb6968..e58f0c2ae 100644 --- a/lib/demangler.js +++ b/lib/demangler.js @@ -45,6 +45,17 @@ class Demangler { this.labelDef = /^([.a-z_$][a-z0-9$_@.]*):/i; this.jumpDef = /j.+\s+([.a-z_$][a-z0-9$_@.]*)/i; this.callDef = /call[q]?\s+([.a-z_$][a-z0-9$_@.]*)/i; + + // symbols in a mov or lea command starting with an underscore + this.movUnderscoreDef = /mov.*\s(_[a-z0-9$_@.]*)/i; + this.leaUnderscoreDef = /lea.*\s(_[a-z0-9$_@.]*)/i + } + + AddMatchToOtherSymbols(matches) { + if (matches) { + const midx = matches.length - 1; + this.othersymbols.Add(matches[midx], matches[midx]); + } } CollectLabels() { @@ -57,17 +68,10 @@ class Demangler { this.symbolstore.Add(matches[midx], matches[midx]); } - matches = line.match(this.jumpDef); - if (matches) { - const midx = matches.length - 1; - this.othersymbols.Add(matches[midx], matches[midx]); - } - - matches = line.match(this.callDef); - if (matches) { - const midx = matches.length - 1; - this.othersymbols.Add(matches[midx], matches[midx]); - } + this.AddMatchToOtherSymbols(line.match(this.jumpDef)); + this.AddMatchToOtherSymbols(line.match(this.callDef)); + this.AddMatchToOtherSymbols(line.match(this.movUnderscoreDef)); + this.AddMatchToOtherSymbols(line.match(this.leaUnderscoreDef)); } this.othersymbols.Exclude(this.symbolstore);