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

Function par_array

src/gpre/exp.cpp:1083–1165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1081//
1082
1083static gpre_nod* par_array(gpre_req* request, gpre_fld* field, bool subscript_flag, bool sql_flag)
1084{
1085 bool paren = false;
1086 bool bracket = false;
1087
1088 if (MSC_match(KW_LEFT_PAREN))
1089 paren = true;
1090 else if (MSC_match(KW_L_BRCKET))
1091 bracket = true;
1092 else if (!subscript_flag)
1093 CPR_s_error("Missing parenthesis or bracket for array reference.");
1094
1095 gpre_nod* array_node =
1096 MSC_node(nod_array, (SSHORT) (field->fld_array_info->ary_dimension_count + 1));
1097
1098 if (sql_flag && ((paren && MSC_match(KW_RIGHT_PAREN)) || (bracket && MSC_match(KW_R_BRCKET))))
1099 {
1100 return array_node;
1101 }
1102
1103 int fortran_adjustment = array_node->nod_count;
1104 if (paren || bracket)
1105 {
1106 if (!global_subscript_field)
1107 global_subscript_field = MET_make_field("gds_array_subscript", dtype_long, 4, false);
1108
1109 // Parse a commalist of subscripts and build a tree of index nodes
1110
1111 int i = 1;
1112 for (dim* dimension = field->fld_array_info->ary_dimension;
1113 dimension; dimension = dimension->dim_next, i++)
1114 {
1115 gpre_nod* node;
1116 if (!sql_flag)
1117 node = par_value(request, global_subscript_field);
1118 else
1119 {
1120 node = SQE_value(request, false, NULL, NULL);
1121 // For all values referenced, post the subscript field
1122 SQE_post_field(node, global_subscript_field);
1123 }
1124
1125 gpre_nod* index_node = MSC_unary(nod_index, node);
1126
1127 // Languages which can't handle negative or non-positive bounds need to
1128 // be accomodated with normalization of the indices.
1129
1130 switch (gpreGlob.sw_language)
1131 {
1132 case lang_c:
1133 case lang_cxx:
1134 case lang_internal:
1135 index_node->nod_arg[0] = normalize_index(dimension, index_node->nod_arg[0], ZERO_BASED);
1136 break;
1137
1138 case lang_cobol:
1139 index_node->nod_arg[0] = normalize_index(dimension, index_node->nod_arg[0], ONE_BASED);
1140 break;

Callers 2

EXP_arrayFunction · 0.70
par_fieldFunction · 0.70

Calls 9

MSC_matchFunction · 0.85
CPR_s_errorFunction · 0.85
MSC_nodeFunction · 0.85
MET_make_fieldFunction · 0.85
par_valueFunction · 0.85
SQE_valueFunction · 0.85
SQE_post_fieldFunction · 0.85
MSC_unaryFunction · 0.85
normalize_indexFunction · 0.85

Tested by

no test coverage detected