Skip to content

Commit dd31671

Browse files
authored
Add error message if unimplemented subroutines are used (#628)
1 parent c6e6064 commit dd31671

File tree

2 files changed

+87
-2
lines changed

2 files changed

+87
-2
lines changed

cobj/tree.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,56 @@ enum cb_usage {
222222

223223
enum cb_operand_type { CB_SENDING_OPERAND, CB_RECEIVING_OPERAND };
224224

225+
enum cb_system_routine {
226+
SYSTEM,
227+
CBL_AND,
228+
CBL_CHANGE_DIR,
229+
CBL_CHECK_FILE_EXIST,
230+
CBL_CLOSE_FILE,
231+
CBL_COPY_FILE,
232+
CBL_CREATE_DIR,
233+
CBL_CREATE_FILE,
234+
CBL_DELETE_DIR,
235+
CBL_DELETE_FILE,
236+
CBL_EQ,
237+
CBL_ERROR_PROC,
238+
CBL_EXIT_PROC,
239+
CBL_FLUSH_FILE,
240+
CBL_GET_CURRENT_DIR,
241+
CBL_IMP,
242+
CBL_NIMP,
243+
CBL_NOR,
244+
CBL_NOT,
245+
CBL_OC_NANOSLEEP,
246+
CBL_OPEN_FILE,
247+
CBL_OR,
248+
CBL_READ_FILE,
249+
CBL_RENAME_FILE,
250+
CBL_TOLOWER,
251+
CBL_TOUPPER,
252+
CBL_WRITE_FILE,
253+
CBL_XOR,
254+
CBL_OC_KEISEN,
255+
CBL_OC_ATTRIBUTE,
256+
C$CHDIR,
257+
C$COPY,
258+
C$DELETE,
259+
C$FILEINFO,
260+
C$LIST_DIRECTORY,
261+
C$GETPID,
262+
C$JUSTIFY,
263+
C$CALLEDBY,
264+
C$MAKEDIR,
265+
C$NARG,
266+
C$SLEEP,
267+
C$PARAMSIZE,
268+
C$TOUPPER,
269+
C$TOLOWER,
270+
CBL_X91,
271+
CBL_XF4,
272+
CBL_XF5
273+
};
274+
225275
/*
226276
* Tree
227277
*/

cobj/typeck.c

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3099,13 +3099,48 @@ void cb_emit_call(cb_tree prog, cb_tree cb_using, cb_tree returning,
30993099
const struct system_table *psyst;
31003100
for (psyst = (const struct system_table *)&system_tab[0]; psyst->syst_name;
31013101
psyst++) {
3102-
if (!strcmp((const char *)CB_LITERAL(prog)->data,
3103-
(const char *)psyst->syst_name)) {
3102+
const char *data = (const char *)CB_LITERAL(prog)->data;
3103+
if (!strcmp(data, (const char *)psyst->syst_name)) {
3104+
// error if the subroutine is not implemented
3105+
switch (psyst - &system_tab[0]) {
3106+
case CBL_CHANGE_DIR:
3107+
case CBL_CHECK_FILE_EXIST:
3108+
case CBL_CLOSE_FILE:
3109+
case CBL_COPY_FILE:
3110+
case CBL_CREATE_DIR:
3111+
case CBL_CREATE_FILE:
3112+
case CBL_DELETE_DIR:
3113+
case CBL_DELETE_FILE:
3114+
case CBL_ERROR_PROC:
3115+
case CBL_EXIT_PROC:
3116+
case CBL_FLUSH_FILE:
3117+
case CBL_GET_CURRENT_DIR:
3118+
case CBL_IMP:
3119+
case CBL_OPEN_FILE:
3120+
case CBL_READ_FILE:
3121+
case CBL_RENAME_FILE:
3122+
case CBL_WRITE_FILE:
3123+
case CBL_OC_KEISEN:
3124+
case CBL_OC_ATTRIBUTE:
3125+
case C$CHDIR:
3126+
case C$COPY:
3127+
case C$DELETE:
3128+
case C$FILEINFO:
3129+
case C$GETPID:
3130+
case C$JUSTIFY:
3131+
case C$MAKEDIR:
3132+
case C$NARG:
3133+
case C$SLEEP:
3134+
case C$PARAMSIZE:
3135+
cb_error(_("%s not implemented"), data);
3136+
return;
3137+
}
31043138
if (psyst->syst_params > cb_list_length(cb_using)) {
31053139
cb_error(_("Wrong number of CALL parameters for '%s'"),
31063140
(char *)psyst->syst_name);
31073141
return;
31083142
}
3143+
31093144
is_sys_call = 1;
31103145
break;
31113146
}

0 commit comments

Comments
 (0)