MCPcopy Create free account
hub / github.com/anjo76/angelscript / ExtractObjectVariableInfo

Method ExtractObjectVariableInfo

sdk/angelscript/source/as_bytecode.cpp:1502–1564  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1500}
1501
1502void asCByteCode::ExtractObjectVariableInfo(asCScriptFunction *outFunc)
1503{
1504 asASSERT( outFunc->scriptData );
1505
1506 unsigned int pos = 0;
1507 asCByteInstruction *instr = first;
1508 int blockLevel = 0;
1509 while( instr )
1510 {
1511 if( instr->op == asBC_Block )
1512 {
1513 asSObjectVariableInfo info;
1514 info.programPos = pos;
1515 info.variableOffset = 0;
1516 info.option = instr->wArg[0] ? asBLOCK_BEGIN : asBLOCK_END;
1517 if( info.option == asBLOCK_BEGIN )
1518 {
1519 blockLevel++;
1520 outFunc->scriptData->objVariableInfo.PushLast(info);
1521 }
1522 else
1523 {
1524 blockLevel--;
1525 asASSERT( blockLevel >= 0 );
1526 if( outFunc->scriptData->objVariableInfo[outFunc->scriptData->objVariableInfo.GetLength()-1].option == asBLOCK_BEGIN &&
1527 outFunc->scriptData->objVariableInfo[outFunc->scriptData->objVariableInfo.GetLength()-1].programPos == pos )
1528 outFunc->scriptData->objVariableInfo.PopLast();
1529 else
1530 outFunc->scriptData->objVariableInfo.PushLast(info);
1531 }
1532 }
1533 else if( instr->op == asBC_ObjInfo )
1534 {
1535 asSObjectVariableInfo info;
1536 info.programPos = pos;
1537 info.variableOffset = (short)instr->wArg[0];
1538 info.option = (asEObjVarInfoOption)*(int*)ARG_DW(instr->arg);
1539 outFunc->scriptData->objVariableInfo.PushLast(info);
1540 }
1541 else if( instr->op == asBC_VarDecl )
1542 {
1543 // Record the position for debug info
1544 outFunc->scriptData->variables[instr->wArg[0]]->declaredAtProgramPos = pos;
1545
1546 // Record declaration of object variables for try/catch handling
1547 // This is used for identifying if handles and objects on the heap should be cleared upon catching an exception
1548 // Only extract this info if there is a try/catch block in the function, so we don't use up unnecessary space
1549 if( outFunc->scriptData->tryCatchInfo.GetLength() && outFunc->scriptData->variables[instr->wArg[0]]->type.GetTypeInfo() )
1550 {
1551 asSObjectVariableInfo info;
1552 info.programPos = pos;
1553 info.variableOffset = outFunc->scriptData->variables[instr->wArg[0]]->stackOffset;
1554 info.option = asOBJ_VARDECL;
1555 outFunc->scriptData->objVariableInfo.PushLast(info);
1556 }
1557 }
1558 else
1559 pos += instr->size;

Callers 1

FinalizeFunctionMethod · 0.80

Calls 4

PushLastMethod · 0.80
PopLastMethod · 0.80
GetTypeInfoMethod · 0.80
GetLengthMethod · 0.45

Tested by

no test coverage detected