From 4b47e425d75d5bcfddfccd0fe9c04bb75a1b2918 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Wed, 11 Nov 2015 17:41:19 -0600 Subject: [PATCH] Do all filtering on the server --- .idea/encodings.xml | 4 +++- .idea/misc.xml | 4 ---- {static => lib}/asm.js | 0 lib/compile.js | 6 ++++-- static/compiler.js | 22 +++++++++------------- static/index.html | 1 - 6 files changed, 16 insertions(+), 21 deletions(-) delete mode 100644 .idea/misc.xml rename {static => lib}/asm.js (100%) diff --git a/.idea/encodings.xml b/.idea/encodings.xml index d82104827..f75895965 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -1,4 +1,6 @@ - + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 8662aa97f..000000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/static/asm.js b/lib/asm.js similarity index 100% rename from static/asm.js rename to lib/asm.js diff --git a/lib/compile.js b/lib/compile.js index 76ca2e5d9..82e922718 100644 --- a/lib/compile.js +++ b/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(); } diff --git a/static/compiler.js b/static/compiler.js index 32e18fd55..d0ba013e8 100644 --- a/static/compiler.js +++ b/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) { diff --git a/static/index.html b/static/index.html index 01db77b53..a73e88a70 100644 --- a/static/index.html +++ b/static/index.html @@ -7,7 +7,6 @@ -