Add support for the D programming language
This commit is contained in:
parent
2388a90e82
commit
b212c58819
12
Makefile
12
Makefile
|
@ -7,6 +7,14 @@ else
|
|||
default: run
|
||||
endif
|
||||
|
||||
ifeq "" "$(shell which gdc-4.6)"
|
||||
optional_d_support:
|
||||
@echo "D language support disabled"
|
||||
else
|
||||
optional_d_support:
|
||||
$(MAKE) -C d
|
||||
endif
|
||||
|
||||
NODE_MODULES=.npm-updated
|
||||
$(NODE_MODULES): package.json
|
||||
npm install
|
||||
|
@ -23,9 +31,9 @@ clean:
|
|||
|
||||
.PHONY: clean run test run-amazon
|
||||
|
||||
run: node_modules
|
||||
run: node_modules optional_d_support
|
||||
./node_modules/.bin/supervisor ./app.js
|
||||
|
||||
run-amazon: node_modules
|
||||
run-amazon: node_modules optional_d_support
|
||||
$(MAKE) -C c-preload
|
||||
./node_modules/.bin/supervisor -- ./app.js --env amazon
|
||||
|
|
18
app.js
18
app.js
|
@ -109,19 +109,23 @@ function compile(req, res) {
|
|||
if (sourceErr) {
|
||||
return res.end(JSON.stringify({code: -1, stderr: sourceErr}));
|
||||
}
|
||||
|
||||
compileTask = function(taskFinished) {
|
||||
var compileTask = function(taskFinished) {
|
||||
temp.mkdir('gcc-explorer-compiler', function(err, dirPath) {
|
||||
if (err) {
|
||||
return res.end(JSON.stringify({code: -1, stderr: "Unable to open temp file: " + err}));
|
||||
}
|
||||
var postProcess = props.get("gcc-explorer", "postProcess");
|
||||
var inputFilename = path.join(dirPath, props.get("gcc-explorer", "compileFilename"));
|
||||
var outputFilename = path.join(dirPath, 'output.S');
|
||||
if (compilerInfo.supportedOpts['-masm']) {
|
||||
var syntax = '-masm=att'; // default at&t
|
||||
if (filters["intel"] == "true") syntax = '-masm=intel';
|
||||
options = options.concat([syntax]);
|
||||
}
|
||||
options = options.concat(['-x', 'c++', '-g', '-o', outputFilename, '-S', '-']);
|
||||
options = options.concat(['-g', '-o', outputFilename, '-S', inputFilename]);
|
||||
var file = fs.openSync(inputFilename, "w");
|
||||
fs.writeSync(file, source);
|
||||
fs.closeSync(file);
|
||||
var compilerWrapper = props.get("gcc-explorer", "compiler-wrapper");
|
||||
if (compilerWrapper) {
|
||||
options = [compiler].concat(options);
|
||||
|
@ -141,7 +145,7 @@ function compile(req, res) {
|
|||
child.stderr.on('data', function (data) { stderr += data; });
|
||||
child.on('exit', function (code) {
|
||||
clearTimeout(timeout);
|
||||
child_process.exec('cat "' + outputFilename + '" | c++filt',
|
||||
child_process.exec('cat "' + outputFilename + '" | ' + postProcess,
|
||||
{ maxBuffer: props.get("gcc-explorer", "max-asm-size", 8 * 1024 * 1024) },
|
||||
function(err, filt_stdout, filt_stderr) {
|
||||
var data = filt_stdout;
|
||||
|
@ -154,11 +158,13 @@ function compile(req, res) {
|
|||
stderr: stderr,
|
||||
asm: data,
|
||||
code: code }));
|
||||
fs.unlink(outputFilename, function() { fs.rmdir(dirPath); });
|
||||
fs.unlink(outputFilename, function() {
|
||||
fs.unlink(inputFilename,
|
||||
function() { fs.rmdir(dirPath); });
|
||||
});
|
||||
taskFinished();
|
||||
});
|
||||
});
|
||||
child.stdin.write(source);
|
||||
child.stdin.end();
|
||||
});
|
||||
};
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
demangle
|
|
@ -0,0 +1,3 @@
|
|||
GDC=gdc-4.6
|
||||
demangle: demangle.d
|
||||
$(GDC) -O2 $< -o $@
|
|
@ -0,0 +1,16 @@
|
|||
import std.stdio;
|
||||
import std.demangle;
|
||||
import std.regex;
|
||||
|
||||
void main() {
|
||||
string dem(RegexMatch!(string) m)
|
||||
{
|
||||
return demangle(m.hit);
|
||||
}
|
||||
|
||||
foreach (line; stdin.byLine()) {
|
||||
string s2 = cast(string)line;
|
||||
auto s = replace!(dem)(s2, regex("[_$a-zA-Z][_$a-zA-Z0-9]*", "g"));
|
||||
writeln(s);
|
||||
}
|
||||
}
|
|
@ -1,2 +1,6 @@
|
|||
# Settings used on Matt's laptop.
|
||||
compilers=/usr/bin/g++-4.4:/usr/bin/g++-4.5:/usr/bin/g++-4.6:/usr/bin/g++-4.7:/usr/bin/clang++:/home/mgodbolt/apps/intel-icc-oss/bin/icc:/usr/bin/arm-linux-gnueabi-g++-4.6
|
||||
# Default settings for GCC Explorer.
|
||||
port=10240
|
||||
compileTimeoutMs=4000
|
||||
compilers=/usr/bin/gdc-4.6
|
||||
compileFilename=example.d
|
||||
postProcess=d/demangle
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
<div class="span6">
|
||||
<form class="well form-inline">
|
||||
<label>Compiler: <select class="compiler"></select></label>
|
||||
<label>Compiler options: <input class="compiler_options" style="width: 30em;" type="text" value="-O2 -std=c++0x -march=native"></label>
|
||||
<label>Compiler options: <input class="compiler_options" style="width: 30em;" type="text" value="-O2 -march=native"></label>
|
||||
<table><tbody><tr><td>Filter: </td>
|
||||
<td>
|
||||
<div class="btn-group filter">
|
||||
|
@ -87,8 +87,8 @@
|
|||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span6 editor">
|
||||
<div class="topbar indented">C++ editor</div>
|
||||
<textarea>// Type C++ code here, or load an example.</textarea>
|
||||
<div class="topbar indented">Code editor</div>
|
||||
<textarea>// Type your code here, or load an example.</textarea>
|
||||
</div>
|
||||
<div class="span6 asm">
|
||||
<div class="topbar indented">Assembly output</div>
|
||||
|
|
Loading…
Reference in New Issue