| 1403 | } |
| 1404 | |
| 1405 | void asCCompiler::CompileStatementBlock(asCScriptNode *block, bool ownVariableScope, bool *hasReturn, asCByteCode *bc) |
| 1406 | { |
| 1407 | *hasReturn = false; |
| 1408 | bool isFinished = false; |
| 1409 | bool hasUnreachableCode = false; |
| 1410 | bool hasReturnBefore = false; |
| 1411 | asUINT visibleNamespaceCount = 0; |
| 1412 | |
| 1413 | if( ownVariableScope ) |
| 1414 | { |
| 1415 | bc->Block(true); |
| 1416 | AddVariableScope(); |
| 1417 | } |
| 1418 | |
| 1419 | asCScriptNode *node = block->firstChild; |
| 1420 | while( node ) |
| 1421 | { |
| 1422 | #ifdef AS_DEBUG |
| 1423 | // Keep the current line in a variable so it will be easier |
| 1424 | // to determine where in a script an assert is occurring. |
| 1425 | int currentLine = 0; |
| 1426 | script->ConvertPosToRowCol(node->tokenPos, ¤tLine, 0); |
| 1427 | #endif |
| 1428 | |
| 1429 | if( !hasUnreachableCode && (*hasReturn || isFinished) ) |
| 1430 | { |
| 1431 | // Empty statements don't count |
| 1432 | if( node->nodeType != snExpressionStatement || node->firstChild ) |
| 1433 | { |
| 1434 | hasUnreachableCode = true; |
| 1435 | Warning(TXT_UNREACHABLE_CODE, node); |
| 1436 | } |
| 1437 | |
| 1438 | if( *hasReturn ) |
| 1439 | hasReturnBefore = true; |
| 1440 | } |
| 1441 | |
| 1442 | if( node->nodeType == snBreak || node->nodeType == snContinue ) |
| 1443 | isFinished = true; |
| 1444 | |
| 1445 | asCByteCode statement(engine); |
| 1446 | if( node->nodeType == snDeclaration ) |
| 1447 | CompileDeclaration(node, &statement); |
| 1448 | else if (node->nodeType == snUsing) |
| 1449 | { |
| 1450 | asCScriptNode* n = node->firstChild; |
| 1451 | asCString name(&script->code[n->tokenPos], n->tokenLength); |
| 1452 | |
| 1453 | auto visibleNamespace = engine->FindNameSpace(name.AddressOf()); |
| 1454 | |
| 1455 | if (visibleNamespace == 0) |
| 1456 | { |
| 1457 | asCString msg; |
| 1458 | msg.Format(TXT_NAMESPACE_s_DOESNT_EXIST, name.AddressOf()); |
| 1459 | Error(msg, node); |
| 1460 | } |
| 1461 | else if (!m_namespaceVisibility.Exists(visibleNamespace)) |
| 1462 | { |
nothing calls this directly
no test coverage detected