MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / emitCodeStream

Method emitCodeStream

Engine/source/console/compiler.cpp:357–385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355//-------------------------------------------------------------------------
356
357void CodeStream::emitCodeStream(U32 *size, U32 **stream, U32 **lineBreaks)
358{
359 // Alloc stream
360 U32 numLineBreaks = getNumLineBreaks();
361 *stream = new U32[mCodePos + (numLineBreaks * 2)];
362 dMemset(*stream, '\0', mCodePos + (numLineBreaks * 2));
363 *size = mCodePos;
364
365 // Dump chunks & line breaks
366 U32 outBytes = mCodePos * sizeof(U32);
367 U8 *outPtr = *((U8**)stream);
368 for (CodeData *itr = mCode; itr != NULL; itr = itr->next)
369 {
370 U32 bytesToCopy = itr->size > outBytes ? outBytes : itr->size;
371 dMemcpy(outPtr, itr->data, bytesToCopy);
372 outPtr += bytesToCopy;
373 outBytes -= bytesToCopy;
374 }
375
376 *lineBreaks = *stream + mCodePos;
377 dMemcpy(*lineBreaks, mBreakLines.address(), sizeof(U32) * mBreakLines.size());
378
379 // Apply patches on top
380 for (U32 i=0; i<mPatchList.size(); i++)
381 {
382 PatchEntry &e = mPatchList[i];
383 (*stream)[e.addr] = e.value;
384 }
385}
386
387//-------------------------------------------------------------------------
388

Callers 2

compileMethod · 0.80
compileExecMethod · 0.80

Calls 4

dMemsetFunction · 0.50
dMemcpyFunction · 0.50
addressMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected