can't... stop... adding... types

This commit is contained in:
Ofek Shilon
2024-10-22 21:02:25 +03:00
parent 897e89421d
commit 9a6c961345
13 changed files with 34 additions and 25 deletions
+1 -1
View File
@@ -2997,7 +2997,7 @@ export class BaseCompiler implements ICompiler {
return result;
}
async processAsm(result, filters, options) {
async processAsm(result, filters: ParseFiltersAndOutputOptions, options: string[]) {
if ((options && options.includes('-emit-llvm')) || this.llvmIr.isLlvmIr(result.asm)) {
return await this.llvmIr.processFromFilters(result.asm, filters);
}
+5 -1
View File
@@ -47,7 +47,11 @@ export class CarbonCompiler extends BaseCompiler {
return ['--color', `--trace_file=${outputFilename}`];
}
override async processAsm(result, filters, options): Promise<ParsedAsmResult> {
override async processAsm(
result,
filters: ParseFiltersAndOutputOptions,
options: string[],
): Promise<ParsedAsmResult> {
// Really should write a custom parser, but for now just don't filter anything.
return await super.processAsm(
result,
+1 -1
View File
@@ -95,7 +95,7 @@ export class HLSLCompiler extends BaseCompiler {
return options;
}
override async processAsm(result, filters, options) {
override async processAsm(result, filters: ParseFiltersAndOutputOptions, options: string[]) {
if (this.isSpirv(result.asm)) {
return this.spirvAsm.processAsm(result.asm, filters);
}
+1 -1
View File
@@ -79,7 +79,7 @@ export class HookCompiler extends BaseCompiler {
return super.runCompiler(compiler, options, inputFilename, execOptions);
}
override async processAsm(result, filters, options) {
override async processAsm(result, filters: ParseFiltersAndOutputOptions, options: string[]) {
// Ignoring `trim` filter because it is not supported by Hook.
filters.trim = false;
const _result = await super.processAsm(result, filters, options);
+1 -1
View File
@@ -81,7 +81,7 @@ export class MLIRCompiler extends BaseCompiler {
return [];
}
override async processAsm(result, filters, options) {
override async processAsm(result, filters: ParseFiltersAndOutputOptions, options: string[]) {
// at some point maybe a custom parser can be written, for now just don't filter anything
return super.processAsm(
result,
+1 -1
View File
@@ -193,7 +193,7 @@ export class PascalWinCompiler extends BaseCompiler {
override optionsForFilter(filters: ParseFiltersAndOutputOptions) {
filters.binary = true;
filters.dontMaskFilenames = true;
(filters as any).preProcessBinaryAsmLines = (asmLines: string[]) => {
filters.preProcessBinaryAsmLines = (asmLines: string[]) => {
const mapFileReader = new MapFileReaderDelphi(unwrap(this.mapFilename));
const reconstructor = new PELabelReconstructor(asmLines, false, mapFileReader, false);
reconstructor.run('output');
+1 -1
View File
@@ -63,7 +63,7 @@ export class FPCCompiler extends BaseCompiler {
return [];
}
override async processAsm(result, filters) {
override async processAsm(result, filters: ParseFiltersAndOutputOptions) {
// TODO: Pascal doesn't have a demangler exe, it's the only compiler that's weird like this
this.demangler = new (unwrap(this.demanglerClass))(null as any, this);
return this.asm.process(result.asm, filters);
+1 -1
View File
@@ -175,7 +175,7 @@ export class RacketCompiler extends BaseCompiler {
return result;
}
override async processAsm(result: any, filters: any, options: any) {
override async processAsm(result: any, filters: ParseFiltersAndOutputOptions, options: string[]) {
// TODO: Process and highlight decompiled output
return {
asm: [{text: result.asm}],
+1 -1
View File
@@ -68,7 +68,7 @@ export class VCompiler extends BaseCompiler {
return compilerOptions;
}
override async processAsm(result: any, filters, options: string[]): Promise<any> {
override async processAsm(result: any, filters: ParseFiltersAndOutputOptions, options: string[]): Promise<any> {
const backend = this.getBackendFromOptions(options);
switch (backend) {
case 'c':
+9 -5
View File
@@ -26,7 +26,11 @@ import path from 'path';
import _ from 'underscore';
import type {CompileChildLibraries, ExecutionOptions} from '../../types/compilation/compilation.interfaces.js';
import type {
CacheKey,
CompileChildLibraries,
ExecutionOptions,
} from '../../types/compilation/compilation.interfaces.js';
import type {ConfiguredOverrides} from '../../types/compilation/compiler-overrides.interfaces.js';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
@@ -55,7 +59,7 @@ export class Win32Compiler extends BaseCompiler {
return ['/std:<value>'];
}
override getExecutableFilename(dirPath: string, outputFilebase: string, key?) {
override getExecutableFilename(dirPath: string, outputFilebase: string, key?: CacheKey) {
return this.getOutputFilename(dirPath, outputFilebase, key) + '.exe';
}
@@ -81,7 +85,7 @@ export class Win32Compiler extends BaseCompiler {
);
}
override getStaticLibraryLinks(libraries) {
override getStaticLibraryLinks(libraries: CompileChildLibraries[]) {
return super.getSortedStaticLibraries(libraries).map(lib => {
return '"' + lib + '.lib"';
});
@@ -142,7 +146,7 @@ export class Win32Compiler extends BaseCompiler {
const mapFilename = outputFilename + '.map';
const mapFileReader = new MapFileReaderVS(mapFilename);
(filters as any).preProcessBinaryAsmLines = asmLines => {
filters.preProcessBinaryAsmLines = asmLines => {
const reconstructor = new PELabelReconstructor(asmLines, false, mapFileReader);
reconstructor.run('output.s.obj');
@@ -168,7 +172,7 @@ export class Win32Compiler extends BaseCompiler {
}
}
override async processAsm(result, filters /*, options*/) {
override async processAsm(result, filters: ParseFiltersAndOutputOptions) {
if (filters.binary) {
filters.dontMaskFilenames = true;
return this.binaryAsmParser.process(result.asm, filters);
+3 -2
View File
@@ -22,6 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
import * as utils from '../utils.js';
import {IAsmParser} from './asm-parser.interfaces.js';
@@ -132,7 +133,7 @@ export class DotNetAsmParser implements IAsmParser {
return cleanedAsm;
}
process(asmResult: string, filters) {
process(asmResult: string, filters: ParseFiltersAndOutputOptions) {
const startTime = process.hrtime.bigint();
const asm: {
@@ -150,7 +151,7 @@ export class DotNetAsmParser implements IAsmParser {
asmLines = asmLines.flatMap(l => (commentRe.test(l) ? [] : [l]));
}
const result = this.scanLabelsAndMethods(asmLines, filters.labels);
const result = this.scanLabelsAndMethods(asmLines, filters.labels!);
for (const i in result.labelDef) {
const label = result.labelDef[i];
+8 -8
View File
@@ -78,17 +78,17 @@ export class MadsAsmParser extends AsmParser {
line: string,
source: AsmResultSource | undefined | null,
filters: ParseFiltersAndOutputOptions,
match,
matchGroups: {[key: string]: string},
): ParsedAsmResultLine {
const labelsInLine: AsmResultLabel[] = [];
const address = parseInt(match.groups.address, 16);
const opcodes = (match.groups.opcodes || '').split(' ').filter(x => !!x);
const address = parseInt(matchGroups.address, 16);
const opcodes = (matchGroups.opcodes || '').split(' ').filter(x => !!x);
let text = '';
if (match.groups.label) {
text = match.groups.label.trim() + ': ';
if (matchGroups.label) {
text = matchGroups.label.trim() + ': ';
}
const disassembly = ' ' + AsmRegex.filterAsmLine(match.groups.disasm, filters);
const disassembly = ' ' + AsmRegex.filterAsmLine(matchGroups.disasm, filters);
const destMatch = line.match(this.destRe);
if (destMatch) {
const labelName = destMatch[2];
@@ -152,7 +152,7 @@ export class MadsAsmParser extends AsmParser {
assert(match.groups);
labelDefinitions[match.groups.label] = asm.length;
asm.push(this.getAsmLineWithOpcodeReMatch(line, source, filters, match));
asm.push(this.getAsmLineWithOpcodeReMatch(line, source, filters, match.groups));
continue;
}
@@ -161,7 +161,7 @@ export class MadsAsmParser extends AsmParser {
if (match) {
assert(match.groups);
const parsedLine = this.getAsmLineWithOpcodeReMatch(line, source, filters, match);
const parsedLine = this.getAsmLineWithOpcodeReMatch(line, source, filters, match.groups);
parsedLine.text = linePrefix + parsedLine.text;
asm.push(parsedLine);
+1 -1
View File
@@ -156,7 +156,7 @@ describe('Hook compiler', () => {
labelDefinitions: {},
};
const filters = {trim: false};
const result = await hook.processAsm({asm: asm}, filters, null);
const result = await hook.processAsm({asm: asm}, filters, []);
delete result.parsingTime;
expect(result).toEqual(expected);
});