Skip to content
Snippets Groups Projects
Unverified Commit 973c9427 authored by Jeremy Rifkin's avatar Jeremy Rifkin Committed by GitHub
Browse files

Ts-ify objdumpers (#4385)

* Ts conversion for objdumpers

* Updated copyright years
parent 527729f8
No related branches found
No related tags found
No related merge requests found
......@@ -70,7 +70,7 @@ rules:
no-useless-call: error
no-useless-computed-key: error
no-useless-concat: error
no-useless-constructor: error
'@typescript-eslint/no-useless-constructor': error
no-useless-escape: error
no-useless-rename: error
no-useless-return: error
......
// 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
......
// 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');
}
}
// 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';
}
}
......@@ -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';
}
}
// 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';
}
}
// 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';
}
}
// 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
......
// 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';
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment