Merge branch 'goldenlayout'

Conflicts:
	etc/config/c++.amazon.properties
	static-old/gcc.css
	static/compiler.js
	static/index.html
dev/git-series/gccdum
Matt Godbolt 7 years ago
commit 15eba4c641

@ -0,0 +1 @@
{ "directory": "static/ext" }

4
.gitignore vendored

@ -1,4 +1,6 @@
*.swp
/node_modules
.npm-updated
/.npm-updated
/.bower-updated
/out
*.heapsnapshot

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value />
</option>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</component>
</project>

@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="gcc-explorer node_modules" level="project" />
</component>
</module>

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<file url="file://$PROJECT_DIR$" libraries="{gcc-explorer node_modules}" />
<file url="file://$PROJECT_DIR$" libraries="{gcc-explorer/node_modules}" />
<file url="file://$PROJECT_DIR$/static/ext/golden-layout" libraries="{gcc-explorer/static/ext/golden-layout/node_modules}" />
<includedPredefinedLibrary name="Node.js Core" />
</component>
</project>

@ -1,15 +0,0 @@
<component name="libraryTable">
<library name="gcc-explorer node_modules" type="javaScript">
<properties>
<option name="frameworkName" value="node_modules" />
<sourceFilesUrls>
<item url="file://$PROJECT_DIR$/node_modules" />
</sourceFilesUrls>
</properties>
<CLASSES>
<root url="file://$PROJECT_DIR$/node_modules" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

@ -1,3 +1,8 @@
ifneq "" "$(NODE_DIR)"
NPM:=$(NODE_DIR)/bin/npm
NODE:=$(NODE_DIR)/bin/npm
default: run
else
ifeq "" "$(shell which npm)"
default:
@echo "Please install node.js"
@ -5,12 +10,15 @@ default:
@echo "On Ubuntu/Debian try: sudo apt-get install nodejs npm"
exit 1
else
NPM:= $(shell which npm)
NODE:= $(shell which node || which nodejs)
default: run
endif
endif
.PHONY: clean run test run-amazon c-preload optional-d-support prereqs
prereqs: optional-d-support node_modules c-preload
.PHONY: clean run test run-amazon c-preload optional-d-support prereqs node_modules bower_modules
.PHONY: dist
prereqs: optional-d-support node_modules c-preload bower_modules
ifeq "" "$(shell which gdc)"
optional-d-support:
@ -22,12 +30,19 @@ endif
NODE_MODULES=.npm-updated
$(NODE_MODULES): package.json
npm install
$(NPM) install
@touch $@
BOWER_MODULES=.bower-updated
$(BOWER_MODULES): bower.json $(NODE_MODULES)
if ! test -f "${BOWER_MODULES}"; then rm -rf static/ext; fi
$(NODE) ./node_modules/bower/bin/bower install
@touch $@
LANG:=C++
node_modules: $(NODE_MODULES)
bower_modules: $(BOWER_MODULES)
test:
(cd test; $(NODE) test.js)
@ -35,12 +50,16 @@ test:
@echo Tests pass
clean:
rm -rf node_modules .npm-updated
rm -rf bower_modules node_modules .npm-updated .bower-updated out static/ext
$(MAKE) -C d clean
$(MAKE) -C c-preload clean
run: node_modules optional-d-support c-preload
$(NODE) ./node_modules/.bin/supervisor -e 'js|node|properties' --exec $(NODE) -- ./app.js --language $(LANG)
run: prereqs
$(NODE) ./node_modules/.bin/supervisor -w app.js,lib,etc/config -e 'js|node|properties' --exec $(NODE) -- ./app.js --language $(LANG)
dist: prereqs
$(NODE) ./node_modules/requirejs/bin/r.js -o app.build.js
c-preload:
$(MAKE) -C c-preload

@ -0,0 +1,16 @@
({
appDir: "static",
baseUrl: ".",
dir: "out/dist",
generateSourceMaps: true,
preserveLicenseComments: false,
optimize: "uglify2",
removeCombined: true,
useStrict: true,
mainConfigFile: "static/main.js",
modules: [
{
name: "main"
}
]
})

@ -135,8 +135,7 @@ function clientOptionsHandler(compilers, fileSources) {
googleAnalyticsEnabled: gccProps('clientGoogleAnalyticsEnabled', false),
sharingEnabled: gccProps('clientSharingEnabled', true),
githubEnabled: gccProps('clientGitHubRibbonEnabled', true),
urlshortener: gccProps('clientURLShortener', 'google'),
gapiKey: gccProps('google-api-key', 'AIzaSyAaz35KJv8DA0ABoime0fEIh32NmbyYbcQ'),
gapiKey: gccProps('googleApiKey', ''),
googleShortLinkRewrite: gccProps('googleShortLinkRewrite', '').split('|'),
defaultSource: gccProps('defaultSource', ''),
language: language,
@ -145,11 +144,13 @@ function clientOptionsHandler(compilers, fileSources) {
defaultCompiler: compilerProps('defaultCompiler', ''),
compileOptions: compilerProps("options"),
supportsBinary: !!compilerProps("supportsBinary"),
sources: sources
postProcess: compilerProps("postProcess"),
sources: sources,
raven: gccProps('ravenUrl', '')
};
var text = "var OPTIONS = " + JSON.stringify(options) + ";";
var text = JSON.stringify(options);
return function getClientOptions(req, res) {
res.set('Content-Type', 'application/javascript');
res.set('Content-Type', 'application/json');
res.set('Cache-Control', 'public, max-age=' + staticMaxAgeMs);
res.end(text);
};
@ -283,7 +284,8 @@ function configuredCompilers() {
is6g: !!props("is6g", false),
intelAsm: props("intelAsm", ""),
needsMulti: !!props("needsMulti", true),
supportsBinary: !!props("supportsBinary", true)
supportsBinary: !!props("supportsBinary", true),
postProcess: props("postProcess", "")
});
}));
}
@ -418,10 +420,11 @@ findCompilers().then(function (compilers) {
.use(logger('combined'))
.use(compression())
.use(sFavicon('static/favicon.ico'))
.use(sStatic('out/dist', {maxAge: staticMaxAgeMs}))
.use(sStatic('static', {maxAge: staticMaxAgeMs}))
.use(bodyParser.json())
.use(restreamer())
.get('/client-options.js', clientOptionsHandler(compilers, fileSources))
.get('/client-options.json', clientOptionsHandler(compilers, fileSources))
.use('/source', getSource)
.use('/api', apiHandler(compilers))
.use('/g', shortUrlHandler)

@ -0,0 +1,31 @@
{
"name": "gcc-explorer",
"description": "Interactively investigate compiler output",
"main": "./app.js",
"authors": [
"Matt Godbolt"
],
"license": "BSD-2-Clause",
"homepage": "https://github.com/mattgodbolt/gcc-explorer",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"codemirror": "CodeMirror#^5.17.0",
"requirejs": "^2.2.0",
"underscore": "^1.8.3",
"golden-layout": "^1.5.6",
"jquery": "^3.1.0",
"bootstrap": "^3.3.7",
"selectize": "^0.12.2",
"eventEmitter": "^5.1.0",
"lz-string": "^1.4.4",
"clipboard": "^1.5.12",
"raven-js": "^3.7.0"
}
}

@ -2,7 +2,7 @@
export LD_PRELOAD=$(dirname $0)/libpreload.so
export ALLOWED_FOR_CREATE=/tmp
export ALLOWED_FOR_READ=/usr/local/include:/usr/include:/usr/lib:/lib:/lib64:/usr/msp430:/usr/arm-linux-gnueabi:/tmp:/opt/:/dev/urandom:/etc/lsb-release:/etc/debian_version:/proc/self:/proc/self/maps:/usr/arm-linux-gnueabihf:/usr/aarch64-linux-gnu:/usr/powerpc-linux-gnu/include:/usr/lib/x86_64-linux-gnu:/usr/mips-linux-gnu:/usr/mipsel-linux-gnu:/usr/mips64-linux-gnuabi64:/usr/mips64el-linux-gnuabi64
export ALLOWED_FOR_READ=/usr/local/include:/usr/include:/usr/lib:/lib:/lib64:/usr/msp430:/usr/arm-linux-gnueabi:/tmp:/opt/:/dev/urandom:/etc/lsb-release:/etc/debian_version:/proc/self:/proc/self/maps:/usr/arm-linux-gnueabihf:/usr/aarch64-linux-gnu:/usr/powerpc-linux-gnu/include:/usr/lib/x86_64-linux-gnu:/usr/mips-linux-gnu:/usr/mipsel-linux-gnu:/usr/mips64-linux-gnuabi64:/usr/mips64el-linux-gnuabi64:/gcc-explorer
export DENIED=/proc/self/cwd:/proc/self/root:/proc/self/exe
# Last-gasp limits
ulimit -t 5 # CPU time in seconds

@ -72,6 +72,14 @@ compiler.clang381.intelAsm=-masm=intel
compiler.clang390.exe=/opt/gcc-explorer/clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang++
compiler.clang390.name=x86-64 clang 3.9.0
compiler.clang390.intelAsm=-masm=intel
compiler.icc16.exe=/opt/gcc-explorer/intel/xe_2016_update3/bin/icc
compiler.icc16.name=x86-64 icc 16
compiler.icc16.intelAsm=-masm=intel
compiler.icc16.needsMulti=false
compiler.icc17.exe=/opt/gcc-explorer/intel/2017/bin/icc
compiler.icc17.name=x86-64 icc 17
compiler.icc17.intelAsm=-masm=intel
compiler.icc17.needsMulti=false
###############################
# GCC for ppc

@ -1,7 +1,11 @@
# Matt's home development computer
defaultCompiler=g54
compilers=g54
compilers=g54:g47:g48
#compilers=localhost@20480
compiler.g54.exe=/usr/bin/g++
compiler.g54.name=g++ 5.4
compiler.g47.exe=/usr/bin/g++-4.7
compiler.g47.name=g++ 4.7
compiler.g48.exe=/usr/bin/g++-4.8
compiler.g48.name=g++ 4.8
#compiler-wrapper=./c-preload/compiler-wrapper

@ -1,9 +1,11 @@
# Settings overridden for Amazon EC2 instances that power http://*.godbolt.org/
googleApiKey=AIzaSyAaz35KJv8DA0ABoime0fEIh32NmbyYbcQ
compileTimeoutMs=5000
compiler-wrapper=./c-preload/compiler-wrapper
max-asm-size=8388608
staticMaxAgeMs=600000
staticMaxAgeMs=30000
cacheMb=50
clientGoogleAnalyticsEnabled=true
proxyRetries=300
proxyRetryMs=500
ravenUrl=https://4574a044b9f8442f86c2ce14490255f1@sentry.io/102028

@ -0,0 +1 @@
ravenUrl=https://4574a044b9f8442f86c2ce14490255f1@sentry.io/102028

@ -1,2 +1,3 @@
language=C++
clientURLShortener=google
ravenUrl=https://4574a044b9f8442f86c2ce14490255f1@sentry.io/102028

@ -1,2 +1,6 @@
http://localhost:10240/#%7B%22version%22%3A2%2C%22source%22%3A%22%23include%20%3Cxmmintrin.h%3E%5Cn%5Cnvoid%20f(__m128%20a%2C%20__m128%20b)%5Cn%7B%5Cn%20%20%2F%2F%20I%20am%20a%20walrus.%5Cn%7D%22%2C%22compiler%22%3A%22%2Fhome%2Fmgodbolt%2Fapps%2Fintel-icc-oss%2Fbin%2Ficc%22%2C%22options%22%3A%22-O3%20-std%3Dc%2B%2B0x%22%2C%22filterAsm%22%3A%7B%22labels%22%3Atrue%2C%22directives%22%3Atrue%7D%7D
http://lud-ldnmg01:10240/#%7B%22version%22%3A2%2C%22source%22%3A%22%23include%20%3Cxmmintrin.h%3E%5Cn%5Cnvoid%20f(__m128%20a%2C%20__m128%20b)%5Cn%7B%5Cn%20%20%2F%2F%20I%20am%20a%20walrus.%5Cn%7D%22%2C%22compiler%22%3A%22%2Fhome%2Fmgodbolt%2Fapps%2Fintel-icc-oss%2Fbin%2Ficc%22%2C%22options%22%3A%22-O3%20-std%3Dc%2B%2B0x%22%2C%22filterAsm%22%3A%7B%22labels%22%3Atrue%2C%22directives%22%3Atrue%7D%7D
-- should be icc, "-O3 -std=c++0x", all filters but comments
http://lud-ldnmg01:10240/#compilers:!((compiler:g7snapshot,options:'-std%3Dc%2B%2B1z+-O3+',source:'%23include+%3Cvector%3E%0A%0Astruct+Widget+%7B%0A++int+n%3B%0A++double+x,+y%3B%0A++Widget(const+Widget%26+o)+:+x(o.x),+y(o.y),+n(o.n)+%7B%7D%0A++Widget(int+n,+double+x,+double+y)+:+n(n),+x(x),+y(y)+%7B%7D%0A%7D%3B%0A%0Astd::vector%3CWidget%3E+vector%3B%0Aconst+int+N+%3D+1002%3B%0Adouble+a+%3D+0.1%3B%0Adouble+b+%3D+0.2%3B%0A%0Avoid+demo()+%7B%0A++vector.reserve(N)%3B%0A++for+(int+i+%3D+01%3B+i+%3C+N%3B+%2B%2Bi)%0A++%7B%0A%09Widget+w+%7Bi,+a,+b%7D%3B%0A%09vector.push_back(w)%3B+//+or+vector.push_back(std::move(w))%0A++%7D%0A%7D%0A%0Aint+main()%0A%7B%0A+%0A+%0A%7D%0A')),filterAsm:(colouriseAsm:!t,commentOnly:!t,directives:!t,intel:!t,labels:!t),version:3
-- should be GCC 7, with widgets source. Binary mode off, all other labels on. -std=c++1z -O3
http://lud-ldnmg01:10240/#compilers:!((compiler:g474,options:'',sourcez:PQKgBALgpgzhYHsBmYDGCC2AHATrGAlggHYB0pamGUx8AFlHmEgjmADY0DmEdAXACgAhiNFjxEyVOkzZw2QsVLl85WvVrVG7TolbdB7fsMmlx0xennLNsddu37Dy0%2BenXbwx8%2B7vPo/7OfoGaIMACAgS0YBhCUQAUUfBCOFyoADSUxHBodClgICApXABuAJRgAN4CYGB4EACuOMRgAIwATADcAgC%2BQAA)),filterAsm:(binary:!t,colouriseAsm:!t,commentOnly:!t,directives:!t,intel:!t,labels:!t),version:3
-- should be 4.7.4, no options, binary, intel, colourise.

@ -225,6 +225,11 @@ Compile.prototype.compile = function (source, compiler, options, filters) {
return Promise.reject("Bad compiler " + compiler);
}
// Don't run binary for unsupported compiles, even if we're asked.
if (filters.binary && !compilerInfo.supportsBinary) {
delete filters.binary;
}
var key = compiler + " | " + source + " | " + options + " | " + JSON.stringify(filters);
var cached = self.cache.get(key);
if (cached) {
@ -249,7 +254,10 @@ Compile.prototype.compile = function (source, compiler, options, filters) {
var compileToAsmPromise = tempFileAndDirPromise.then(function (info) {
var inputFilename = info.inputFilename;
var dirPath = info.dirPath;
var postProcess = compilerProps("postProcess");
var postProcess = [compilerProps("postProcess"), compilerInfo.postProcess];
postProcess = postProcess.filter(function (x) {
return x;
});
var outputFilename = path.join(dirPath, 'output.S');
if (compilerInfo.options) {
options = options.concat(compilerInfo.options.split(" "));
@ -291,9 +299,9 @@ Compile.prototype.compile = function (source, compiler, options, filters) {
result.asm = "<No output: generated assembly was too large (" + stat.size + " > " + maxSize + " bytes)>";
return result;
}
if (postProcess) {
if (postProcess.length) {
return new Promise(function (resolve) {
child_process.exec('cat "' + outputFilename + '" | ' + postProcess,
child_process.exec('cat "' + outputFilename + '" | ' + postProcess.join(" | "),
{maxBuffer: maxSize},
function (err, data) {
if (err)

@ -32,7 +32,9 @@
"underscore-node": "*"
},
"devDependencies": {
"supervisor": "0.3.1"
"supervisor": "0.3.1",
"bower": "*",
"requirejs": "*"
},
"scripts": {
"test": "make test"

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 519 B

After

Width:  |  Height:  |  Size: 519 B

@ -32,20 +32,16 @@ body {
}
.output {
/*height: 40px;*/
height: 80px;
overflow: auto;
font-family: monospace;
font-size: x-small;
}
.compilerVersion {
font-size: small;
}
.compilers-container {
}
.compiler-options {
margin-left: 10px; /* space between the scroll-down and the compiler's options */
margin-left: 10px; // space between the scroll-down and the compiler's options
width: 100%;
}
@ -199,6 +195,7 @@ li.social {
font-weight: bold;
}
/* Only one of these class is currently used on index.html but just in case
* we change it, it is already tuned */
.col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4,
@ -215,7 +212,7 @@ li.social {
}
.panel-primary {
border-color: #000;
border-color: #000;
}
.panel-body {
@ -232,10 +229,10 @@ li.social {
.panel-modest,
.panel-modest .panel-body {
display: inline-block;
}
display: inline-block;
}
.unselectable {
.unselectable{
/* disable text selection on character icons
* source : http://stackoverflow.com/a/9314458/4669135 */
-webkit-touch-callout: none;
@ -277,20 +274,11 @@ li.social {
float: right;
}
.diff-before-button {
background-color: rgba(251, 175, 175, .7);
background-color: rgba(251,175,175,.7);
}
.diff-after-button {
background-color: rgba(151, 234, 151, .6);
}
.well-tiny {
padding: 2px;
border-radius: 2px;
}
.dropdown-menu.compilers {
max-height: 400px;
overflow-y: auto;
background-color: rgba(151,234,151,.6);
}

@ -303,7 +303,47 @@ function resizeEditors() {
_.each(allCompilers, function (compiler) { compiler.resize(windowHeight); });
}
function codeEditorFactory(container, state) {
var template = $('#codeEditor');
var options = state.options;
container.getElement().html(template.html());
return new Editor(container, options.language);
}
function compilerOutputFactory(container, state) {
var template = $('#compiler');
var options = state.options;
container.getElement().html(template.html());
return new CompileToAsm(container);
}
function initialise(options) {
var config = {
content: [{
type: 'row',
content: [{
type: 'component',
componentName: 'codeEditor',
componentState: { options: options }
}, {
type: 'column',
content: [{
type: 'component',
componentName: 'compilerOutput',
componentState: { options: options }
}, {
type: 'component',
componentName: 'compilerOutput',
componentState: { options: options }
}]
}]
}]
};
var myLayout = new GoldenLayout(config, $("#root")[0]);
myLayout.registerComponent('codeEditor', codeEditorFactory);
myLayout.registerComponent('compilerOutput', compilerOutputFactory);
myLayout.init();
/*
var defaultFilters = JSON.stringify(getAsmFilters());
var actualFilters = $.parseJSON(window.localStorage.filter || defaultFilters);
setFilterUi(actualFilters);
@ -376,6 +416,7 @@ function initialise(options) {
$(window).on("resize", resizeEditors);
resizeEditors();
*/
}
function getAsmFilters() {

@ -0,0 +1,363 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Compiler Explorer</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="ext/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="ext/codemirror/codemirror.css" rel="stylesheet">
<link href="ext/golden-layout/goldenlayout-base.css" rel="stylesheet">
<link href="ext/golden-layout/goldenlayout-light-theme.css" rel="stylesheet">
<link href="gcc.css" rel="stylesheet">
<script src="client-options.js"></script>
<script src="ext/codemirror/codemirror.js"></script>
<script src="asm-mode.js"></script>
<script src="ext/jquery/jquery-2.2.2.min.js"></script>
<script src="ext/golden-layout/goldenlayout.min.js"></script>
<script src="ext/jquery-ui-1.11.4/jquery-ui.min.js"></script>
<script src="ext/rison.js"></script>
<script src="ext/underscore-min.js"></script>
<script src="ext/clipboard.min.js"></script>
<script src="compiler.js"></script>
<script src="gcc.js"></script>
<script src="ext/bootstrap/js/bootstrap.min.js"></script>
<script src="ext/lz-string/lz-string-1.3.3-min.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', OPTIONS.googleAnalyticsAccount]);
_gaq.push(['_trackPageview']);
setTimeout(function () {
"use strict";
function create_script_element(id, url) {
var el = document.createElement('script');
el.type = 'text/javascript';
el.async = true;
el.id = id;
el.src = url;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(el, s);
}
create_script_element('urlshortener', 'urlshorten-' + OPTIONS.urlshortener + ".js");
if (OPTIONS.googleAnalyticsEnabled)
create_script_element('ga', ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js');
if (OPTIONS.sharingEnabled) {
create_script_element('gp', 'https://apis.google.com/js/plusone.js');
create_script_element('twitter-wjs', '//platform.twitter.com/widgets.js');
(function(document, i) {
var f,s=document.getElementById(i);
f=document.createElement('iframe');
f.src='//api.flattr.com/button/view/?uid=mattgodbolt&button=compact&url='+encodeURIComponent(document.URL);
f.title='Flattr';
f.height=20;
f.width=110;
f.style.borderWidth=0;
s.appendChild(f);
}(document, 'flattr_button'));
}
}, 0);
</script>
</head>
<body>
<div class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">Compiler Explorer - <span class="language-name"></span></a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="if-github-enabled">
<a href="https://github.com/mattgodbolt/gcc-explorer">Source on GitHub</a>
</li>
<li class="dropdown if-share-enabled">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Donate<b class="caret"></b></a>
<ul class="dropdown-menu">
<li class="navbar-text"><a href="https://www.changetip.com/tipme/mattgodbolt">ChangeTip.Me</a></li>
<li class="navbar-text" id="flattr_button"></li>
</ul>
</li>
<li class="dropdown if-share-enabled">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Share<b class="caret"></b></a>
<ul class="dropdown-menu">
<li class="social">
<g:plusone annotation="inline" width="150"></g:plusone>
</li>
<li class="social"><a href="https://twitter.com/share" class="twitter-share-button"
data-via="mattgodbolt">Tweet</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">About<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="https://plus.google.com/112384289668860490877" rel="publisher">Google+ page</a>
</li>
<li><a href="https://plus.google.com/105166465490735292917" rel="author">About Matt</a></li>
<li><a href="mailto:matt@godbolt.org">Contact Matt</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div id="codeEditor" class="template">
<textarea>// Type your code here, or load an example.</textarea>
</div>
<div id="compiler" class="template">
<div class="panel-body">
<div class="params">
<form class="well well-sm form-inline">
<table>
<tbody>
<tr>
<td class="dropdown compilers-container">
<button type="button" title="Compiler to use" class="btn btn-default dropdown-toggle compiler-selection" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="compiler">g++</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu compilers">
</ul>
</td>
<td>
<input accesskey="" title="Options to pass to compiler" class="compiler-options" placeholder="compiler options" type="text" value="" style="width:90%">
</td>
</tr>
</tbody>
</table>
</form>
</div>
<div class="asm">
<textarea>Awaiting...</textarea>
</div>
<div class="output">
<div class="result">
<div class="topbar">Compiler output &mdash; <span class="compilerVersion"></span></div>
<div class="output">
<div class="template"></div>
</div>
</div>
</div>
</div>
</div>
<div class="container-fluid" id="#root"><!--
<ul id="draggablePanelList" class="list-unstyled">
<li class="panel panel-primary col-md-3">
<div class="panel-heading"><span class="title">Code editor</span></div>
<div class="panel-body">
<div id="commonParams">
<form class="well form-inline files">
<div>
<label>Source: <select class="source"></select></label>
<label>Name: <select class="filename"></select></label>
<button id="new-slot" class="btn btn-sm" title="Open a new slot.">New slot</button>
<button id="new-diff" class="btn btn-sm" title="Open a new diff.">New diff</button>
</div>
<div class="btn-group btn-group-sm">
<button class="btn btn-sm load">Load</button>
<button class="btn btn-sm save">Save</button>
<button class="btn btn-sm saveas">Save as...</button>
<button class="btn btn-sm fulllink" title="Permanent, full URL to this page">Full link</button>
<button class="btn btn-sm shortlink" title="Permanent link to this page as a short link">Short link</button>
</div>
<div class="btn-group btn-group-sm filter">
<button class="btn btn-sm" type="button" value="binary"
title="Compile to binary and disassemble the output">Binary
</button>
<button class="btn btn-sm active nonbinary" type="button"
title="Filter unused labels from the output" value="labels">Unused labels
</button>
<button class="btn btn-sm active nonbinary" type="button"
title="Filter all assembler directives from the output" value="directives">Directives
</button>
<button class="btn btn-sm active nonbinary" type="button"
title="Remove all lines which are only comments from the output" value="commentOnly">
Comment-only lines
</button>
<button class="btn btn-sm" type="button" title="Output disassembly in Intel syntax"
value="intel">Intel syntax
</button>
<button class="btn btn-sm" type="button"
title="Colourise lines so one can see how the source maps to the output"
value="colouriseAsm">Colourise
</button>
</div>
<div class="collapse permalink-collapse">
<div class="input-group input-group-sm permalink">
<input type="text" class="form-control input-sm" placeholder="Loading" readonly id="permalink" size="1024">
<span class="input-group-btn">
<button class="btn btn-sm btn-default clippy" type="button" data-clipboard-target="#permalink"
title="Copy to clipboard">
<img src="ext/clippy.svg" class="clippy" width="13px" alt="Copy to clipboard">
</button>
</span>
</div>
</div>
</form>
</div>
<div class="editor">
<div class="topbar indented">
Code editor
<span class="pull-right input-group input-group-sm">
<button accesskey="a" title="Automatically build when you stop typing"
class="btn btn-default btn-sm autocompile active">
<span class="glyphicon glyphicon-play-circle"></span>
</button>
</span>
</div>
<textarea>// Type your code here, or load an example.</textarea>
</div>
<div class="modal fade" id="saveDialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">&times;</span></button>
<h4>Save as...</h4>
</div>
<div class="modal-body">
<label>Filename: <input class="save-filename" style="width: 30em;" type="text"></label>
</div>
<div class="modal-footer">
<a href="#" data-dismiss="modal" class="btn btn-default">Cancel</a>
<a href="#" class="btn btn-primary save">Save</a>
</div>
</div>
</div>
</div>
</div>
</li>
<li class="panel panel-primary col-md-3 template slot" id="slotTemplate">
<div class="panel-heading">
<span class="title">Slot template (should *not* be visible)</span>
<span class="closeButton unicodeCross unselectable characterIcon">&#10006;</span>
</div>
<div class="panel-body">
<div class="params">
<form class="well well-sm form-inline">
<table>
<tbody>
<tr>
<td>
<p class="leaderSlotIcon unselectable characterIcon unselectedCharacterIcon">&#9734;</p>
<td class="dropdown compilers-container">
&lt;!&ndash; the accesskey is set in static/compiler.js &ndash;&gt;
<button accesskey="" type="button" title="Compiler to use (alt-C)" class="btn btn-default dropdown-toggle compiler-selection" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="compiler">g++</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu compilers">
</ul>
</td>
<td>
&lt;!&ndash; the accesskey is set in static/compiler.js &ndash;&gt;
<input accesskey="" title="Options to pass to compiler (alt-O)" class="compiler-options" placeholder="compiler options" type="text" value="" style="width:90%">
</td>
</tr>
</tbody>
</table>
<div class="btn-group btn-group-sm filter">
&lt;!&ndash; Place slot-specific buttons here. &ndash;&gt;
</div>
</form>
</div>
<div class="asm">
<div class="topbar indented">Assembly output</div>
<textarea>Awaiting...</textarea>
</div>
<div class="output">
<div class="result">
<div class="topbar">Compiler output &mdash; <span class="compilerVersion"></span></div>
<div class="output">
<div class="template"></div>
</div>
</div>
</div>
</div>
<li class="panel panel-primary col-md-3 template diff" id="diffTemplate">
<div class="panel-heading"><span class="title">Diff template (should *not* be visible)</span><span class="closeButton unicodeCross unselectable characterIcon">&#10006;</span></div>
<div class="panel-body">
<div class="params">
<form class="well well-sm form-inline">
<table>
<tbody>
<tr>
<td class="dropdown compilers-container before">
<button type="button"
title="Slot before" class="btn btn-default dropdown-toggle diff-before-button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="slotName">before</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu slotNameList">
</ul>
</td>
<td> <span class="compilers-container unicode-arrow unselectable" >&#8658;</span> </td>
<td class="dropdown compilers-container after">
<button type="button"
title="Slot after" class="btn btn-default dropdown-toggle diff-after-button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="slotName">after</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu slotNameList">
</ul>
</td>
<td> <span class="compilers-container unicode-arrow reverse-diff unselectable characterIcon">&#8646;</span> </td>
</tr>
</tbody>
</table>
</form>
</div>
<div class="diffText">
<div class="topbar indented">Diff output</div>
<textarea>Awaiting...</textarea>
</div>
</div>
</li>
</ul>
--></div>
<div class="template lang c">// Type your code here, or load an example.
int square(int num) {
return num * num;
}
</div>
<div class="template lang rust">// Type your code here, or load an example.
pub fn square(num: i32) -&gt; i32 {
num * num
}
</div>
<div class="template lang go">// Type your code here, or load an example.
// Your function name should start with a capital letter.
package main
func Square(x int) int {
return x * x
}
func main() {}
</div>
<div class="template lang d">// Type your code here, or load an example.
int square(int num) {
return num * num;
}
</div>
<script type="text/javascript">
$(function () {
if (!OPTIONS.sharingEnabled)
$('.if-share-enabled').remove();
if (!OPTIONS.githubEnabled)
$('.if-github-enabled').remove();
});
</script>
</body>
</html>

@ -0,0 +1,31 @@
function googleJSClientLoaded() {
gapi.client.setApiKey(OPTIONS.gapiKey);
gapi.client.load('urlshortener', 'v1', function () {
shortenURL(googleJSClientLoaded.url, googleJSClientLoaded.done);
});
}
function shortenURL(url, done) {
if (!window.gapi || !gapi.client) {
// Load the Google APIs client library asynchronously, then the
// urlshortener API, and finally come back here.
googleJSClientLoaded.url = url;
googleJSClientLoaded.done = done;
$(document.body).append('<script src="https://apis.google.com/js/client.js?onload=googleJSClientLoaded">');
return;
}
var request = gapi.client.urlshortener.url.insert({
resource: {
longUrl: url
}
});
request.then(function (resp) {
var id = resp.result.id;
if (OPTIONS.googleShortLinkRewrite.length === 2) {
id = id.replace(new RegExp(OPTIONS.googleShortLinkRewrite[0]), OPTIONS.googleShortLinkRewrite[1]);
}
done(id);
}, function () {
done(url);
});
}

1
static/.gitignore vendored

@ -0,0 +1 @@
ext

@ -0,0 +1,84 @@
// Copyright (c) 2012-2016, Matt Godbolt
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
define(function (require, exports) {
"use strict";
var options = require('options');
var Raven = require('raven-js');
if (options.raven) {
Raven.config(options.raven).install();
}
if (options.googleAnalyticsEnabled) {
(function (i, s, o, g, r, a, m) {
i.GoogleAnalyticsObject = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments);
};
i[r].l = 1 * new Date();
a = s.createElement(o);
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
exports.ga = window.ga;
ga('create', options.googleAnalyticsAccount, 'auto');
ga('send', 'pageview');
} else {
exports.ga = function () {
};
}
exports.initialise = function () {
setTimeout(function () {
function create_script_element(id, url) {
var el = document.createElement('script');
el.type = 'text/javascript';
el.async = true;
el.id = id;
el.src = url;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(el, s);
}
if (options.sharingEnabled) {
create_script_element('gp', 'https://apis.google.com/js/plusone.js');
create_script_element('twitter-wjs', '//platform.twitter.com/widgets.js');
(function (document, i) {
var f, s = document.getElementById(i);
f = document.createElement('iframe');
f.src = '//api.flattr.com/button/view/?uid=mattgodbolt&button=compact&url=' + encodeURIComponent(document.URL);
f.title = 'Flattr';
f.height = 20;
f.width = 110;
f.style.borderWidth = 0;
s.appendChild(f);
}(document, 'flattr_button'));
}
}, 0);
};
});

@ -22,69 +22,71 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
CodeMirror.defineMode("asm", function () {
function tokenString(quote) {
return function (stream) {
var escaped = false, next, end = false;
while ((next = stream.next()) !== null) {
if (next == quote && !escaped) {
end = true;
break;
define(function (require) {
"use strict";
var CodeMirror = require('codemirror');
CodeMirror.defineMode("asm", function () {
function tokenString(quote) {
return function (stream) {
var escaped = false, next, end = false;
while ((next = stream.next()) !== null) {
if (next == quote && !escaped) {
end = true;
break;
}
escaped = !escaped && next == "\\";
}
escaped = !escaped && next == "\\";
}
return "string";
};
}
return "string";
};
}
var x86_32regName = /\b[re]?(ax|bx|cx|dx|si|di|bp|ip|sp)\b/;
var x86_64regName = /r[\d]+[d]?/;
var x86_xregName = /[xy]mm\d+/;
var x86_keywords = /PTR|BYTE|[DQ]?WORD|XMMWORD|YMMWORD/;
var labelName = /\.L\w+/;
var x86_32regName = /\b[re]?(ax|bx|cx|dx|si|di|bp|ip|sp)\b/;
var x86_64regName = /r[\d]+[d]?/;
var x86_xregName = /[xy]mm\d+/;
var x86_keywords = /PTR|BYTE|[DQ]?WORD|XMMWORD|YMMWORD/;
var labelName = /\.L\w+/;
return {
token: function (stream) {
if (stream.match(/\/\*([^*]|[*][^\/])*\**\//)) {
return "comment";
}
if (stream.match(/^.+:$/)) {
return "variable-2";
}
if (stream.sol() && stream.match(/^\s*\.\w+/)) {
return "header";
}
if (stream.sol() && stream.match(/^\s+\w+/)) {
return "keyword";
}
if (stream.eatSpace()) return null;
if (stream.match(x86_32regName)
|| stream.match(x86_64regName)
|| stream.match(x86_xregName)) {
return "variable-3";
}
if (stream.match(x86_keywords)) return "keyword";
if (stream.match(labelName)) return "variable-2";
var ch = stream.next();
if (ch == '"' || ch == "'") {
return tokenString(ch)(stream);
}
if (/[\[\]{}\(\),;\:]/.test(ch)) return null;
if (/[\d$]/.test(ch) || (ch == '-' && stream.peek().match(/[0-9]/))) {
stream.eatWhile(/[\w\.]/);
return "number";
}
if (ch == '%') {
stream.eatWhile(/\w+/);
return "variable-3";
}
if (ch == '#') {
stream.eatWhile(/.*/);
return "comment";
return {
token: function (stream) {
if (stream.match(/\/\*([^*]|[*][^\/])*\**\//)) {
return "comment";
}
if (stream.match(/^.+:$/)) {
return "variable-2";
}
if (stream.sol() && stream.match(/^\s*\.\w+/)) {
return "header";
}
if (stream.sol() && stream.match(/^\s+\w+/)) {
return "keyword";
}
if (stream.eatSpace()) return null;
if (stream.match(x86_32regName) || stream.match(x86_64regName) || stream.match(x86_xregName)) {
return "variable-3";
}
if (stream.match(x86_keywords)) return "keyword";
if (stream.match(labelName)) return "variable-2";
var ch = stream.next();
if (ch == '"' || ch == "'") {
return tokenString(ch)(stream);
}
if (/[\[\]{}\(\),;\:]/.test(ch)) return null;
if (/[\d$]/.test(ch) || (ch == '-' && stream.peek().match(/[0-9]/))) {
stream.eatWhile(/[\w\.]/);
return "number";
}
if (ch == '%') {
stream.eatWhile(/\w+/);
return "variable-3";
}
if (ch == '#') {
stream.eatWhile(/.*/);
return "comment";
}
return "word";
}
return "word";
}
};
});
};
});
CodeMirror.defineMIME("text/x-asm", "asm");
CodeMirror.defineMIME("text/x-asm", "asm");
});

@ -0,0 +1,3 @@
<svg height="1024" width="896" xmlns="http://www.w3.org/2000/svg">
<path d="M128 768h256v64H128v-64z m320-384H128v64h320v-64z m128 192V448L384 640l192 192V704h320V576H576z m-288-64H128v64h160v-64zM128 704h160v-64H128v64z m576 64h64v128c-1 18-7 33-19 45s-27 18-45 19H64c-35 0-64-29-64-64V192c0-35 29-64 64-64h192C256 57 313 0 384 0s128 57 128 128h192c35 0 64 29 64 64v320h-64V320H64v576h640V768zM128 256h512c0-35-29-64-64-64h-64c-35 0-64-29-64-64s-29-64-64-64-64 29-64 64-29 64-64 64h-64c-35 0-64 29-64 64z" />
</svg>

After

Width:  |  Height:  |  Size: 519 B

@ -0,0 +1,51 @@
// Copyright (c) 2012-2016, Matt Godbolt
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.