2017-02-25 03:49:34 +00:00
|
|
|
var solcProcess = require('child_process').fork(__dirname + '/solcP.js');
|
2017-02-25 20:47:35 +00:00
|
|
|
var compilerLoaded = false;
|
2017-02-25 00:27:27 +00:00
|
|
|
|
|
|
|
var SolcW = function() {
|
|
|
|
};
|
|
|
|
|
|
|
|
SolcW.prototype.load_compiler = function(done) {
|
2017-02-25 20:47:35 +00:00
|
|
|
if (compilerLoaded) { done(); }
|
|
|
|
solcProcess.once('message', function(msg) {
|
2017-02-25 03:49:34 +00:00
|
|
|
if (msg.result !== 'loadedCompiler') {
|
|
|
|
return;
|
|
|
|
}
|
2017-02-25 20:47:35 +00:00
|
|
|
compilerLoaded = true;
|
2017-02-25 03:49:34 +00:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
solcProcess.send({action: 'loadCompiler'});
|
|
|
|
};
|
|
|
|
|
2017-02-25 20:47:35 +00:00
|
|
|
SolcW.prototype.isCompilerLoaded = function() {
|
|
|
|
return (compilerLoaded === true);
|
|
|
|
}
|
|
|
|
|
2017-02-25 03:49:34 +00:00
|
|
|
SolcW.prototype.compile = function(obj, optimize, done) {
|
2017-02-25 20:47:35 +00:00
|
|
|
solcProcess.once('message', function(msg) {
|
2017-02-25 03:49:34 +00:00
|
|
|
if (msg.result !== 'compilation') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
done(msg.output);
|
|
|
|
});
|
|
|
|
solcProcess.send({action: 'compile', obj, optimize});
|
2017-02-25 00:27:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = SolcW;
|
|
|
|
|