本文整理汇总了C++中RefClassWriter::GetCeeGen方法的典型用法代码示例。如果您正苦于以下问题:C++ RefClassWriter::GetCeeGen方法的具体用法?C++ RefClassWriter::GetCeeGen怎么用?C++ RefClassWriter::GetCeeGen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RefClassWriter
的用法示例。
在下文中一共展示了RefClassWriter::GetCeeGen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetMethodIL
// SetMethodIL -- This function will create a method within the class
void QCALLTYPE COMDynamicWrite::SetMethodIL(QCall::ModuleHandle pModule,
INT32 tk,
BOOL fIsInitLocal,
LPCBYTE pBody,
INT32 cbBody,
LPCBYTE pLocalSig,
INT32 sigLength,
UINT16 maxStackSize,
ExceptionInstance * pExceptions,
INT32 numExceptions,
INT32 * pTokenFixups,
INT32 numTokenFixups)
{
QCALL_CONTRACT;
BEGIN_QCALL;
RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
_ASSERTE(pRCW);
_ASSERTE(pLocalSig);
PCCOR_SIGNATURE pcSig = (PCCOR_SIGNATURE)pLocalSig;
_ASSERTE(*pcSig == IMAGE_CEE_CS_CALLCONV_LOCAL_SIG);
mdSignature pmLocalSigToken;
if (sigLength==2 && pcSig[0]==0 && pcSig[1]==0)
{
//This is an empty local variable sig
pmLocalSigToken=0;
}
else
{
IfFailThrow(pRCW->GetEmitter()->GetTokenFromSig( pcSig, sigLength, &pmLocalSigToken));
}
COR_ILMETHOD_FAT fatHeader;
// set fatHeader.Flags to CorILMethod_InitLocals if user wants to zero init the stack frame.
//
fatHeader.SetFlags(fIsInitLocal ? CorILMethod_InitLocals : 0);
fatHeader.SetMaxStack(maxStackSize);
fatHeader.SetLocalVarSigTok(pmLocalSigToken);
fatHeader.SetCodeSize(cbBody);
bool moreSections = (numExceptions != 0);
unsigned codeSizeAligned = fatHeader.GetCodeSize();
if (moreSections)
codeSizeAligned = AlignUp(codeSizeAligned, 4); // to insure EH section aligned
unsigned headerSize = COR_ILMETHOD::Size(&fatHeader, numExceptions != 0);
//Create the exception handlers.
CQuickArray<COR_ILMETHOD_SECT_EH_CLAUSE_FAT> clauses;
if (numExceptions > 0)
{
clauses.AllocThrows(numExceptions);
for (int i = 0; i < numExceptions; i++)
{
clauses[i].SetFlags((CorExceptionFlag)(pExceptions[i].m_type));
clauses[i].SetTryOffset(pExceptions[i].m_start);
clauses[i].SetTryLength(pExceptions[i].m_end - pExceptions[i].m_start);
clauses[i].SetHandlerOffset(pExceptions[i].m_handle);
clauses[i].SetHandlerLength(pExceptions[i].m_handleEnd - pExceptions[i].m_handle);
if (pExceptions[i].m_type == COR_ILEXCEPTION_CLAUSE_FILTER)
{
clauses[i].SetFilterOffset(pExceptions[i].m_filterOffset);
}
else if (pExceptions[i].m_type!=COR_ILEXCEPTION_CLAUSE_FINALLY)
{
clauses[i].SetClassToken(pExceptions[i].m_exceptionType);
}
else
{
clauses[i].SetClassToken(mdTypeRefNil);
}
}
}
unsigned ehSize = ExceptionHandlingSize(numExceptions, clauses.Ptr());
S_UINT32 totalSizeSafe = S_UINT32(headerSize) + S_UINT32(codeSizeAligned) + S_UINT32(ehSize);
if (totalSizeSafe.IsOverflow())
COMPlusThrowOM();
UINT32 totalSize = totalSizeSafe.Value();
ICeeGen* pGen = pRCW->GetCeeGen();
BYTE* buf = NULL;
ULONG methodRVA;
pGen->AllocateMethodBuffer(totalSize, &buf, &methodRVA);
if (buf == NULL)
COMPlusThrowOM();
_ASSERTE(buf != NULL);
_ASSERTE((((size_t) buf) & 3) == 0); // header is dword aligned
#ifdef _DEBUG
BYTE* endbuf = &buf[totalSize];
#endif
BYTE * startBuf = buf;
//.........这里部分代码省略.........