Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 2, 2025

This PR implements 15 previously missing intrinsic functions in opensource COBOL 4J, significantly expanding the runtime library's COBOL compatibility. The implementation adds support for validation functions, data conversion functions, and comparison utilities that are essential for complete COBOL standard compliance.

Functions Implemented

Validation Functions

  • TEST-NUMVAL - Tests whether a string contains valid numeric data
  • TEST-NUMVAL-C - Tests numeric validity with currency symbol support
  • TEST-NUMVAL-F - Tests floating-point numeric format validity
  • TEST-DATE-YYYYMMDD - Validates date format (was already implemented)
  • TEST-DAY-YYYYDDD - Validates day format (was already implemented)

Data Conversion Functions

  • NUMVAL-F - Converts floating-point format strings to numeric values
  • BOOLEAN-OF-INTEGER - Converts integer values to boolean representation
  • INTEGER-OF-BOOLEAN - Converts boolean fields to integer values
  • CHAR-NATIONAL - Returns national characters for ordinal positions
  • DISPLAY-OF - Converts national/Unicode data to display format
  • NATIONAL-OF - Converts display data to national character format

Comparison Functions

  • LOCALE-COMPARE - Performs locale-aware string comparison
  • STANDARD-COMPARE - Performs standard ASCII-based string comparison

Field Limit Functions

  • HIGHEST-ALGEBRAIC - Returns the maximum representable value for a field type
  • LOWEST-ALGEBRAIC - Returns the minimum representable value for a field type

Exception Handling Functions

  • EXCEPTION-FILE-N - Returns exception file information in national format
  • EXCEPTION-LOCATION-N - Returns exception location in national format

Technical Details

All implementations follow the established patterns in the codebase:

  • Proper field attribute handling using CobolFieldAttribute
  • Correct memory management with makeFieldEntry() and currField
  • Appropriate error handling and edge case validation
  • Type-safe conversions using existing utility methods

The function table in cobj/reserved.c has been updated to mark these functions as implemented with their corresponding Java method names.

Testing

The code compiles successfully and integrates with the existing runtime without breaking changes. All new functions handle error conditions gracefully and return appropriate default values when invalid input is encountered.

Note: The constants PI and E are handled as compile-time constants by the compiler rather than runtime functions, so they remain marked with NULL routines as intended.

Fixes #634.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: yutaro-sakamoto <80912876+yutaro-sakamoto@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Support all intrinsic functions Implement 15 missing intrinsic functions to complete COBOL function support Sep 2, 2025
@Copilot Copilot AI requested a review from yutaro-sakamoto September 2, 2025 06:23
Copilot finished work on behalf of yutaro-sakamoto September 2, 2025 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support all intrinsic functions

2 participants