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

Method add2

src/dsql/ExprNodes.cpp:2139–2254  ·  view source on GitHub ↗

Add (or subtract) the contents of a descriptor to value block, with dialect-3 semantics, as in the blr_add, blr_subtract, and blr_agg_total verbs following a blr_version5.

Source from the content-addressed store, hash-verified

2137// Add (or subtract) the contents of a descriptor to value block, with dialect-3 semantics, as in
2138// the blr_add, blr_subtract, and blr_agg_total verbs following a blr_version5.
2139dsc* ArithmeticNode::add2(thread_db* tdbb, const dsc* desc, impure_value* value, const ValueExprNode* node,
2140 const UCHAR blrOp)
2141{
2142 const ArithmeticNode* arithmeticNode = nodeAs<ArithmeticNode>(node);
2143
2144 fb_assert(
2145 (arithmeticNode && !arithmeticNode->dialect1 &&
2146 (arithmeticNode->blrOp == blr_add || arithmeticNode->blrOp == blr_subtract)) ||
2147 nodeIs<AggNode>(node));
2148
2149 dsc* result = &value->vlu_desc;
2150
2151 // Handle date arithmetic
2152
2153 if (node->nodFlags & FLAG_DATE)
2154 {
2155 fb_assert(arithmeticNode);
2156 return arithmeticNode->addDateTime(tdbb, desc, value);
2157 }
2158
2159 // Handle decimal arithmetic
2160
2161 if (node->nodFlags & FLAG_DECFLOAT)
2162 {
2163 const Decimal128 d1 = MOV_get_dec128(tdbb, desc);
2164 const Decimal128 d2 = MOV_get_dec128(tdbb, &value->vlu_desc);
2165
2166 DecimalStatus decSt = tdbb->getAttachment()->att_dec_status;
2167 value->vlu_misc.vlu_dec128 = (blrOp == blr_subtract) ? d2.sub(decSt, d1) : d1.add(decSt, d2);
2168
2169 result->dsc_dtype = dtype_dec128;
2170 result->dsc_length = sizeof(Decimal128);
2171 result->dsc_scale = 0;
2172 result->dsc_sub_type = 0;
2173 result->dsc_address = (UCHAR*) &value->vlu_misc.vlu_dec128;
2174
2175 return result;
2176 }
2177
2178 // 128-bit arithmetic
2179
2180 if (node->nodFlags & FLAG_INT128)
2181 {
2182 const Int128 d1 = MOV_get_int128(tdbb, desc, node->nodScale);
2183 const Int128 d2 = MOV_get_int128(tdbb, &value->vlu_desc, node->nodScale);
2184
2185 value->vlu_misc.vlu_int128 = (blrOp == blr_subtract) ? d2.sub(d1) : d1.add(d2);
2186
2187 result->dsc_dtype = dtype_int128;
2188 result->dsc_length = sizeof(Int128);
2189 result->dsc_scale = node->nodScale;
2190 setFixedSubType(result, *desc, value->vlu_desc);
2191 result->dsc_address = (UCHAR*) &value->vlu_misc.vlu_int128;
2192
2193 return result;
2194 }
2195
2196 // Handle floating arithmetic

Callers

nothing calls this directly

Calls 12

MOV_get_dec128Function · 0.85
MOV_get_int128Function · 0.85
setFixedSubTypeFunction · 0.85
MOV_get_doubleFunction · 0.85
isinfFunction · 0.85
GdsClass · 0.85
MOV_get_int64Function · 0.85
addDateTimeMethod · 0.80
ERR_postFunction · 0.50
getAttachmentMethod · 0.45
subMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected