mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-11-30 22:11:18 -06:00
Merging request options into 1 options object, this makes it clearer to me
This commit is contained in:
@@ -143,18 +143,22 @@ Compile.prototype.optionsForFilter = function (filters, outputFilename) {
|
||||
if (this.compiler.intelAsm && filters.intel && !filters.binary) {
|
||||
options = options.concat(this.compiler.intelAsm.split(" "));
|
||||
}
|
||||
if(this.compiler.supportsOptOutput && filters.optOutput) {
|
||||
options = options.concat(this.compiler.optArg);
|
||||
}
|
||||
if (!filters.binary) options = options.concat('-S');
|
||||
return options;
|
||||
};
|
||||
|
||||
Compile.prototype.prepareArguments = function (userOptions, filters, inputFilename, outputFilename) {
|
||||
Compile.prototype.prepareArguments = function (userOptions, filters, backendOptions, inputFilename, outputFilename) {
|
||||
var options = this.optionsForFilter(filters, outputFilename);
|
||||
backendOptions = backendOptions || {};
|
||||
|
||||
if (this.compiler.options) {
|
||||
options = options.concat(this.compiler.options.split(" "));
|
||||
}
|
||||
|
||||
if(this.compiler.supportsOptOutput && backendOptions.produceOptInfo) {
|
||||
options = options.concat(this.compiler.optArg);
|
||||
}
|
||||
|
||||
return options.concat(userOptions || []).concat([this.filename(inputFilename)]);
|
||||
};
|
||||
|
||||
@@ -213,7 +217,7 @@ Compile.prototype.compile = function (source, options, backendOptions, filters)
|
||||
var dirPath = info.dirPath;
|
||||
var outputFilebase = "output";
|
||||
var outputFilename = path.join(dirPath, outputFilebase + ".s"); // NB keep lower case as ldc compiler `tolower`s the output name
|
||||
options = self.prepareArguments(options, filters, inputFilename, outputFilename);
|
||||
options = self.prepareArguments(options, filters, backendOptions, inputFilename, outputFilename);
|
||||
|
||||
options = options.filter(_.identity);
|
||||
|
||||
|
||||
@@ -94,10 +94,11 @@ function CompileHandler(gccProps, compilerProps) {
|
||||
// JSON-style request
|
||||
compiler = this.compilersById[req.compiler || req.body.compiler];
|
||||
if (!compiler) return next();
|
||||
var requestOptions = req.body.options;
|
||||
source = req.body.source;
|
||||
options = req.body.options;
|
||||
backendOptions = req.body.backendOptions;
|
||||
filters = req.body.filters || compiler.getDefaultFilters();
|
||||
options = requestOptions.userArguments;
|
||||
backendOptions = requestOptions.compilerOptions;
|
||||
filters = requestOptions.filters || compiler.getDefaultFilters();
|
||||
} else {
|
||||
// API-style
|
||||
compiler = this.compilersById[req.compiler];
|
||||
|
||||
+14
-10
@@ -70,7 +70,7 @@ define(function (require) {
|
||||
this.pendingRequestSentAt = 0;
|
||||
this.nextRequest = null;
|
||||
this.settings = {};
|
||||
|
||||
this.wantOptInfo = state.wantOptInfo;
|
||||
this.decorations = {};
|
||||
this.prevDecorations = [];
|
||||
this.optButton = this.domRoot.find('.btn.view-optimization');
|
||||
@@ -248,7 +248,7 @@ define(function (require) {
|
||||
this.optButton, createOptView.bind(this));
|
||||
|
||||
this.optButton.click(_.bind(function () {
|
||||
this.filters.set("optOutput", true);
|
||||
this.wantOptInfo = true;
|
||||
var insertPoint = hub.findParentRowOrColumn(this.container) ||
|
||||
this.container.layoutManager.root.contentItems[0];
|
||||
insertPoint.addChild(createOptView());
|
||||
@@ -296,15 +296,17 @@ define(function (require) {
|
||||
|
||||
|
||||
Compiler.prototype.compile = function () {
|
||||
var options = {
|
||||
userArguments: this.options,
|
||||
compilerOptions: { produceAst: this.astViewOpen, produceOptInfo: this.wantOptInfo },
|
||||
filters: this.getEffectiveFilters()
|
||||
};
|
||||
this.compilerService.expand(this.source).then(_.bind(function (expanded) {
|
||||
var request = {
|
||||
source: expanded || "",
|
||||
compiler: this.compiler ? this.compiler.id : "",
|
||||
options: this.options,
|
||||
backendOptions: {produceAst: this.astViewOpen},
|
||||
filters: this.getEffectiveFilters()
|
||||
options: options
|
||||
};
|
||||
|
||||
if (!this.compiler) {
|
||||
this.onCompileResponse(request, errorResult("<Please select a compiler>"), false);
|
||||
} else {
|
||||
@@ -425,7 +427,7 @@ define(function (require) {
|
||||
hitType: 'event',
|
||||
eventCategory: 'Compile',
|
||||
eventAction: request.compiler,
|
||||
eventLabel: request.options,
|
||||
eventLabel: request.options.userArguments,
|
||||
eventValue: cached ? 1 : 0
|
||||
});
|
||||
ga('send', {
|
||||
@@ -436,7 +438,7 @@ define(function (require) {
|
||||
});
|
||||
|
||||
this.setAssembly(result.asm || fakeAsm("<No output>"));
|
||||
if (request.filters.binary) {
|
||||
if (request.options.filters.binary) {
|
||||
this.outputEditor.updateOptions({
|
||||
lineNumbers: _.bind(this.getBinaryForLine, this),
|
||||
lineNumbersMinChars: 19
|
||||
@@ -480,7 +482,7 @@ define(function (require) {
|
||||
|
||||
Compiler.prototype.onOptViewClosed = function (id) {
|
||||
if (this.id == id) {
|
||||
this.filters.set("optOutput", false);
|
||||
this.wantOptInfo = false;
|
||||
this.optButton.prop("disabled", false);
|
||||
}
|
||||
};
|
||||
@@ -565,7 +567,9 @@ define(function (require) {
|
||||
compiler: this.compiler ? this.compiler.id : "",
|
||||
source: this.sourceEditorId,
|
||||
options: this.options,
|
||||
filters: this.filters.get() // NB must *not* be effective filters
|
||||
// NB must *not* be effective filters
|
||||
filters: this.filters.get(),
|
||||
wantOptInfo: this.wantOptInfo
|
||||
};
|
||||
this.fontScale.addState(state);
|
||||
return state;
|
||||
|
||||
Reference in New Issue
Block a user