aboutsummaryrefslogtreecommitdiff
path: root/lib/compilers/golang.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compilers/golang.js')
-rw-r--r--lib/compilers/golang.js23
1 files changed, 8 insertions, 15 deletions
diff --git a/lib/compilers/golang.js b/lib/compilers/golang.js
index 73a64aac7..bbcba3195 100644
--- a/lib/compilers/golang.js
+++ b/lib/compilers/golang.js
@@ -31,21 +31,15 @@ import { ClangParser } from './argument-parsers';
// Each arch has a list of jump instructions in
// Go source src/cmd/asm/internal/arch.
-const jumpPrefixes = [
- 'j',
- 'b',
-
- // arm
- 'cb',
- 'tb',
-
- // s390x
- 'cmpb',
- 'cmpub',
-];
+// x86 -> j, b
+// arm -> cb, tb
+// s390x -> cmpb, cmpub
+const jumpRe = /^(j|b|cb|tb|cmpb|cmpub).*/i;
export class GolangCompiler extends BaseCompiler {
- static get key() { return 'golang'; }
+ static get key() {
+ return 'golang';
+ }
convertNewGoL(code) {
const re = /^\s+(0[Xx]?[\dA-Za-z]+)?\s?(\d+)\s*\(([^:]+):(\d+)\)\s*([A-Z]+)(.*)/;
@@ -129,7 +123,6 @@ export class GolangCompiler extends BaseCompiler {
prevLine = lineMatch;
}
- ins = ins.toLowerCase();
args = this.replaceJump(func, funcCollisions[func], ins, args, usedLabels);
res.push(`\t${ins}${args}`);
return res;
@@ -155,7 +148,7 @@ export class GolangCompiler extends BaseCompiler {
}
// Check instruction has a jump prefix
- if (_.any(jumpPrefixes, prefix => ins.startsWith(prefix))) {
+ if (ins.match(jumpRe)) {
let label = `${func}_pc${match[2]}`;
if (collisions > 0) {
label += `_${collisions}`;