diff --git a/static/compiler.js b/static/compiler.js index 3e4800a71..3702eefb5 100644 --- a/static/compiler.js +++ b/static/compiler.js @@ -67,7 +67,6 @@ define(function (require) { this.compiler = compilersById[state.compiler] || compilersById[options.defaultCompiler]; this.options = state.options || options.compileOptions; this.filters = new Toggles(this.domRoot.find(".filters"), state.filters); - this.unexpandedSource = ""; this.source = ""; this.assembly = []; this.colours = []; @@ -168,7 +167,7 @@ define(function (require) { this.mouseMoveThrottledFunction = _.throttle(_.bind(this.onMouseMove, this), 250); - this.outputEditor.onMouseLeave(function (e) { + this.outputEditor.onMouseLeave(function () { self.linkedFadeTimeoutId = setTimeout(function () { clearEditorsLinkedLines(); self.linkedFadeTimeoutId = -1; @@ -231,11 +230,11 @@ define(function (require) { } function createOptView() { - return Components.getOptViewWith(self.id, self.unexpandedSource, self.lastResult.optOutput, self.getCompilerName(), self.sourceEditorId); + return Components.getOptViewWith(self.id, self.source, self.lastResult.optOutput, self.getCompilerName(), self.sourceEditorId); } function createAstView() { - return Components.getAstViewWith(self.id, self.unexpandedSource, self.lastResult.astOutput, self.getCompilerName(), self.sourceEditorId); + return Components.getAstViewWith(self.id, self.source, self.lastResult.astOutput, self.getCompilerName(), self.sourceEditorId); } this.container.layoutManager.createDragSource( @@ -299,20 +298,22 @@ define(function (require) { Compiler.prototype.compile = function () { var shouldProduceAst = this.astViewOpen; - var request = { - source: this.source || "", - compiler: this.compiler ? this.compiler.id : "", - options: this.options, - backendOptions: {produceAst: shouldProduceAst}, - filters: this.getEffectiveFilters() - }; + this.expand(this.source).then(_.bind(function (expanded) { + var request = { + source: expanded || "", + compiler: this.compiler ? this.compiler.id : "", + options: this.options, + backendOptions: {produceAst: shouldProduceAst}, + filters: this.getEffectiveFilters() + }; - if (!this.compiler) { - this.onCompileResponse(request, errorResult(""), false); - return; - } + if (!this.compiler) { + this.onCompileResponse(request, errorResult(""), false); + } else { + this.sendCompile(request); + } + }, this)); - this.sendCompile(request); }; Compiler.prototype.sendCompile = function (request) { @@ -449,6 +450,7 @@ define(function (require) { timingVar: request.compiler, timingValue: timeTaken }); + this.setAssembly(result.asm || fakeAsm("")); if (request.filters.binary) { this.outputEditor.updateOptions({ @@ -462,7 +464,7 @@ define(function (require) { }); } var status = this.domRoot.find(".status"); - var allText = _.pluck((result.stdout || []).concat(result.stderr | []), 'text').join("\n"); + var allText = _.pluck((result.stdout || []).concat(result.stderr || []), 'text').join("\n"); var failed = result.code !== 0; var warns = !failed && !!allText; status.toggleClass('error', failed); @@ -514,11 +516,8 @@ define(function (require) { Compiler.prototype.onEditorChange = function (editor, source) { if (editor === this.sourceEditorId) { - this.unexpandedSource = source; - this.expand(source).then(_.bind(function (expanded) { - this.source = expanded; - this.compile(); - }, this)); + this.source = source; + this.compile(); } }; diff --git a/static/editor.js b/static/editor.js index c9534d487..ce2bc7f42 100644 --- a/static/editor.js +++ b/static/editor.js @@ -273,9 +273,11 @@ define(function (require) { return Components.getCompiler(this.id); }, this); + var addCompilerButton = this.domRoot.find('.btn.add-compiler'); + this.container.layoutManager.createDragSource( - this.domRoot.find('.btn.add-compiler'), compilerConfig()); - this.domRoot.find('.btn.add-compiler').click(_.bind(function () { + addCompilerButton, compilerConfig()); + addCompilerButton.click(_.bind(function () { var insertPoint = hub.findParentRowOrColumn(this.container) || this.container.layoutManager.root.contentItems[0]; insertPoint.addChild(compilerConfig()); diff --git a/views/templates.pug b/views/templates.pug index 4bda8d5bf..4beee9fea 100644 --- a/views/templates.pug +++ b/views/templates.pug @@ -15,7 +15,7 @@ table tr td: select.compiler-picker(placeholder="Select a compiler...") - td: input.options.form-control(type="text" placeholder="compiler options..." size="256") + td: input.options.form-control(type="text" placeholder="Compiler options..." size="256") div.btn-group.btn-group-sm.filters(data-toggle="buttons") // TODO store these in the app and drive from there? // Make a dropdown? With more options? e.g. demangling etc