MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / Add

Method Add

src/simulate/runtime_string.cpp:250–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248 // string operations
249
250 vec4f SimPolicy_String::Add ( vec4f a, vec4f b, Context & context, LineInfo * at ) {
251 const char * sA = to_rts(a);
252 auto la = stringLength(context, sA);
253 const char * sB = to_rts(b);
254 auto lb = stringLength(context, sB);
255 uint32_t commonLength = la + lb;
256 if ( !commonLength ) {
257 return v_zero();
258 } else if ( char * sAB = (char * ) context.allocateString(nullptr, commonLength, at) ) {
259 memcpy ( sAB, sA, la );
260 memcpy ( sAB+la, sB, lb+1 );
261 context.stringHeap->recognize(sAB);
262 return cast<char *>::from(sAB);
263 } else {
264 context.throw_out_of_memory(true, commonLength, at);
265 return v_zero();
266 }
267 }
268
269 void SimPolicy_String::SetAdd ( char * a, vec4f b, Context & context, LineInfo * at ) {
270 char ** pA = (char **)a;

Callers

nothing calls this directly

Calls 6

to_rtsFunction · 0.85
stringLengthFunction · 0.85
allocateStringMethod · 0.80
recognizeMethod · 0.80
throw_out_of_memoryMethod · 0.80
v_zeroFunction · 0.50

Tested by

no test coverage detected