diff options
author | Jeremy Rifkin <51220084+jeremy-rifkin@users.noreply.github.com> | 2022-12-03 11:41:43 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-03 11:41:43 -0500 |
commit | 973c9427f0ab24e695c2501b7834d64b36ca03ed (patch) | |
tree | c3dafc0686e12b8d1243f22300f1914b50fd15ef /lib/objdumper | |
parent | 527729f8975dfe4c440a1036d43519f9a5ae8f5a (diff) | |
download | compiler-explorer-973c9427f0ab24e695c2501b7834d64b36ca03ed.tar.gz compiler-explorer-973c9427f0ab24e695c2501b7834d64b36ca03ed.zip |
Ts-ify objdumpers (#4385)gh-5258
* Ts conversion for objdumpers
* Updated copyright years
Diffstat (limited to 'lib/objdumper')
-rw-r--r-- | lib/objdumper/_all.ts (renamed from lib/objdumper/_all.js) | 2 | ||||
-rw-r--r-- | lib/objdumper/base.ts (renamed from lib/objdumper/base.js) | 17 | ||||
-rw-r--r-- | lib/objdumper/binutils.ts (renamed from lib/objdumper/binutils.js) | 13 | ||||
-rw-r--r-- | lib/objdumper/da65.ts (renamed from lib/objdumper/da65.js) | 15 | ||||
-rw-r--r-- | lib/objdumper/default.ts (renamed from lib/objdumper/default.js) | 4 | ||||
-rw-r--r-- | lib/objdumper/elftoolchain.ts (renamed from lib/objdumper/elftoolchain.js) | 13 | ||||
-rw-r--r-- | lib/objdumper/index.ts (renamed from lib/objdumper/index.js) | 2 | ||||
-rw-r--r-- | lib/objdumper/llvm.ts (renamed from lib/objdumper/llvm.js) | 13 |
8 files changed, 35 insertions, 44 deletions
diff --git a/lib/objdumper/_all.js b/lib/objdumper/_all.ts index e8e0d6207..17784a71f 100644 --- a/lib/objdumper/_all.js +++ b/lib/objdumper/_all.ts @@ -1,4 +1,4 @@ -// Copyright (c) 2021, Compiler Explorer Authors +// Copyright (c) 2022, Compiler Explorer Authors // All rights reserved. // // Redistribution and use in source and binary forms, with or without diff --git a/lib/objdumper/base.js b/lib/objdumper/base.ts index 77cc7ee86..6d4559679 100644 --- a/lib/objdumper/base.js +++ b/lib/objdumper/base.ts @@ -1,4 +1,4 @@ -// Copyright (c) 2021, Compiler Explorer Authors +// Copyright (c) 2022, Compiler Explorer Authors // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -22,13 +22,10 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -export class BaseObjdumper { - constructor() { - this.intelAsmOptions = null; - this.widthOptions = null; - } +export abstract class BaseObjdumper { + constructor(protected readonly intelAsmOptions: string[], protected readonly widthOptions: string[]) {} - getDefaultArgs(outputFilename, demangle, intelAsm) { + getDefaultArgs(outputFilename: string, demangle?: boolean, intelAsm?: boolean) { const args = ['-d', outputFilename, '-l', ...this.widthOptions]; if (demangle) args.push('-C'); @@ -36,4 +33,10 @@ export class BaseObjdumper { return args; } + + // There's no way in TS to do an abstract static members and interfaces don't allow "static" at all. + // There's apparently a hack with InstanceType but I couldn't get it working. I think this is the best solution. + static get key(): string { + throw new Error('Objdumper must provide a `static get key()` implementation'); + } } diff --git a/lib/objdumper/binutils.js b/lib/objdumper/binutils.ts index da85d9797..99f33ae96 100644 --- a/lib/objdumper/binutils.js +++ b/lib/objdumper/binutils.ts @@ -1,4 +1,4 @@ -// Copyright (c) 2021, Compiler Explorer Authors +// Copyright (c) 2022, Compiler Explorer Authors // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -25,14 +25,11 @@ import {BaseObjdumper} from './base'; export class BinutilsObjdumper extends BaseObjdumper { - static get key() { - return 'binutils'; - } - constructor() { - super(); + super(['-M', 'intel'], ['--insn-width=16']); + } - this.intelAsmOptions = ['-M', 'intel']; - this.widthOptions = ['--insn-width=16']; + static override get key() { + return 'binutils'; } } diff --git a/lib/objdumper/da65.js b/lib/objdumper/da65.ts index 5cf7a7acf..b48bfc631 100644 --- a/lib/objdumper/da65.js +++ b/lib/objdumper/da65.ts @@ -25,18 +25,15 @@ import {BaseObjdumper} from './base'; export class Da65Objdumper extends BaseObjdumper { - static get key() { - return 'da65'; - } - constructor() { - super(); - - this.intelAsmOptions = []; - this.widthOptions = []; + super([], []); } - getDefaultArgs(outputFilename) { + override getDefaultArgs(outputFilename: string) { return [outputFilename]; } + + static override get key() { + return 'da65'; + } } diff --git a/lib/objdumper/default.js b/lib/objdumper/default.ts index c89ca48d8..886d2d429 100644 --- a/lib/objdumper/default.js +++ b/lib/objdumper/default.ts @@ -1,4 +1,4 @@ -// Copyright (c) 2021, Compiler Explorer Authors +// Copyright (c) 2022, Compiler Explorer Authors // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -25,7 +25,7 @@ import {BinutilsObjdumper} from './binutils'; export class DefaultObjdumper extends BinutilsObjdumper { - static get key() { + static override get key() { return 'default'; } } diff --git a/lib/objdumper/elftoolchain.js b/lib/objdumper/elftoolchain.ts index d6d5221b6..408aa2b3a 100644 --- a/lib/objdumper/elftoolchain.js +++ b/lib/objdumper/elftoolchain.ts @@ -1,4 +1,4 @@ -// Copyright (c) 2021, Compiler Explorer Authors +// Copyright (c) 2022, Compiler Explorer Authors // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -25,14 +25,11 @@ import {BaseObjdumper} from './base'; export class ElfToolChainObjdumper extends BaseObjdumper { - static get key() { - return 'elftoolchain'; - } - constructor() { - super(); + super(['-M', 'intel'], []); + } - this.intelAsmOptions = ['-M', 'intel']; - this.widthOptions = []; + static override get key() { + return 'elftoolchain'; } } diff --git a/lib/objdumper/index.js b/lib/objdumper/index.ts index 791d8a500..716db51c1 100644 --- a/lib/objdumper/index.js +++ b/lib/objdumper/index.ts @@ -1,4 +1,4 @@ -// Copyright (c) 2021, Compiler Explorer Authors +// Copyright (c) 2022, Compiler Explorer Authors // All rights reserved. // // Redistribution and use in source and binary forms, with or without diff --git a/lib/objdumper/llvm.js b/lib/objdumper/llvm.ts index 93e73bc4a..217ba1073 100644 --- a/lib/objdumper/llvm.js +++ b/lib/objdumper/llvm.ts @@ -1,4 +1,4 @@ -// Copyright (c) 2021, Compiler Explorer Authors +// Copyright (c) 2022, Compiler Explorer Authors // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -25,14 +25,11 @@ import {BaseObjdumper} from './base'; export class LlvmObjdumper extends BaseObjdumper { - static get key() { - return 'llvm'; - } - constructor() { - super(); + super(['--x86-asm-syntax=intel'], []); + } - this.intelAsmOptions = ['--x86-asm-syntax=intel']; - this.widthOptions = []; + static override get key() { + return 'llvm'; } } |