@ -81,12 +81,15 @@ export class Compiler {
* @param missingInputs missing import file path list
* @param missingInputs missing import file path list
* /
* /
internalCompile ( files : Source , missingInputs? : string [ ] ) : void {
internalCompile ( files : Source , missingInputs? : string [ ] , timeStamp? : number ) : void {
if ( timeStamp != this . state . compilationStartTime && this . state . compilerRetriggerMode == CompilerRetriggerMode . retrigger ) {
return
}
this . gatherImports ( files , missingInputs , ( error , input ) = > {
this . gatherImports ( files , missingInputs , ( error , input ) = > {
if ( error ) {
if ( error ) {
this . state . lastCompilationResult = null
this . state . lastCompilationResult = null
this . event . trigger ( 'compilationFinished' , [ false , { error : { formattedMessage : error , severity : 'error' } } , files , input , this . state . currentVersion ] )
this . event . trigger ( 'compilationFinished' , [ false , { error : { formattedMessage : error , severity : 'error' } } , files , input , this . state . currentVersion ] )
} else if ( this . state . compileJSON && input ) { this . state . compileJSON ( input ) }
} else if ( this . state . compileJSON && input ) { this . state . compileJSON ( input , timeStamp ) }
} )
} )
}
}
@ -100,7 +103,7 @@ export class Compiler {
this . state . target = target
this . state . target = target
this . state . compilationStartTime = new Date ( ) . getTime ( )
this . state . compilationStartTime = new Date ( ) . getTime ( )
this . event . trigger ( 'compilationStarted' , [ ] )
this . event . trigger ( 'compilationStarted' , [ ] )
this . internalCompile ( files )
this . internalCompile ( files , null , this . state . compilationStartTime )
}
}
/ * *
/ * *
@ -157,7 +160,7 @@ export class Compiler {
* @param source Source
* @param source Source
* /
* /
onCompilationFinished ( data : CompilationResult , missingInputs? : string [ ] , source? : SourceWithTarget , input? : string , version? : string ) : void {
onCompilationFinished ( data : CompilationResult , missingInputs? : string [ ] , source? : SourceWithTarget , input? : string , version? : string , timeStamp? : number ) : void {
let noFatalErrors = true // ie warnings are ok
let noFatalErrors = true // ie warnings are ok
const checkIfFatalError = ( error : CompilationError ) = > {
const checkIfFatalError = ( error : CompilationError ) = > {
@ -173,7 +176,7 @@ export class Compiler {
this . event . trigger ( 'compilationFinished' , [ false , data , source , input , version ] )
this . event . trigger ( 'compilationFinished' , [ false , data , source , input , version ] )
} else if ( missingInputs !== undefined && missingInputs . length > 0 && source && source . sources ) {
} else if ( missingInputs !== undefined && missingInputs . length > 0 && source && source . sources ) {
// try compiling again with the new set of inputs
// try compiling again with the new set of inputs
this . internalCompile ( source . sources , missingInputs )
this . internalCompile ( source . sources , missingInputs , timeStamp )
} else {
} else {
data = this . updateInterface ( data )
data = this . updateInterface ( data )
if ( source ) {
if ( source ) {
@ -292,6 +295,7 @@ export class Compiler {
this . state . worker . addEventListener ( 'message' , ( msg : Record < 'data' , MessageFromWorker > ) = > {
this . state . worker . addEventListener ( 'message' , ( msg : Record < 'data' , MessageFromWorker > ) = > {
const data : MessageFromWorker = msg . data
const data : MessageFromWorker = msg . data
if ( this . state . compilerRetriggerMode == CompilerRetriggerMode . retrigger && data . timestamp !== this . state . compilationStartTime ) {
if ( this . state . compilerRetriggerMode == CompilerRetriggerMode . retrigger && data . timestamp !== this . state . compilationStartTime ) {
// drop message from previous compilation
return
return
}
}
switch ( data . cmd ) {
switch ( data . cmd ) {
@ -312,7 +316,7 @@ export class Compiler {
sources = jobs [ data . job ] . sources
sources = jobs [ data . job ] . sources
delete jobs [ data . job ]
delete jobs [ data . job ]
}
}
this . onCompilationFinished ( result , data . missingInputs , sources , data . input , this . state . currentVersion )
this . onCompilationFinished ( result , data . missingInputs , sources , data . input , this . state . currentVersion , data . timestamp )
}
}
break
break
}
}
@ -325,7 +329,7 @@ export class Compiler {
this . onCompilationFinished ( { error : { formattedMessage } } )
this . onCompilationFinished ( { error : { formattedMessage } } )
} )
} )
this . state . compileJSON = ( source : SourceWithTarget ) = > {
this . state . compileJSON = ( source : SourceWithTarget , timeStamp : number ) = > {
if ( source && source . sources ) {
if ( source && source . sources ) {
const { optimize , runs , evmVersion , language , useFileConfiguration , configFileContent } = this . state
const { optimize , runs , evmVersion , language , useFileConfiguration , configFileContent } = this . state
jobs . push ( { sources : source } )
jobs . push ( { sources : source } )
@ -342,12 +346,11 @@ export class Compiler {
return
return
}
}
this . state . worker . postMessage ( {
this . state . worker . postMessage ( {
cmd : 'compile' ,
cmd : 'compile' ,
job : jobs.length - 1 ,
job : jobs.length - 1 ,
input : input ,
input : input ,
timestamp : this.state.compilationStartTime
timestamp : timeStamp
} )
} )
}
}
}
}