TrMen | ed4c581 | 2022-07-09 17:03:23 +0200 | [diff] [blame] | 1 | // Copyright (c) 2022, Compiler Explorer Authors |
| 2 | // All rights reserved. |
| 3 | // |
| 4 | // Redistribution and use in source and binary forms, with or without |
| 5 | // modification, are permitted provided that the following conditions are met: |
| 6 | // |
| 7 | // * Redistributions of source code must retain the above copyright notice, |
| 8 | // this list of conditions and the following disclaimer. |
| 9 | // * Redistributions in binary form must reproduce the above copyright |
| 10 | // notice, this list of conditions and the following disclaimer in the |
| 11 | // documentation and/or other materials provided with the distribution. |
| 12 | // |
| 13 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 14 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 16 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 17 | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 23 | // POSSIBILITY OF SUCH DAMAGE. |
| 24 | |
| 25 | import path from 'path'; |
| 26 | |
| 27 | import {ExecutionOptions} from '../../types/compilation/compilation.interfaces'; |
Jeremy Rifkin | 6a6efae | 2023-01-29 13:22:30 -0500 | [diff] [blame] | 28 | import {CompilerInfo} from '../../types/compiler.interfaces'; |
Marc Poulhiès | 2fa2bbb | 2022-11-28 21:37:15 +0100 | [diff] [blame] | 29 | import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces'; |
TrMen | ed4c581 | 2022-07-09 17:03:23 +0200 | [diff] [blame] | 30 | import {BaseCompiler} from '../base-compiler'; |
TrMen | ed4c581 | 2022-07-09 17:03:23 +0200 | [diff] [blame] | 31 | |
| 32 | export class JaktCompiler extends BaseCompiler { |
| 33 | static get key() { |
| 34 | return 'jakt'; |
| 35 | } |
| 36 | |
Jeremy Rifkin | 6a6efae | 2023-01-29 13:22:30 -0500 | [diff] [blame] | 37 | constructor(info: CompilerInfo, env) { |
TrMen | ed4c581 | 2022-07-09 17:03:23 +0200 | [diff] [blame] | 38 | super(info, env); |
| 39 | |
TrMen | ed4c581 | 2022-07-09 17:03:23 +0200 | [diff] [blame] | 40 | this.outputFilebase = 'example'; |
| 41 | } |
| 42 | |
Romaric Jodin | 72a19da | 2022-10-10 13:02:50 +0200 | [diff] [blame] | 43 | override getCompilerResultLanguageId() { |
| 44 | return 'cppp'; |
partouf | b8e4d2d | 2022-10-12 21:11:47 +0200 | [diff] [blame] | 45 | } |
| 46 | |
Marc Poulhiès | 2fa2bbb | 2022-11-28 21:37:15 +0100 | [diff] [blame] | 47 | override async objdump( |
| 48 | outputFilename, |
| 49 | result: any, |
| 50 | maxSize: number, |
| 51 | intelAsm, |
| 52 | demangle, |
Jeremy Rifkin | 6a6efae | 2023-01-29 13:22:30 -0500 | [diff] [blame] | 53 | staticReloc: boolean, |
| 54 | dynamicReloc: boolean, |
Marc Poulhiès | 2fa2bbb | 2022-11-28 21:37:15 +0100 | [diff] [blame] | 55 | filters: ParseFiltersAndOutputOptions, |
| 56 | ) { |
Marc Poulhiès | 6905568 | 2023-01-11 19:39:25 +0100 | [diff] [blame] | 57 | const objdumpResult = await super.objdump( |
| 58 | outputFilename, |
| 59 | result, |
| 60 | maxSize, |
| 61 | intelAsm, |
| 62 | demangle, |
| 63 | staticReloc, |
| 64 | dynamicReloc, |
| 65 | filters, |
| 66 | ); |
| 67 | |
partouf | b8e4d2d | 2022-10-12 21:11:47 +0200 | [diff] [blame] | 68 | objdumpResult.languageId = 'asm'; |
| 69 | return objdumpResult; |
Romaric Jodin | 72a19da | 2022-10-10 13:02:50 +0200 | [diff] [blame] | 70 | } |
| 71 | |
Marc Poulhiès | 2fa2bbb | 2022-11-28 21:37:15 +0100 | [diff] [blame] | 72 | override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: any) { |
TrMen | ed4c581 | 2022-07-09 17:03:23 +0200 | [diff] [blame] | 73 | return ['--binary-dir', path.dirname(outputFilename)]; |
| 74 | } |
| 75 | |
Jeremy Rifkin | 6a6efae | 2023-01-29 13:22:30 -0500 | [diff] [blame] | 76 | override getObjdumpOutputFilename(defaultOutputFilename: string) { |
TrMen | ed4c581 | 2022-07-09 17:03:23 +0200 | [diff] [blame] | 77 | const parsed_path = path.parse(defaultOutputFilename); |
| 78 | |
partouf | b8e4d2d | 2022-10-12 21:11:47 +0200 | [diff] [blame] | 79 | return path.join(parsed_path.dir, this.outputFilebase); |
TrMen | ed4c581 | 2022-07-09 17:03:23 +0200 | [diff] [blame] | 80 | } |
| 81 | |
Jeremy Rifkin | 6a6efae | 2023-01-29 13:22:30 -0500 | [diff] [blame] | 82 | override getExecutableFilename(dirPath: string, outputFilebase: string) { |
TrMen | ed4c581 | 2022-07-09 17:03:23 +0200 | [diff] [blame] | 83 | return path.join(dirPath, outputFilebase); |
| 84 | } |
| 85 | |
| 86 | // We have no dynamic linking in Jakt |
| 87 | override getSharedLibraryPathsAsArguments(libraries, libDownloadPath) { |
| 88 | return []; |
| 89 | } |
| 90 | |
| 91 | // We have no dynamic linking in Jakt |
Jeremy Rifkin | 6a6efae | 2023-01-29 13:22:30 -0500 | [diff] [blame] | 92 | override getSharedLibraryLinks(libraries: any[]): string[] { |
TrMen | ed4c581 | 2022-07-09 17:03:23 +0200 | [diff] [blame] | 93 | return []; |
| 94 | } |
| 95 | |
| 96 | override getOutputFilename(dirPath: string, outputFilebase: string, key?: any): string { |
partouf | b8e4d2d | 2022-10-12 21:11:47 +0200 | [diff] [blame] | 97 | return path.join(dirPath, 'Root Module.cpp'); |
TrMen | ed4c581 | 2022-07-09 17:03:23 +0200 | [diff] [blame] | 98 | } |
| 99 | } |