mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 07:04:04 -05:00
Add basic COBOL support
This commit is contained in:
3
.github/labeler.yml
vendored
3
.github/labeler.yml
vendored
@@ -40,6 +40,9 @@ lang-clean:
|
||||
- lib/compilers/clean.js
|
||||
- etc/config/clean.*.properties
|
||||
- static/modes/clean-mode.ts
|
||||
lang-cobol:
|
||||
- lib/compilers/cobol.js
|
||||
- etc/config/cobol.*.properties
|
||||
lang-cppx:
|
||||
- etc/config/cppx?(_blue|_gold).*.properties
|
||||
- static/modes/cppx-blue-mode.ts
|
||||
|
||||
10
etc/config/cobol.amazon.properties
Normal file
10
etc/config/cobol.amazon.properties
Normal file
@@ -0,0 +1,10 @@
|
||||
compilers=&cobol
|
||||
defaultCompiler=cobol
|
||||
|
||||
group.cobol.groupName=COBOL
|
||||
group.cobol.compilers=cobol
|
||||
group.cobol.isSemVer=true
|
||||
group.cobol.baseName=COBOL
|
||||
group.cobol.licenseName=GPLv3
|
||||
group.cobol.licenseLink=https://sourceforge.net/p/gnucobol/code/HEAD/tree/trunk/COPYING
|
||||
compiler.cobol.exe=/opt/compiler-explorer/gnucobol/bin/cobc
|
||||
14
etc/config/cobol.defaults.properties
Normal file
14
etc/config/cobol.defaults.properties
Normal file
@@ -0,0 +1,14 @@
|
||||
# Default settings for COBOL
|
||||
compilers=cobol
|
||||
compilerType=cobol
|
||||
|
||||
versionFlag=--version
|
||||
|
||||
objdumper=objdump
|
||||
supportsBinary=true
|
||||
supportsBinaryObject=true
|
||||
binaryHideFuncRe=^(__.*|_(init|start|fini)|(de)?register_tm_clones|call_gmon_start|frame_dummy|\.plt.*|_dl_relocate_static_pie)$
|
||||
supportsLibraryCodeFilter=true
|
||||
|
||||
compiler.cobol.name=GNU COBOL
|
||||
compiler.cobol.exe=/usr/local/bin/cobc
|
||||
15
examples/cobol/Max_array.cob
Normal file
15
examples/cobol/Max_array.cob
Normal file
@@ -0,0 +1,15 @@
|
||||
identification division.
|
||||
program-id. Max_array.
|
||||
data division.
|
||||
working-storage section.
|
||||
01 ws-array-1 pic s9(8) occurs 65535 times.
|
||||
01 ws-array-2 pic s9(8) occurs 65535 times.
|
||||
01 i pic s9(8) comp.
|
||||
procedure division.
|
||||
move 0 to i.
|
||||
perform varying i from 1 by 1 until i > 65535
|
||||
if ws-array-1(i) > ws-array-2(i)
|
||||
move ws-array-1(i) to ws-array-2(i)
|
||||
end-if
|
||||
end-perform.
|
||||
stop run.
|
||||
5
examples/cobol/default.cob
Normal file
5
examples/cobol/default.cob
Normal file
@@ -0,0 +1,5 @@
|
||||
identification division.
|
||||
program-id. hello.
|
||||
procedure division.
|
||||
display "Hello World!".
|
||||
stop run.
|
||||
@@ -38,6 +38,7 @@ export {ClangCudaCompiler} from './clang.js';
|
||||
export {ClangHipCompiler} from './clang.js';
|
||||
export {ClangIntelCompiler} from './clang.js';
|
||||
export {CleanCompiler} from './clean.js';
|
||||
export {CobolCompiler} from './cobol.js';
|
||||
export {CppFrontCompiler} from './cppfront.js';
|
||||
export {CprocCompiler} from './cproc.js';
|
||||
export {CLSPVCompiler} from './clspv.js';
|
||||
|
||||
86
lib/compilers/cobol.ts
Normal file
86
lib/compilers/cobol.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
// Copyright (c) 2023, Compiler Explorer Authors
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import _ from 'underscore';
|
||||
|
||||
import path from 'path';
|
||||
|
||||
import type {CompilationResult, ExecutionOptions} from '../../types/compilation/compilation.interfaces.js';
|
||||
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
|
||||
import {BaseCompiler} from '../base-compiler.js';
|
||||
import * as utils from '../utils.js';
|
||||
|
||||
export class CobolCompiler extends BaseCompiler {
|
||||
static get key() {
|
||||
return 'cobol';
|
||||
}
|
||||
|
||||
override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string) {
|
||||
let options = ['-o', this.filename(outputFilename)];
|
||||
if (!filters.binary) options = options.concat('-S');
|
||||
else options = options.concat('-x');
|
||||
return options;
|
||||
}
|
||||
|
||||
override getCompilerResultLanguageId() {
|
||||
return 'asm';
|
||||
}
|
||||
|
||||
override async objdump(
|
||||
outputFilename,
|
||||
result: any,
|
||||
maxSize: number,
|
||||
intelAsm,
|
||||
demangle,
|
||||
staticReloc: boolean,
|
||||
dynamicReloc: boolean,
|
||||
filters: ParseFiltersAndOutputOptions,
|
||||
) {
|
||||
const objdumpResult = await super.objdump(
|
||||
outputFilename,
|
||||
result,
|
||||
maxSize,
|
||||
intelAsm,
|
||||
demangle,
|
||||
staticReloc,
|
||||
dynamicReloc,
|
||||
filters,
|
||||
);
|
||||
|
||||
objdumpResult.languageId = 'asm';
|
||||
return objdumpResult;
|
||||
}
|
||||
|
||||
override getExecutableFilename(dirPath: string, outputFilebase: string) {
|
||||
return path.join(dirPath, outputFilebase);
|
||||
}
|
||||
|
||||
override getSharedLibraryPathsAsArguments(libraries, libDownloadPath) {
|
||||
return [];
|
||||
}
|
||||
|
||||
override getSharedLibraryLinks(libraries: any[]): string[] {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -165,6 +165,17 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
|
||||
previewFilter: null,
|
||||
monacoDisassembly: null,
|
||||
},
|
||||
cobol: {
|
||||
name: 'COBOL',
|
||||
monaco: 'cobol',
|
||||
extensions: ['.cob', '.cbl', '.cobol'],
|
||||
alias: [],
|
||||
logoUrl: null, // TODO: Find a better alternative
|
||||
formatter: null,
|
||||
logoUrlDark: null,
|
||||
previewFilter: null,
|
||||
monacoDisassembly: null,
|
||||
},
|
||||
cpp_for_opencl: {
|
||||
name: 'C++ for OpenCL',
|
||||
monaco: 'cpp-for-opencl',
|
||||
|
||||
@@ -33,6 +33,7 @@ export type LanguageKey =
|
||||
| 'circt'
|
||||
| 'clean'
|
||||
| 'cmake'
|
||||
| 'cobol'
|
||||
| 'cpp_for_opencl'
|
||||
| 'cppx'
|
||||
| 'cppx_blue'
|
||||
|
||||
Reference in New Issue
Block a user