mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-12 15:04:29 +00:00
36 lines
799 B
JavaScript
36 lines
799 B
JavaScript
var solcProcess;
|
|
var compilerLoaded = false;
|
|
|
|
var SolcW = function() {
|
|
};
|
|
|
|
SolcW.prototype.load_compiler = function(done) {
|
|
if (compilerLoaded) { done(); }
|
|
solcProcess = require('child_process').fork(__dirname + '/solcP.js');
|
|
solcProcess.once('message', function(msg) {
|
|
if (msg.result !== 'loadedCompiler') {
|
|
return;
|
|
}
|
|
compilerLoaded = true;
|
|
done();
|
|
});
|
|
solcProcess.send({action: 'loadCompiler'});
|
|
};
|
|
|
|
SolcW.prototype.isCompilerLoaded = function() {
|
|
return (compilerLoaded === true);
|
|
};
|
|
|
|
SolcW.prototype.compile = function(obj, optimize, done) {
|
|
solcProcess.once('message', function(msg) {
|
|
if (msg.result !== 'compilation') {
|
|
return;
|
|
}
|
|
done(msg.output);
|
|
});
|
|
solcProcess.send({action: 'compile', obj, optimize});
|
|
};
|
|
|
|
module.exports = SolcW;
|
|
|