emit version and input too

pull/2112/head
aniket-engg 3 years ago committed by Aniket
parent 93862b55c2
commit 2e4b8520cc
  1. 4
      apps/solidity-compiler/src/app/compiler-api.ts
  2. 1
      libs/remix-solidity/src/compiler/compiler-worker.ts
  3. 16
      libs/remix-solidity/src/compiler/compiler.ts
  4. 1
      libs/remix-solidity/src/compiler/types.ts

@ -261,11 +261,11 @@ export const CompilerApiMixin = (Base) => class extends Base {
this.on('fileManager', 'fileClosed', this.data.eventHandlers.onFileClosed)
this.data.eventHandlers.onCompilationFinished = (success, data, source) => {
this.data.eventHandlers.onCompilationFinished = (success, data, source, input, version) => {
this.compileErrors = data
if (success) {
// forwarding the event to the appManager infra
this.emit('compilationFinished', source.target, source, 'soljson', data)
this.emit('compilationFinished', source.target, source, 'soljson', data, input, version)
if (data.errors && data.errors.length > 0) {
this.statusChanged({
key: data.errors.length,

@ -45,6 +45,7 @@ export default function (self) { // eslint-disable-line @typescript-eslint/expli
cmd: 'compiled',
job: data.job,
data: compileJSON(data.input),
input: data.input,
missingInputs: missingInputs
})
}

@ -111,16 +111,17 @@ export class Compiler {
return { error: 'Deferred import' }
}
let result: CompilationResult = {}
let input
try {
if (source && source.sources) {
const { optimize, runs, evmVersion, language } = this.state
const input = compilerInput(source.sources, { optimize, runs, evmVersion, language })
input = compilerInput(source.sources, { optimize, runs, evmVersion, language })
result = JSON.parse(compiler.compile(input, { import: missingInputsCallback }))
}
} catch (exception) {
result = { error: { formattedMessage: 'Uncaught JavaScript exception:\n' + exception, severity: 'error', mode: 'panic' } }
}
this.onCompilationFinished(result, missingInputs, source)
this.onCompilationFinished(result, missingInputs, source, input, this.state.currentVersion)
}
this.onCompilerLoaded(compiler.version())
}
@ -133,7 +134,7 @@ export class Compiler {
* @param source Source
*/
onCompilationFinished (data: CompilationResult, missingInputs?: string[], source?: SourceWithTarget): void {
onCompilationFinished (data: CompilationResult, missingInputs?: string[], source?: SourceWithTarget, input?, version?): void {
let noFatalErrors = true // ie warnings are ok
const checkIfFatalError = (error: CompilationError) => {
@ -159,7 +160,7 @@ export class Compiler {
source: source
}
}
this.event.trigger('compilationFinished', [true, data, source])
this.event.trigger('compilationFinished', [true, data, source, input, version])
}
}
@ -182,16 +183,17 @@ export class Compiler {
return { error: 'Deferred import' }
}
let result: CompilationResult = {}
let input
try {
if (source && source.sources) {
const { optimize, runs, evmVersion, language } = this.state
const input = compilerInput(source.sources, { optimize, runs, evmVersion, language })
input = compilerInput(source.sources, { optimize, runs, evmVersion, language })
result = JSON.parse(remoteCompiler.compile(input, { import: missingInputsCallback }))
}
} catch (exception) {
result = { error: { formattedMessage: 'Uncaught JavaScript exception:\n' + exception, severity: 'error', mode: 'panic' } }
}
this.onCompilationFinished(result, missingInputs, source)
this.onCompilationFinished(result, missingInputs, source, input, version)
}
this.onCompilerLoaded(version)
}
@ -273,7 +275,7 @@ export class Compiler {
sources = jobs[data.job].sources
delete jobs[data.job]
}
this.onCompilationFinished(result, data.missingInputs, sources)
this.onCompilationFinished(result, data.missingInputs, sources, data.input, this.state.currentVersion)
}
break
}

@ -186,6 +186,7 @@ export interface MessageFromWorker {
cmd: string,
job?: number,
missingInputs?: string[],
input?: any,
data?: string
}

Loading…
Cancel
Save