Skip to content

Commit

Permalink
Initial support for parsing old URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgodbolt committed Sep 14, 2016
1 parent 4f66930 commit 106ff7c
Show file tree
Hide file tree
Showing 8 changed files with 665 additions and 12 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"jquery": "^3.1.0",
"bootstrap": "^3.3.7",
"selectize": "^0.12.2",
"eventEmitter": "^5.1.0"
"eventEmitter": "^5.1.0",
"lz-string": "^1.4.4"
}
}
6 changes: 5 additions & 1 deletion etc/oldhash.txt
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 13 additions & 1 deletion static/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ define(function (require) {

// Gets the filters that will actually be used (accounting for issues with binary
// mode etc).
Compiler.prototype.getEffectiveFilters = function() {
Compiler.prototype.getEffectiveFilters = function () {
if (!this.compiler) return {};
var filters = this.filters.get();
if (filters.binary && !this.compiler.supportsBinary) {
Expand Down Expand Up @@ -330,6 +330,18 @@ define(function (require) {
componentName: 'compilerOutput',
componentState: {source: editorId}
};
},
getComponentWith: function (editorId, filters, options, compilerId) {
return {
type: 'component',
componentName: 'compilerOutput',
componentState: {
source: editorId,
filters: filters,
options: options,
compiler: compilerId
}
};
}
};
});
14 changes: 11 additions & 3 deletions static/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ define(function (require) {
mode: cmMode
});

if (state.src) {
this.editor.setValue(state.src);
if (state.source) {
this.editor.setValue(state.source);
} else if (defaultSrc) {
this.editor.setValue(defaultSrc);
}
Expand Down Expand Up @@ -166,7 +166,7 @@ define(function (require) {
Editor.prototype.updateState = function () {
this.container.setState({
id: this.id,
src: this.getSource(),
source: this.getSource(),
options: this.options.get()
});
};
Expand Down Expand Up @@ -285,6 +285,14 @@ define(function (require) {
componentState: {id: id},
isClosable: false
};
},
getComponentWith: function (id, source, options) {
return {
type: 'component',
componentName: 'codeEditor',
componentState: {id: id, source: source, options: options},
isClosable: false
};
}
};
});
2 changes: 0 additions & 2 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
<link href="ext/selectize/dist/css/selectize.bootstrap2.css" rel="stylesheet">
<link href="explorer.css" rel="stylesheet">
<script data-main="main" src="ext/requirejs/require.js"></script>
<!--<script src="ext/rison.js"></script>-->
<!--<script src="ext/clipboard.min.js"></script>x-->
<!--<script src="ext/lz-string/lz-string-1.3.3-min.js"></script>-->
</head>
<body>
<div class="navbar navbar-inverse">
Expand Down
17 changes: 13 additions & 4 deletions static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ require.config({
selectize: 'ext/selectize/dist/js/selectize.min',
sifter: 'ext/sifter/sifter.min',
microplugin: 'ext/microplugin/src/microplugin',
events: 'ext/eventEmitter/EventEmitter'
events: 'ext/eventEmitter/EventEmitter',
lzstring: 'ext/lz-string/libs/lz-string'
},
packages: [{
name: "codemirror",
Expand All @@ -54,6 +55,7 @@ define(function (require) {
var GoldenLayout = require('goldenlayout');
var compiler = require('compiler');
var editor = require('editor');
var url = require('url');
var Hub = require('hub');

analytics.initialise();
Expand All @@ -68,9 +70,16 @@ define(function (require) {
content: [{type: 'row', content: [editor.getComponent(1), compiler.getComponent(1)]}]
};
var root = $("#root");
// TODO: find old storage and convert
var savedState = localStorage.getItem('gl');
var config = savedState !== null ? JSON.parse(savedState) : defaultConfig;
var config = url.deserialiseState(window.location.hash.substr(1));
$(window).bind('hashchange', function () {
window.location.reload(); // punt on hash events and just reload the page
});

if (!config) {
// TODO: find old storage and convert
var savedState = localStorage.getItem('gl');
config = savedState !== null ? JSON.parse(savedState) : defaultConfig;
}

var layout = new GoldenLayout(config, root);
layout.on('stateChanged', function () {
Expand Down
Loading

0 comments on commit 106ff7c

Please sign in to comment.