diff options
Diffstat (limited to 'lib/compilers/golang.js')
-rw-r--r-- | lib/compilers/golang.js | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/compilers/golang.js b/lib/compilers/golang.js index ee6fd8096..4490b52a0 100644 --- a/lib/compilers/golang.js +++ b/lib/compilers/golang.js @@ -22,19 +22,21 @@ // 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'), _ = require('underscore-node'); -function compilenewgol(info, env) { - const compiler = new Compile(info, env); - compiler.originalGetDefaultExecOptions = compiler.getDefaultExecOptions; +class GolangCompiler extends BaseCompiler { + constructor(info, env) { + super(info, env); + return this.initialise(); + } - function convertNewGoL(code) { + convertNewGoL(code) { const re = /^\s+(0[xX]?[0-9A-Za-z]+)?\s?[0-9]+\s*\(([^:]+):([0-9]+)\)\s*([A-Z]+)(.*)/; let prevLine = null; let file = null; let fileCount = 0; - return _.compact(code.map(function (obj) { + return _.compact(code.map(obj => { const line = obj.text; const match = line.match(re); if (match) { @@ -54,30 +56,28 @@ function compilenewgol(info, env) { })).join("\n"); } - compiler.postProcess = function (result, outputFilename, filters) { - result.asm = convertNewGoL(result.stdout); + postProcess(result, outputFilename, filters) { + result.asm = this.convertNewGoL(result.stdout); result.stdout = []; return Promise.resolve(result); - }; + } - compiler.optionsForFilter = function (filters, outputFilename, userOptions) { + optionsForFilter(filters, outputFilename, userOptions) { // If we're dealing with an older version... if (this.compiler.id === '6g141') { return ['tool', '6g', '-g', '-o', outputFilename, '-S']; } return ['tool', 'compile', '-o', outputFilename, '-S']; - }; + } - compiler.getDefaultExecOptions = function () { - const execOptions = this.originalGetDefaultExecOptions(); + getDefaultExecOptions() { + const execOptions = super.getDefaultExecOptions(); const goroot = this.compilerProps("compiler." + this.compiler.id + ".goroot"); if (goroot) { execOptions.env.GOROOT = goroot; } return execOptions; - }; - - return compiler.initialise(); + } } -module.exports = compilenewgol; +module.exports = GolangCompiler; |