aboutsummaryrefslogtreecommitdiff
path: root/lib/compilers/ppci.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compilers/ppci.js')
-rw-r--r--lib/compilers/ppci.js32
1 files changed, 13 insertions, 19 deletions
diff --git a/lib/compilers/ppci.js b/lib/compilers/ppci.js
index aedfea4f6..0cc63dce3 100644
--- a/lib/compilers/ppci.js
+++ b/lib/compilers/ppci.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2018, Windel Bouwman and Patrick Quist
+// Copyright (c) 2018, Windel Bouwman & Patrick Quist
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -22,35 +22,29 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
-const Compile = require('../base-compiler'),
+const BaseCompiler = require('../base-compiler'),
exec = require('../exec'),
logger = require('../logger').logger;
-function compilePpci(info, env) {
- const compiler = new Compile(info, env);
- const originalExec = compiler.exec;
-
- compiler.exec = function (compiler, args, options) {
+class PPCICompiler extends BaseCompiler {
+ exec(compiler, args, options) {
if (compiler.endsWith('.py')) {
- const python = env.ceProps("python3");
+ const python = this.env.ceProps('python3');
options = options || {};
const matches = compiler.match(/^(.*)(\/ppci\/)(.*).py/);
if (matches) {
- const pythonpath = matches[1];
- const ppciname = "ppci." + matches[3].replace('/', '.');
- options.env = {'PYTHONPATH': pythonpath};
- let python_args = ['-m', ppciname].concat(args);
+ const pythonPath = matches[1];
+ const ppciName = `ppci.${matches[3].replace('/', '.')}`;
+ options.env = {PYTHONPATH: pythonPath};
+ let python_args = ['-m', ppciName].concat(args);
return exec.execute(python, python_args, options);
- } else {
- logger.error('invalid ppci path');
}
+ logger.error(`Invalid ppci path ${compiler}`);
} else {
- return originalExec(compiler, args, options);
+ return super.exec(compiler, args, options);
}
- };
-
- return compiler.initialise();
+ }
}
-module.exports = compilePpci;
+module.exports = PPCICompiler;