Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Enforce max-statement/line & further unify UI
  • Loading branch information
RubenRBS committed Mar 24, 2018
1 parent 0437f8d commit abb391f
Show file tree
Hide file tree
Showing 14 changed files with 487 additions and 407 deletions.
4 changes: 2 additions & 2 deletions .eslintrc
Expand Up @@ -8,8 +8,8 @@
},
"rules": {
"eqeqeq": ["error", "smart"],
"max-statements": ["warn", 50],
"max-len": ["warn", 120, { "ignoreRegExpLiterals": true }],
"max-statements": ["error", 50],
"max-len": ["error", 120, { "ignoreRegExpLiterals": true }],
"eol-last": ["error", "always"],
"semi": ["error", "always"],
"indent": ["error", 4, { "SwitchCase": 1 }],
Expand Down
10 changes: 7 additions & 3 deletions app.js
Expand Up @@ -241,7 +241,9 @@ function ClientOptionsHandler(fileSources) {
}), 'name');

const supportsBinary = compilerPropsAT(languages, res => !!res, 'supportsBinary', true);
const supportsExecutePerLanguage = compilerPropsAT(languages, (res, lang) => supportsBinary[lang.id] && !!res, 'supportsExecute', true);
const supportsExecutePerLanguage = compilerPropsAT(languages, (res, lang) => {
return supportsBinary[lang.id] && !!res;
}, 'supportsExecute', true);
const supportsExecute = Object.values(supportsExecutePerLanguage).some((value) => value);

const libs = {};
Expand Down Expand Up @@ -303,7 +305,8 @@ function ClientOptionsHandler(fileSources) {
doCache: doCache
};
this.setCompilers = compilers => {
const blacklistedKeys = ['exe', 'versionFlag', 'versionRe', 'compilerType', 'demangler', 'objdumper', 'postProcess'];
const blacklistedKeys = ['exe', 'versionFlag', 'versionRe', 'compilerType', 'demangler', 'objdumper',
'postProcess'];
const copiedCompilers = JSON.parse(JSON.stringify(compilers));
_.each(options.compilers, (compiler, compilersKey) => {
_.each(compiler, (_, propKey) => {
Expand Down Expand Up @@ -649,7 +652,8 @@ Promise.all([findCompilers(), aws.initConfig(awsProps)])
}));
webServer.use(express.static(staticDir));
} else {
//assume that anything not dev is just production this gives sane defaults for anyone who isn't messing with this
/* Assume that anything not dev is just production.
* This gives sane defaults for anyone who isn't messing with this */
logger.info(" serving static files from '" + staticDir + "'");
webServer.use(express.static(staticDir, {maxAge: staticMaxAgeSecs * 1000}));
}
Expand Down
4 changes: 3 additions & 1 deletion lib/base-compiler.js
Expand Up @@ -269,7 +269,9 @@ class BaseCompiler {
const outputFilebase = "output";
const outputFilename = this.getOutputFilename(dirPath, outputFilebase);

options = _.compact(this.prepareArguments(options, filters, backendOptions, inputFilename, outputFilename));
options = _.compact(
this.prepareArguments(options, filters, backendOptions, inputFilename, outputFilename)
);

const execOptions = this.getDefaultExecOptions();

Expand Down
4 changes: 3 additions & 1 deletion lib/exec.js
Expand Up @@ -46,7 +46,9 @@ function execute(command, args, options) {
// AP: Run Windows-volume executables in winTmp. Otherwise, run in tmpDir (which may be undefined).
// https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
const child = child_process.spawn(command, args, {
cwd: options.customCwd ? options.customCwd : (command.startsWith("/mnt") && process.env.wsl) ? process.env.winTmp : process.env.tmpDir,
cwd: options.customCwd ? options.customCwd : (
(command.startsWith("/mnt") && process.env.wsl) ? process.env.winTmp : process.env.tmpDir
),
env: env,
detached: process.platform === 'linux'
});
Expand Down
7 changes: 5 additions & 2 deletions lib/handlers/compile.js
Expand Up @@ -125,7 +125,9 @@ class CompileHandler {
_.each(this.compilersById, compilerInLang => {
if (response === undefined) {
_.each(compilerInLang, compiler => {
if (response === undefined && (compiler.compiler.id === compilerId || compiler.compiler.alias === compilerId)) {
if (response === undefined &&
(compiler.compiler.id === compilerId || compiler.compiler.alias === compilerId)) {

response = compiler;
}
});
Expand Down Expand Up @@ -195,7 +197,8 @@ class CompileHandler {
const {source, options, backendOptions, filters} = this.parseRequest(req, compiler);
const remote = compiler.getRemote();
if (remote) {
req.url = req.originalUrl; // Undo any routing that was done to get here (i.e. /api/* path has been removed)
// Undo any routing that was done to get here (i.e. /api/* path has been removed)
req.url = req.originalUrl;
this.proxy.web(req, res, {target: remote}, e => {
logger.error("Proxy error: ", e);
next(e);
Expand Down
9 changes: 3 additions & 6 deletions lib/pascal-support.js
Expand Up @@ -77,9 +77,7 @@ class PascalDemangler {

demangle(text) {
if (!text.endsWith(':')) return false;
if (this.shouldIgnoreSymbol(text)) {
return false;
}
if (this.shouldIgnoreSymbol(text)) return false;

text = text.substr(0, text.length - 1);

Expand All @@ -91,13 +89,12 @@ class PascalDemangler {
}
}

let unmangledGlobalVar;
if (text.startsWith("U_$OUTPUT_$$_")) {
unmangledGlobalVar = text.substr(13).toLowerCase();
let unmangledGlobalVar = text.substr(13).toLowerCase();
this.symbolStore.Add(text, unmangledGlobalVar);
return unmangledGlobalVar;
} else if (text.startsWith("U_OUTPUT_")) {
unmangledGlobalVar = text.substr(9).toLowerCase();
let unmangledGlobalVar = text.substr(9).toLowerCase();
this.symbolStore.Add(text, unmangledGlobalVar);
return unmangledGlobalVar;
}
Expand Down
4 changes: 2 additions & 2 deletions static/.eslintrc
Expand Up @@ -8,8 +8,8 @@
},
"rules": {
"eqeqeq": ["error", "smart"],
"max-statements": ["warn", 50],
"max-len": ["warn", 120, { "ignoreRegExpLiterals": true }],
"max-statements": ["error", 50],
"max-len": ["error", 120, { "ignoreRegExpLiterals": true }],
"strict": ["error", "safe"],
"eol-last": ["error", "always"],
"semi": ["error", "always"],
Expand Down
10 changes: 10 additions & 0 deletions static/ast-view.js
Expand Up @@ -131,6 +131,16 @@ Ast.prototype.onCompilerClose = function (id) {
};

Ast.prototype.updateState = function () {
this.container.setState(this.currentState());
};

Ast.prototype.currentState = function () {
var state = {
id: this._compilerid,
editorid: this._editorid
};
this.fontScale.addState(state);
return state;
};

Ast.prototype.onCompilerClose = function (id) {
Expand Down
86 changes: 57 additions & 29 deletions static/cfg-view.js
Expand Up @@ -93,28 +93,15 @@ function Cfg(hub, container, state) {
}
};

this.toggles = new Toggles(this.domRoot.find('.options'), state.options);

this.cfgVisualiser = new vis.Network(this.domRoot.find('.graph-placeholder')[0],
this.defaultCfgOutput, this.networkOpts);

this.cfgVisualiser.on('dragEnd', _.bind(this.saveState, this));
this.cfgVisualiser.on('zoom', _.bind(this.saveState, this));

this.toggleNavigationButton = this.domRoot.find('.toggle-navigation');
this.toggleNavigationButton.on('click', _.bind(function () {
this.networkOpts.interaction.navigationButtons = this.toggleNavigationButton.hasClass('active');
this.cfgVisualiser.setOptions(this.networkOpts);
}, this));
this.togglePhysicsButton = this.domRoot.find('.toggle-physics');
this.togglePhysicsButton.on('click', _.bind(function () {
this.networkOpts.physics.enabled = this.togglePhysicsButton.hasClass('active');
// change only physics.enabled option to preserve current node locations
this.cfgVisualiser.setOptions({
physics: {enabled: this.networkOpts.physics.enabled}
});
}, this));
this.initButtons(state);

this.initCallbacks();
this.compilerId = state.id;
this._editorid = state.editorid;
this._binaryFilter = false;
Expand All @@ -137,24 +124,13 @@ function Cfg(hub, container, state) {
}
}, this));

this.eventHub.on('compilerClose', this.onCompilerClose, this);
this.eventHub.on('compileResult', this.onCompileResult, this);
this.eventHub.on('compiler', this.onCompiler, this);
this.eventHub.on('filtersChange', this.onFiltersChange, this);

this.container.on('destroy', this.close, this);
this.container.on('resize', this.resize, this);
this.container.on('shown', this.resize, this);
this.eventHub.emit('cfgViewOpened', this.compilerId);
this.eventHub.emit('requestFilters', this.compilerId);
this.eventHub.emit('requestCompiler', this.compilerId);

this.initCallbacks();
this.adaptStructure = function (names) {
return _.map(names, function (name) {
return {name: name};
});
};

this.updateButtons();
this.setTitle();
}

Expand Down Expand Up @@ -203,6 +179,57 @@ Cfg.prototype.onFiltersChange = function (id, filters) {
}
};

Cfg.prototype.initButtons = function (state) {
this.toggles = new Toggles(this.domRoot.find('.options'), state.options);

this.toggleNavigationButton = this.domRoot.find('.toggle-navigation');
this.toggleNavigationTitle = this.toggleNavigationButton.prop('title');

this.togglePhysicsButton = this.domRoot.find('.toggle-physics');
this.togglePhysicsTitle = this.togglePhysicsButton.prop('title');
};

Cfg.prototype.initCallbacks = function () {
this.eventHub.on('compilerClose', this.onCompilerClose, this);
this.eventHub.on('compileResult', this.onCompileResult, this);
this.eventHub.on('compiler', this.onCompiler, this);
this.eventHub.on('filtersChange', this.onFiltersChange, this);

this.container.on('destroy', this.close, this);
this.container.on('resize', this.resize, this);
this.container.on('shown', this.resize, this);
this.eventHub.emit('cfgViewOpened', this.compilerId);
this.eventHub.emit('requestFilters', this.compilerId);
this.eventHub.emit('requestCompiler', this.compilerId);

this.togglePhysicsButton.on('click', _.bind(function () {
this.networkOpts.physics.enabled = this.togglePhysicsButton.hasClass('active');
// change only physics.enabled option to preserve current node locations
this.cfgVisualiser.setOptions({
physics: {enabled: this.networkOpts.physics.enabled}
});
}, this));

this.toggleNavigationButton.on('click', _.bind(function () {
this.networkOpts.interaction.navigationButtons = this.toggleNavigationButton.hasClass('active');
this.cfgVisualiser.setOptions({interaction: {
navigationButtons: this.networkOpts.interaction.navigationButtons}
});
}, this));
this.toggles.on('change', _.bind(function () {
this.updateButtons();
this.saveState();
}, this));
};

Cfg.prototype.updateButtons = function () {
var formatButtonTitle = function (button, title) {
button.prop('title', '[' + (button.hasClass('active') ? 'ON' : 'OFF') + '] ' + title);
};
formatButtonTitle(this.togglePhysicsButton, this.togglePhysicsTitle);
formatButtonTitle(this.toggleNavigationButton, this.toggleNavigationTitle);
};

Cfg.prototype.resize = function () {
if (this.cfgVisualiser.canvas) {
var height = this.domRoot.height() - this.domRoot.find('.top-bar').outerHeight(true);
Expand All @@ -212,7 +239,8 @@ Cfg.prototype.resize = function () {
};

Cfg.prototype.setTitle = function () {
this.container.setTitle(this._compilerName + ' Graph Viewer (Editor #' + this._editorid + ', Compiler #' + this.compilerId + ')');
this.container.setTitle(
this._compilerName + ' Graph Viewer (Editor #' + this._editorid + ', Compiler #' + this.compilerId + ')');
};

Cfg.prototype.assignLevels = function (data) {
Expand Down

0 comments on commit abb391f

Please sign in to comment.