Skip to content

Commit 5cce423

Browse files
committed
fix: codegen.c
* Fix a bug about data items with EXTERNAL
1 parent ea41d1a commit 5cce423

File tree

1 file changed

+43
-36
lines changed

1 file changed

+43
-36
lines changed

cobj/codegen.c

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -853,12 +853,12 @@ static void joutput_base(struct cb_field *f) {
853853
// EDIT
854854
/* Base name */
855855
strcpy_identifier_cobol_to_java(name, top->name);
856-
if (!top->flag_external) {
856+
// if (!top->flag_external) {
857857
register_data_storage_list(f, top);
858-
}
858+
// }
859859

860860
if (!top->flag_base) {
861-
if (!top->flag_external) {
861+
// if (!top->flag_external) {
862862
if (!top->flag_local || top->flag_is_global) {
863863
bl = cobc_malloc(sizeof(struct base_list));
864864
bl->f = top;
@@ -877,17 +877,17 @@ static void joutput_base(struct cb_field *f) {
877877
joutput_local("\t/* %s */\n", top->name);
878878
}
879879
}
880-
}
880+
// }
881881
top->flag_base = 1;
882882
}
883883

884-
if (top->flag_external) {
885-
joutput("%s%s", CB_PREFIX_BASE, name);
886-
} else {
884+
// if (top->flag_external) {
885+
// joutput("%s%s", CB_PREFIX_BASE, name);
886+
// } else {
887887
if (joutput_field_storage(f, top) && f->offset != 0) {
888888
joutput(".getSubDataStorage(%d)", f->offset);
889889
}
890-
}
890+
// }
891891

892892
if (cb_field_variable_address(f)) {
893893
for (p = f->parent; p; f = f->parent, p = f->parent) {
@@ -2260,14 +2260,14 @@ static void joutput_initialize_external(cb_tree x, struct cb_field *f) {
22602260
joutput_prefix();
22612261
joutput_data(x);
22622262
if (f->ename) {
2263-
joutput(" = CobolExternal.getStorageAddress (\"%s\", %d);\n", f->ename,
2263+
joutput(" = CobolExternal.getStorageAddress (\"%s\", %d);", f->ename,
22642264
f->size);
22652265
} else if (f->storage == CB_STORAGE_FILE) {
22662266
file = CB_TREE(f->file);
2267-
joutput(" = CobolExternal.getStorageAddress (\"%s\", %d);\n",
2267+
joutput(" = CobolExternal.getStorageAddress (\"%s\", %d);",
22682268
CB_FILE(file)->record->name, f->size);
22692269
} else {
2270-
joutput(" = CobolExternal.getStorageAddress (\"%s\", %d);\n", f->name,
2270+
joutput(" = CobolExternal.getStorageAddress (\"%s\", %d);", f->name,
22712271
f->size);
22722272
}
22732273
}
@@ -2597,12 +2597,12 @@ static void joutput_initialize(struct cb_initialize *p) {
25972597
int c;
25982598

25992599
f = cb_field(p->var);
2600-
if (f->flag_external) {
2601-
joutput_initialize_external(p->var, f);
2602-
if (!p->flag_statement) {
2603-
return;
2604-
}
2605-
}
2600+
// if (f->flag_external) {
2601+
// joutput_initialize_external(p->var, f);
2602+
// if (!p->flag_statement) {
2603+
// return;
2604+
// }
2605+
// }
26062606
switch (initialize_type(p, f, 1)) {
26072607
case INITIALIZE_NONE:
26082608
break;
@@ -4240,6 +4240,10 @@ static void joutput_initial_values(struct cb_field *p) {
42404240
if (p->flag_no_init && !p->count) {
42414241
continue;
42424242
}
4243+
/* EXTERNAL items */
4244+
if (p->flag_external) {
4245+
continue;
4246+
}
42434247
int tmp_flag = integer_reference_flag;
42444248
integer_reference_flag = 1;
42454249
joutput_stmt(cb_build_initialize(x, cb_true, NULL, def, 0),
@@ -5079,6 +5083,9 @@ static void joutput_init_method(struct cb_program *prog) {
50795083
joutput_prefix();
50805084
joutput("%s = new CobolDataStorage(%d);", base_name,
50815085
blp->f->memory_size);
5086+
} else if (blp->f->flag_external) {
5087+
joutput_initialize_external(cb_build_field_reference(blp->f, NULL),
5088+
blp->f);
50825089
} else {
50835090
joutput_prefix();
50845091
joutput("%s = new CobolDataStorage(%d);", base_name,
@@ -5595,25 +5602,25 @@ static void joutput_declare_member_variables(struct cb_program *prog,
55955602
}
55965603

55975604
/* External items */
5598-
for (f = prog->working_storage; f; f = f->sister) {
5599-
if (f->flag_external) {
5600-
joutput_prefix();
5601-
joutput("private CobolDataStorage ");
5602-
joutput_base(f);
5603-
joutput(" = null; /* %s */", f->name);
5604-
joutput_newline();
5605-
}
5606-
}
5607-
for (l = prog->file_list; l; l = CB_CHAIN(l)) {
5608-
f = CB_FILE(CB_VALUE(l))->record;
5609-
if (f->flag_external) {
5610-
joutput_prefix();
5611-
joutput("private CobolDataStorage ");
5612-
joutput_base(f);
5613-
joutput(" = null; /* %s */", f->name);
5614-
joutput_newline();
5615-
}
5616-
}
5605+
// for (f = prog->working_storage; f; f = f->sister) {
5606+
// if (f->flag_external) {
5607+
// joutput_prefix();
5608+
// joutput("private CobolDataStorage ");
5609+
// joutput_base(f);
5610+
// joutput(" = null; /* %s */", f->name);
5611+
// joutput_newline();
5612+
// }
5613+
// }
5614+
// for (l = prog->file_list; l; l = CB_CHAIN(l)) {
5615+
// f = CB_FILE(CB_VALUE(l))->record;
5616+
// if (f->flag_external) {
5617+
// joutput_prefix();
5618+
// joutput("private CobolDataStorage ");
5619+
// joutput_base(f);
5620+
// joutput(" = null; /* %s */", f->name);
5621+
// joutput_newline();
5622+
// }
5623+
// }
56175624

56185625
/* AbstractCobolField型変数の宣言(非定数) */
56195626
if (field_cache) {

0 commit comments

Comments
 (0)