@@ -825,14 +825,34 @@ static int is_call_parameter(const struct cb_field *f) {
825825 return 0 ;
826826}
827827
828+ static int is_dangling_linkage (const struct cb_field * f ) {
829+ struct cb_field * lf ;
830+ cb_tree p ;
831+ for (lf = current_prog -> linkage_storage ; lf ; lf = lf -> sister ) {
832+ if (f == lf ) {
833+ for (p = current_prog -> parameter_list ; p ; p = CB_CHAIN (p )) {
834+ if (f == cb_field (CB_VALUE (p ))) {
835+ return 0 ;
836+ }
837+ }
838+ return 1 ;
839+ }
840+ }
841+ return 0 ;
842+ }
843+
844+ static int is_runtime_resolved_parent (const struct cb_field * f ) {
845+ return is_call_parameter (f ) || is_dangling_linkage (f );
846+ }
847+
828848static int joutput_field_storage (struct cb_field * f , struct cb_field * top ) {
829- int flag_call_parameter = is_call_parameter (top );
830- if (flag_call_parameter ||
849+ int flag_runtime_resolved = is_runtime_resolved_parent (top );
850+ if (flag_runtime_resolved ||
831851 (f -> offset == 0 && strcmp (f -> name , top -> name ) == 0 )) {
832852 char * base_name = get_java_identifier_base (top );
833853 joutput (base_name );
834854 free (base_name );
835- return flag_call_parameter ;
855+ return flag_runtime_resolved ;
836856 } else {
837857 char * base_name = get_java_identifier_base (f );
838858 joutput (base_name );
@@ -2849,12 +2869,14 @@ static void joutput_call(struct cb_call *p) {
28492869 joutput_line ("CobolDataStorage content_%d = new CobolDataStorage(8);" ,
28502870 (int )n );
28512871 } else if (CB_CAST_P (x )) {
2852- joutput_line ("void *ptr_%d;" , (int )n );
2872+ joutput_line ("CobolDataStorage ptr_%d = new CobolDataStorage(8);" ,
2873+ (int )n );
28532874 }
28542875 break ;
28552876 case CB_CALL_BY_CONTENT :
28562877 if (CB_CAST_P (x )) {
2857- joutput_line ("void *ptr_%d;" , (int )n );
2878+ joutput_line ("CobolDataStorage ptr_%d = new CobolDataStorage(8);" ,
2879+ (int )n );
28582880 } else if (CB_TREE_TAG (x ) != CB_TAG_INTRINSIC && x != cb_null &&
28592881 !(CB_CAST_P (x ))) {
28602882 joutput_prefix ();
@@ -2890,17 +2912,17 @@ static void joutput_call(struct cb_call *p) {
28902912 joutput ("L);\n" );
28912913 } else if (CB_CAST_P (x )) {
28922914 joutput_prefix ();
2893- joutput ("ptr_%d = " , (int )n );
2915+ joutput ("ptr_%d.set( " , (int )n );
28942916 joutput_integer (x );
2895- joutput (";\n" );
2917+ joutput (") ;\n" );
28962918 }
28972919 break ;
28982920 case CB_CALL_BY_CONTENT :
28992921 if (CB_CAST_P (x )) {
29002922 joutput_prefix ();
2901- joutput ("ptr_%d = " , (int )n );
2923+ joutput ("ptr_%d.set( " , (int )n );
29022924 joutput_integer (x );
2903- joutput (";\n" );
2925+ joutput (") ;\n" );
29042926 } else if (CB_TREE_TAG (x ) != CB_TAG_INTRINSIC ) {
29052927 if (CB_NUMERIC_LITERAL_P (x )) {
29062928 joutput_prefix ();
@@ -2952,6 +2974,9 @@ static void joutput_call(struct cb_call *p) {
29522974 break ;
29532975 }
29542976 break ;
2977+ case CB_TAG_CAST :
2978+ joutput ("(AbstractCobolField) null" );
2979+ break ;
29552980 default :
29562981 joutput ("null" );
29572982 break ;
@@ -3061,7 +3086,7 @@ static void joutput_call(struct cb_call *p) {
30613086 } else if (CB_REFERENCE_P (x ) && CB_FILE_P (cb_ref (x ))) {
30623087 joutput_param (cb_ref (x ), -1 );
30633088 } else if (CB_CAST_P (x )) {
3064- joutput ("& ptr_%d" , (int )n );
3089+ joutput ("ptr_%d" , (int )n );
30653090 } else {
30663091 int tmp_param_wrap_string_flag = param_wrap_string_flag ;
30673092 param_wrap_string_flag = 1 ;
@@ -3072,7 +3097,7 @@ static void joutput_call(struct cb_call *p) {
30723097 case CB_CALL_BY_CONTENT :
30733098 if (CB_TREE_TAG (x ) != CB_TAG_INTRINSIC && x != cb_null ) {
30743099 if (CB_CAST_P (x )) {
3075- joutput ("& ptr_%d" , (int )n );
3100+ joutput ("ptr_%d" , (int )n );
30763101 } else {
30773102 joutput ("content_%d" , (int )n );
30783103 }
@@ -5349,7 +5374,7 @@ static void joutput_init_method(struct cb_program *prog) {
53495374 int i ;
53505375 for (i = 0 ; i < data_storage_cache_count ; ++ i ) {
53515376 struct data_storage_list * entry = sorted_data_storage_cache [i ];
5352- if (is_call_parameter (entry -> top ) && entry -> f != entry -> top ) {
5377+ if (is_runtime_resolved_parent (entry -> top ) && entry -> f != entry -> top ) {
53535378 continue ;
53545379 }
53555380 joutput_prefix ();
@@ -5834,7 +5859,7 @@ static void joutput_declare_member_variables(struct cb_program *prog,
58345859
58355860 for (i = 0 ; i < data_storage_cache_count ; ++ i ) {
58365861 struct data_storage_list * entry = sorted_data_storage_cache [i ];
5837- if (is_call_parameter (entry -> top ) && entry -> f != entry -> top ) {
5862+ if (is_runtime_resolved_parent (entry -> top ) && entry -> f != entry -> top ) {
58385863 continue ;
58395864 }
58405865 joutput_prefix ();
0 commit comments