diff options
author | Jeremy Rifkin <51220084+jeremy-rifkin@users.noreply.github.com> | 2024-01-21 10:29:58 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-21 10:29:58 -0600 |
commit | e5fb8e1afc518a3d21a56a3cabf39d24c7f31f14 (patch) | |
tree | ea59f9d3e4954bcd5022a7f1aad07ba7bebdacd3 /lib/compilers | |
parent | 163605aca0c704fe878138d80cbb9edb73c62f51 (diff) | |
download | compiler-explorer-e5fb8e1afc518a3d21a56a3cabf39d24c7f31f14.tar.gz compiler-explorer-e5fb8e1afc518a3d21a56a3cabf39d24c7f31f14.zip |
Improve typings for the now-global HandlerConfig (#6027)gh-10273
This PR populates types in the HandlerConfig
Diffstat (limited to 'lib/compilers')
-rw-r--r-- | lib/compilers/d8.ts | 15 | ||||
-rw-r--r-- | lib/compilers/dex2oat.ts | 7 | ||||
-rw-r--r-- | lib/compilers/java.ts | 4 | ||||
-rw-r--r-- | lib/compilers/kotlin.ts | 3 |
4 files changed, 20 insertions, 9 deletions
diff --git a/lib/compilers/d8.ts b/lib/compilers/d8.ts index 155f6aa83..6a0437e58 100644 --- a/lib/compilers/d8.ts +++ b/lib/compilers/d8.ts @@ -29,14 +29,17 @@ import _ from 'underscore'; import {logger} from '../logger.js'; -import {BaseCompiler} from '../base-compiler.js'; +import {BaseCompiler, SimpleOutputFilenameCompiler} from '../base-compiler.js'; import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js'; import type {ParsedAsmResult, ParsedAsmResultLine} from '../../types/asmresult/asmresult.interfaces.js'; import {CompilationResult, ExecutionOptions} from '../../types/compilation/compilation.interfaces.js'; import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; +import {unwrap} from '../assert.js'; +import {JavaCompiler} from './java.js'; +import {KotlinCompiler} from './kotlin.js'; -export class D8Compiler extends BaseCompiler { +export class D8Compiler extends BaseCompiler implements SimpleOutputFilenameCompiler { static get key() { return 'android-d8'; } @@ -80,7 +83,9 @@ export class D8Compiler extends BaseCompiler { // Instantiate Java or Kotlin compiler based on the current language. if (this.lang.id === 'android-java') { - const javaCompiler = global.handler_config.compileHandler.findCompiler('java', this.javaId); + const javaCompiler = unwrap( + global.handler_config.compileHandler.findCompiler('java', this.javaId), + ) as JavaCompiler; outputFilename = javaCompiler.getOutputFilename(preliminaryCompilePath); const javaOptions = _.compact( javaCompiler.prepareArguments( @@ -100,7 +105,9 @@ export class D8Compiler extends BaseCompiler { javaCompiler.getDefaultExecOptions(), ); } else if (this.lang.id === 'android-kotlin') { - const kotlinCompiler = global.handler_config.compileHandler.findCompiler('kotlin', this.kotlinId); + const kotlinCompiler = unwrap( + global.handler_config.compileHandler.findCompiler('kotlin', this.kotlinId), + ) as KotlinCompiler; outputFilename = kotlinCompiler.getOutputFilename(preliminaryCompilePath); const kotlinOptions = _.compact( kotlinCompiler.prepareArguments( diff --git a/lib/compilers/dex2oat.ts b/lib/compilers/dex2oat.ts index 9c8000fc1..240964165 100644 --- a/lib/compilers/dex2oat.ts +++ b/lib/compilers/dex2oat.ts @@ -27,7 +27,7 @@ import path from 'path'; import fs from 'fs-extra'; import _ from 'underscore'; -import {BaseCompiler} from '../base-compiler.js'; +import {BaseCompiler, SimpleOutputFilenameCompiler} from '../base-compiler.js'; import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js'; import type {ParsedAsmResult, ParsedAsmResultLine} from '../../types/asmresult/asmresult.interfaces.js'; @@ -40,6 +40,7 @@ import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.in import {Dex2OatPassDumpParser} from '../parsers/dex2oat-pass-dump-parser.js'; import * as utils from '../utils.js'; +import {unwrap} from '../assert.js'; export class Dex2OatCompiler extends BaseCompiler { static get key() { @@ -118,7 +119,9 @@ export class Dex2OatCompiler extends BaseCompiler { // Instantiate D8 compiler, which will in turn instantiate a Java or // Kotlin compiler based on the current language. - const d8Compiler = global.handler_config.compileHandler.findCompiler(this.lang.id, this.d8Id); + const d8Compiler = unwrap( + global.handler_config.compileHandler.findCompiler(this.lang.id, this.d8Id), + ) as BaseCompiler & SimpleOutputFilenameCompiler; if (!d8Compiler) { return { ...this.handleUserError( diff --git a/lib/compilers/java.ts b/lib/compilers/java.ts index a12af2398..a2e027751 100644 --- a/lib/compilers/java.ts +++ b/lib/compilers/java.ts @@ -30,7 +30,7 @@ import type {ParsedAsmResult, ParsedAsmResultLine} from '../../types/asmresult/a import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js'; import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; import {unwrap} from '../assert.js'; -import {BaseCompiler} from '../base-compiler.js'; +import {BaseCompiler, SimpleOutputFilenameCompiler} from '../base-compiler.js'; import {logger} from '../logger.js'; import * as utils from '../utils.js'; @@ -38,7 +38,7 @@ import {JavaParser} from './argument-parsers.js'; import {BypassCache} from '../../types/compilation/compilation.interfaces.js'; import {ExecutableExecutionOptions} from '../../types/execution/execution.interfaces.js'; -export class JavaCompiler extends BaseCompiler { +export class JavaCompiler extends BaseCompiler implements SimpleOutputFilenameCompiler { static get key() { return 'java'; } diff --git a/lib/compilers/kotlin.ts b/lib/compilers/kotlin.ts index 51a8bb509..351552610 100644 --- a/lib/compilers/kotlin.ts +++ b/lib/compilers/kotlin.ts @@ -26,11 +26,12 @@ import {BypassCache} from '../../types/compilation/compilation.interfaces.js'; import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js'; import {ExecutableExecutionOptions} from '../../types/execution/execution.interfaces.js'; import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; +import {SimpleOutputFilenameCompiler} from '../base-compiler.js'; import {KotlinParser} from './argument-parsers.js'; import {JavaCompiler} from './java.js'; -export class KotlinCompiler extends JavaCompiler { +export class KotlinCompiler extends JavaCompiler implements SimpleOutputFilenameCompiler { static override get key() { return 'kotlin'; } |