MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / gen_based

Function gen_based

src/gpre/languages/rmc.cpp:1042–1167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1040//
1041
1042static void gen_based( const act* action)
1043{
1044 USHORT datatype;
1045
1046 const bas* based_on = (bas*) action->act_object;
1047 const gpre_fld* field = based_on->bas_field;
1048
1049 if (based_on->bas_flags & BAS_segment)
1050 {
1051 datatype = dtype_text;
1052 SLONG length = field->fld_seg_length;
1053 if (!length)
1054 length = 256;
1055 }
1056 else if (field->fld_array_info)
1057 {
1058 CPR_error("Based on currently not implemented for arrays.");
1059 return; // silence non initialized warning
1060
1061 // TBD - messy
1062 //datatype = field->fld_array_info->ary_dtype;
1063 //for (dimension = field->fld_array_info->ary_dimension; dimension;
1064 // dimension = dimension->dim_next)
1065 //{
1066 // fprintf(gpreGlob.out_file, "<not implemented>");
1067 //}
1068 }
1069 else
1070 datatype = field->fld_dtype;
1071
1072 SSHORT digits;
1073
1074 switch (datatype)
1075 {
1076 case dtype_short:
1077 case dtype_long:
1078 case dtype_int64:
1079 digits = (datatype == dtype_short) ? 5 : 10;
1080 fprintf(gpreGlob.out_file, "%sPIC S", names[COLUMN]);
1081 if (field->fld_scale >= -digits && field->fld_scale <= 0)
1082 {
1083 if (field->fld_scale > -digits)
1084 fprintf(gpreGlob.out_file, "9(%d)", digits + field->fld_scale);
1085 if (field->fld_scale)
1086 fprintf(gpreGlob.out_file, "V9(%d)", digits - (digits + field->fld_scale));
1087 if (datatype == dtype_short)
1088 fprintf(gpreGlob.out_file, USAGE_BINARY2);
1089 else if (datatype == dtype_long)
1090 fprintf(gpreGlob.out_file, USAGE_BINARY4);
1091 else
1092 fprintf(gpreGlob.out_file, USAGE_BINARY8);
1093 }
1094 else if (field->fld_scale > 0)
1095 fprintf(gpreGlob.out_file, "9(%d)P(%d)", digits, field->fld_scale);
1096 else
1097 fprintf(gpreGlob.out_file, "VP(%d)9(%d)", -(field->fld_scale + digits), digits);
1098 break;
1099

Callers 1

RMC_actionFunction · 0.70

Calls 1

CPR_errorFunction · 0.85

Tested by

no test coverage detected