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

Method emitCodeStream

Engine/source/console/compiler.cpp:507–535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

505//-------------------------------------------------------------------------
506
507void CodeStream::emitCodeStream(U32 *size, U32 **stream, U32 **lineBreaks)
508{
509 // Alloc stream
510 U32 numLineBreaks = getNumLineBreaks();
511 *stream = new U32[mCodePos + (numLineBreaks * 2)];
512 dMemset(*stream, '\0', mCodePos + (numLineBreaks * 2));
513 *size = mCodePos;
514
515 // Dump chunks & line breaks
516 U32 outBytes = mCodePos * sizeof(U32);
517 U8 *outPtr = *((U8**)stream);
518 for (CodeData *itr = mCode; itr != NULL; itr = itr->next)
519 {
520 U32 bytesToCopy = itr->size > outBytes ? outBytes : itr->size;
521 dMemcpy(outPtr, itr->data, bytesToCopy);
522 outPtr += bytesToCopy;
523 outBytes -= bytesToCopy;
524 }
525
526 *lineBreaks = *stream + mCodePos;
527 dMemcpy(*lineBreaks, mBreakLines.address(), sizeof(U32) * mBreakLines.size());
528
529 // Apply patches on top
530 for (U32 i = 0; i<mPatchList.size(); i++)
531 {
532 PatchEntry &e = mPatchList[i];
533 (*stream)[e.addr] = e.value;
534 }
535}
536
537//-------------------------------------------------------------------------
538

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