Browse Source

Do all filtering on the server

dev/git-series/gccdum
Matt Godbolt 7 years ago
parent
commit
4b47e425d7
  1. 4
      .idea/encodings.xml
  2. 4
      .idea/misc.xml
  3. 0
      lib/asm.js
  4. 6
      lib/compile.js
  5. 22
      static/compiler.js
  6. 1
      static/index.html

4
.idea/encodings.xml

@ -1,4 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

4
.idea/misc.xml

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" />
</project>

0
static/asm.js → lib/asm.js

6
lib/compile.js

@ -30,7 +30,8 @@ var props = require('./properties'),
LRU = require('lru-cache'),
fs = require('fs-extra'),
Promise = require('promise'),
Queue = require('promise-queue');
Queue = require('promise-queue'),
asm = require('./asm');
Queue.configure(Promise);
temp.track();
@ -157,7 +158,7 @@ Compile.prototype.compile = function (source, compiler, options, filters) {
return Promise.reject("Bad compiler " + compiler);
}
var key = compiler + " | " + source + " | " + options + " | " + filters.intel;
var key = compiler + " | " + source + " | " + options + " | " + JSON.stringify(filters);
var cached = self.cache.get(key);
if (cached) {
self.cacheHits++;
@ -232,6 +233,7 @@ Compile.prototype.compile = function (source, compiler, options, filters) {
result.dirPath = undefined;
}
if (result.okToCache) {
result.asm = asm.processAsm(result.asm, filters);
self.cache.set(key, result);
self.cacheStats();
}

22
static/compiler.js

@ -156,7 +156,7 @@ function Compiler(domRoot, origFilters, windowLocalPrefix, onChangeCallback, lan
elem.text(msg);
}
});
currentAssembly = data.asm || "[no output]";
currentAssembly = data.asm || fakeAsm("[no output]");
updateAsm();
}
@ -180,20 +180,16 @@ function Compiler(domRoot, origFilters, windowLocalPrefix, onChangeCallback, lan
function updateAsm(forceUpdate) {
if (!currentAssembly) return;
var hashedUpdate = JSON.stringify({
asm: currentAssembly,
filters: filters
});
var hashedUpdate = JSON.stringify(currentAssembly);
if (!forceUpdate && lastUpdatedAsm == hashedUpdate) {
return;
}
lastUpdatedAsm = hashedUpdate;
var asm = processAsm(currentAssembly, filters);
var asmText = $.map(asm, function (x) {
var asmText = $.map(currentAssembly, function (x) {
return x.text;
}).join("\n");
var numberedLines = numberUsedLines(asm);
var numberedLines = numberUsedLines(currentAssembly);
cppEditor.operation(function () {
clearBackground(cppEditor);
@ -218,8 +214,8 @@ function Compiler(domRoot, origFilters, windowLocalPrefix, onChangeCallback, lan
}
}
function pickOnlyRequestFilters(filters) {
return {intel: !!filters.intel};
function fakeAsm(text) {
return [{text: text, source: null}];
}
function onChange() {
@ -230,7 +226,7 @@ function Compiler(domRoot, origFilters, windowLocalPrefix, onChangeCallback, lan
source: cppEditor.getValue(),
compiler: $('.compiler').val(),
options: $('.compiler_options').val(),
filters: pickOnlyRequestFilters(filters),
filters: filters,
};
setSetting('compiler', data.compiler);
setSetting('compilerOptions', data.options);
@ -248,7 +244,7 @@ function Compiler(domRoot, origFilters, windowLocalPrefix, onChangeCallback, lan
onCompileResponse(data, result);
}
});
currentAssembly = "[Processing...]";
currentAssembly = fakeAsm("[Processing...]");
updateAsm();
}, 750);
setSetting('code', cppEditor.getValue());
@ -328,7 +324,7 @@ function Compiler(domRoot, origFilters, windowLocalPrefix, onChangeCallback, lan
function setFilters(f) {
filters = f;
onChange(); // used to just update ASM, but things like "Intel syntax" need a new request
onChange();
}
function setEditorHeight(height) {

1
static/index.html

@ -7,7 +7,6 @@
<link href="gcc.css" rel="stylesheet">
<script src="client-options.js"></script>
<script src="ext/codemirror/codemirror.js"></script>
<script src="asm.js"></script>
<script src="asm-mode.js"></script>
<script src="ext/jquery/jquery-1.7.1.min.js"></script>
<script src="compiler.js"></script>

Loading…
Cancel
Save