blob: d480dea88e04c7a760c2313f0891970849c2bcd6 [file] [log] [blame] [raw]
TrMened4c5812022-07-09 17:03:23 +02001// 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
25import path from 'path';
26
27import {ExecutionOptions} from '../../types/compilation/compilation.interfaces';
Jeremy Rifkin6a6efae2023-01-29 13:22:30 -050028import {CompilerInfo} from '../../types/compiler.interfaces';
Marc Poulhiès2fa2bbb2022-11-28 21:37:15 +010029import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces';
TrMened4c5812022-07-09 17:03:23 +020030import {BaseCompiler} from '../base-compiler';
TrMened4c5812022-07-09 17:03:23 +020031
32export class JaktCompiler extends BaseCompiler {
33 static get key() {
34 return 'jakt';
35 }
36
Jeremy Rifkin6a6efae2023-01-29 13:22:30 -050037 constructor(info: CompilerInfo, env) {
TrMened4c5812022-07-09 17:03:23 +020038 super(info, env);
39
TrMened4c5812022-07-09 17:03:23 +020040 this.outputFilebase = 'example';
41 }
42
Romaric Jodin72a19da2022-10-10 13:02:50 +020043 override getCompilerResultLanguageId() {
44 return 'cppp';
partoufb8e4d2d2022-10-12 21:11:47 +020045 }
46
Marc Poulhiès2fa2bbb2022-11-28 21:37:15 +010047 override async objdump(
48 outputFilename,
49 result: any,
50 maxSize: number,
51 intelAsm,
52 demangle,
Jeremy Rifkin6a6efae2023-01-29 13:22:30 -050053 staticReloc: boolean,
54 dynamicReloc: boolean,
Marc Poulhiès2fa2bbb2022-11-28 21:37:15 +010055 filters: ParseFiltersAndOutputOptions,
56 ) {
Marc Poulhiès69055682023-01-11 19:39:25 +010057 const objdumpResult = await super.objdump(
58 outputFilename,
59 result,
60 maxSize,
61 intelAsm,
62 demangle,
63 staticReloc,
64 dynamicReloc,
65 filters,
66 );
67
partoufb8e4d2d2022-10-12 21:11:47 +020068 objdumpResult.languageId = 'asm';
69 return objdumpResult;
Romaric Jodin72a19da2022-10-10 13:02:50 +020070 }
71
Marc Poulhiès2fa2bbb2022-11-28 21:37:15 +010072 override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: any) {
TrMened4c5812022-07-09 17:03:23 +020073 return ['--binary-dir', path.dirname(outputFilename)];
74 }
75
Jeremy Rifkin6a6efae2023-01-29 13:22:30 -050076 override getObjdumpOutputFilename(defaultOutputFilename: string) {
TrMened4c5812022-07-09 17:03:23 +020077 const parsed_path = path.parse(defaultOutputFilename);
78
partoufb8e4d2d2022-10-12 21:11:47 +020079 return path.join(parsed_path.dir, this.outputFilebase);
TrMened4c5812022-07-09 17:03:23 +020080 }
81
Jeremy Rifkin6a6efae2023-01-29 13:22:30 -050082 override getExecutableFilename(dirPath: string, outputFilebase: string) {
TrMened4c5812022-07-09 17:03:23 +020083 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 Rifkin6a6efae2023-01-29 13:22:30 -050092 override getSharedLibraryLinks(libraries: any[]): string[] {
TrMened4c5812022-07-09 17:03:23 +020093 return [];
94 }
95
96 override getOutputFilename(dirPath: string, outputFilebase: string, key?: any): string {
partoufb8e4d2d2022-10-12 21:11:47 +020097 return path.join(dirPath, 'Root Module.cpp');
TrMened4c5812022-07-09 17:03:23 +020098 }
99}