From 40a016c84eff6beabb76c437f9dfe71a8329d938 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Mon, 28 Sep 2020 09:48:17 +0530 Subject: [PATCH] added runs for compiler --- libs/remix-solidity/src/compiler/compiler-input.ts | 2 +- libs/remix-solidity/src/compiler/compiler.ts | 11 +++++------ libs/remix-solidity/src/compiler/types.ts | 2 ++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libs/remix-solidity/src/compiler/compiler-input.ts b/libs/remix-solidity/src/compiler/compiler-input.ts index 106b724734..e65ae5fb82 100644 --- a/libs/remix-solidity/src/compiler/compiler-input.ts +++ b/libs/remix-solidity/src/compiler/compiler-input.ts @@ -9,7 +9,7 @@ export default (sources: Source, opts: CompilerInputOptions): string => { settings: { optimizer: { enabled: opts.optimize === true || opts.optimize === 1, - runs: 200 + runs: opts.runs }, libraries: opts.libraries, outputSelection: { diff --git a/libs/remix-solidity/src/compiler/compiler.ts b/libs/remix-solidity/src/compiler/compiler.ts index 5a7168db8e..c4a9afbf57 100644 --- a/libs/remix-solidity/src/compiler/compiler.ts +++ b/libs/remix-solidity/src/compiler/compiler.ts @@ -23,6 +23,7 @@ export class Compiler { worker: null, currentVersion: null, optimize: false, + runs: 200, evmVersion: null, language: 'Solidity', compilationStartTime: null, @@ -109,7 +110,8 @@ export class Compiler { let result: CompilationResult = {} try { if(source && source.sources) { - const input = compilerInput(source.sources, {optimize: this.state.optimize, evmVersion: this.state.evmVersion, language: this.state.language}) + const {optimize, runs, evmVersion, language} = this.state + const input = compilerInput(source.sources, {optimize, runs, evmVersion, language}) result = JSON.parse(compiler.compile(input, { import: missingInputsCallback })) } } catch (exception) { @@ -247,15 +249,12 @@ export class Compiler { this.state.compileJSON = (source: SourceWithTarget) => { if(source && source.sources) { + const {optimize, runs, evmVersion, language} = this.state jobs.push({sources: source}) this.state.worker.postMessage({ cmd: 'compile', job: jobs.length - 1, - input: compilerInput(source.sources, { - optimize: this.state.optimize, - evmVersion: this.state.evmVersion, - language: this.state.language - }) + input: compilerInput(source.sources, {optimize, runs, evmVersion, language}) }) } } diff --git a/libs/remix-solidity/src/compiler/types.ts b/libs/remix-solidity/src/compiler/types.ts index 51509a9245..42691d51c4 100644 --- a/libs/remix-solidity/src/compiler/types.ts +++ b/libs/remix-solidity/src/compiler/types.ts @@ -143,6 +143,7 @@ export interface Source { export interface CompilerInputOptions { optimize: boolean | number, + runs: number, libraries?: { [fileName: string]: Record }, @@ -159,6 +160,7 @@ export interface CompilerState { worker: any, currentVersion: string| null| undefined, optimize: boolean, + runs: number evmVersion: EVMVersion| null, language: Language, compilationStartTime: number| null,