From 0a5dd05b6f9e39741cacfb76a840e81605896c1e Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 8 Nov 2016 01:18:58 +0000 Subject: [PATCH] Add target contract name to the compiler --- src/app.js | 6 ++++-- src/app/compiler.js | 18 +++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/app.js b/src/app.js index 1b26a4dbd6..e38076580d 100644 --- a/src/app.js +++ b/src/app.js @@ -520,9 +520,11 @@ var run = function () { } compileTimeout = window.setTimeout(function () { var files = {} - files[utils.fileNameFromKey(editor.getCacheFile())] = editor.getValue() + var target = utils.fileNameFromKey(editor.getCacheFile()) - compiler.compile(files) + files[target] = editor.getValue() + + compiler.compile(files, target) }, 300) } diff --git a/src/app/compiler.js b/src/app/compiler.js index 446903a7d6..0715a8f1db 100644 --- a/src/app/compiler.js +++ b/src/app/compiler.js @@ -28,8 +28,8 @@ function Compiler (editor, handleImportCall) { optimize = _optimize } - var internalCompile = function (files, missingInputs) { - gatherImports(files, missingInputs, function (error, input) { + var internalCompile = function (files, target, missingInputs) { + gatherImports(files, target, missingInputs, function (error, input) { if (error) { self.lastCompilationResult = null self.event.trigger('compilationFinished', [false, { 'error': error }, files]) @@ -39,9 +39,9 @@ function Compiler (editor, handleImportCall) { }) } - var compile = function (files) { + var compile = function (files, target) { self.event.trigger('compilationStarted', []) - internalCompile(files) + internalCompile(files, target) } this.compile = compile @@ -120,7 +120,7 @@ function Compiler (editor, handleImportCall) { self.event.trigger('compilationFinished', [false, data, source]) } else if (missingInputs !== undefined && missingInputs.length > 0) { // try compiling again with the new set of inputs - internalCompile(source.sources, missingInputs) + internalCompile(source.sources, source.target, missingInputs) } else { data = updateInterface(data) @@ -208,10 +208,10 @@ function Compiler (editor, handleImportCall) { worker.postMessage({cmd: 'loadVersion', data: url}) } - function gatherImports (files, importHints, cb) { + function gatherImports (files, target, importHints, cb) { importHints = importHints || [] if (!compilerAcceptsMultipleFiles) { - cb(null, files[editor.getCacheFile()]) + cb(null, files[target]) return } @@ -246,14 +246,14 @@ function Compiler (editor, handleImportCall) { cb(err) } else { files[m] = content - gatherImports(files, importHints, cb) + gatherImports(files, target, importHints, cb) } }) return } - cb(null, { 'sources': files }) + cb(null, { 'sources': files, 'target': target }) } function truncateVersion (version) {