Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions cobj/typeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -3099,13 +3099,48 @@ void cb_emit_call(cb_tree prog, cb_tree cb_using, cb_tree returning,
const struct system_table *psyst;
for (psyst = (const struct system_table *)&system_tab[0]; psyst->syst_name;
psyst++) {
if (!strcmp((const char *)CB_LITERAL(prog)->data,
(const char *)psyst->syst_name)) {
const char *data = (const char *)CB_LITERAL(prog)->data;
if (!strcmp(data, (const char *)psyst->syst_name)) {
// error if the subroutine is not implemented
switch (psyst - &system_tab[0]) {
case 2: // CBL_CHANGE_DIR
case 3: // CBL_CHECK_FILE_EXIST
case 4: // CBL_CLOSE_FILE
case 5: // CBL_COPY_FILE
case 6: // CBL_CREATE_DIR
case 7: // CBL_CREATE_FILE
case 8: // CBL_DELETE_DIR
case 9: // CBL_DELETE_FILE
case 11: // CBL_ERROR_PROC
case 12: // CBL_EXIT_PROC
case 13: // CBL_FLUSH_FILE
case 14: // CBL_GET_CURRENT_DIR
case 15: // CBL_IMP
case 20: // CBL_OPEN_FILE
case 22: // CBL_READ_FILE
case 23: // CBL_RENAME_FILE
case 26: // CBL_WRITE_FILE
case 28: // CBL_OC_KEISEN
case 29: // CBL_OC_ATTRIBUTE
case 30: // C$CHDIR
case 31: // C$COPY
case 32: // C$DELETE
case 33: // C$FILEINFO
case 35: // C$GETPID
case 36: // C$JUSTIFY
case 38: // C$MAKEDIR
case 39: // C$NARG
case 40: // C$SLEEP
case 41: // C$PARAMSIZE
Copy link

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The switch-case relies on hardcoded index values to identify unimplemented subroutines, which could be error-prone if the 'system_tab' ordering changes. Consider using named constants or an enumeration for these indices to improve code clarity and maintainability.

Suggested change
case 2: // CBL_CHANGE_DIR
case 3: // CBL_CHECK_FILE_EXIST
case 4: // CBL_CLOSE_FILE
case 5: // CBL_COPY_FILE
case 6: // CBL_CREATE_DIR
case 7: // CBL_CREATE_FILE
case 8: // CBL_DELETE_DIR
case 9: // CBL_DELETE_FILE
case 11: // CBL_ERROR_PROC
case 12: // CBL_EXIT_PROC
case 13: // CBL_FLUSH_FILE
case 14: // CBL_GET_CURRENT_DIR
case 15: // CBL_IMP
case 20: // CBL_OPEN_FILE
case 22: // CBL_READ_FILE
case 23: // CBL_RENAME_FILE
case 26: // CBL_WRITE_FILE
case 28: // CBL_OC_KEISEN
case 29: // CBL_OC_ATTRIBUTE
case 30: // C$CHDIR
case 31: // C$COPY
case 32: // C$DELETE
case 33: // C$FILEINFO
case 35: // C$GETPID
case 36: // C$JUSTIFY
case 38: // C$MAKEDIR
case 39: // C$NARG
case 40: // C$SLEEP
case 41: // C$PARAMSIZE
case CBL_CHANGE_DIR: // CBL_CHANGE_DIR
case CBL_CHECK_FILE_EXIST: // CBL_CHECK_FILE_EXIST
case CBL_CLOSE_FILE: // CBL_CLOSE_FILE
case CBL_COPY_FILE: // CBL_COPY_FILE
case CBL_CREATE_DIR: // CBL_CREATE_DIR
case CBL_CREATE_FILE: // CBL_CREATE_FILE
case CBL_DELETE_DIR: // CBL_DELETE_DIR
case CBL_DELETE_FILE: // CBL_DELETE_FILE
case CBL_ERROR_PROC: // CBL_ERROR_PROC
case CBL_EXIT_PROC: // CBL_EXIT_PROC
case CBL_FLUSH_FILE: // CBL_FLUSH_FILE
case CBL_GET_CURRENT_DIR: // CBL_GET_CURRENT_DIR
case CBL_IMP: // CBL_IMP
case CBL_OPEN_FILE: // CBL_OPEN_FILE
case CBL_READ_FILE: // CBL_READ_FILE
case CBL_RENAME_FILE: // CBL_RENAME_FILE
case CBL_WRITE_FILE: // CBL_WRITE_FILE
case CBL_OC_KEISEN: // CBL_OC_KEISEN
case CBL_OC_ATTRIBUTE: // CBL_OC_ATTRIBUTE
case C$CHDIR: // C$CHDIR
case C$COPY: // C$COPY
case C$DELETE: // C$DELETE
case C$FILEINFO: // C$FILEINFO
case C$GETPID: // C$GETPID
case C$JUSTIFY: // C$JUSTIFY
case C$MAKEDIR: // C$MAKEDIR
case C$NARG: // C$NARG
case C$SLEEP: // C$SLEEP
case C$PARAMSIZE: // C$PARAMSIZE

Copilot uses AI. Check for mistakes.
cb_error(_("%s not implemented"), data);
return;
}
if (psyst->syst_params > cb_list_length(cb_using)) {
cb_error(_("Wrong number of CALL parameters for '%s'"),
(char *)psyst->syst_name);
return;
}

is_sys_call = 1;
break;
}
Expand Down
Loading