MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / ParseWhileStatement

Method ParseWhileStatement

neo/d3xp/script/Script_Compiler.cpp:1755–1784  ·  view source on GitHub ↗

================ idCompiler::ParseWhileStatement ================ */

Source from the content-addressed store, hash-verified

1753================
1754*/
1755void idCompiler::ParseWhileStatement( void ) {
1756 idVarDef *e;
1757 int patch1;
1758 int patch2;
1759
1760 loopDepth++;
1761
1762 ExpectToken( "(" );
1763
1764 patch2 = gameLocal.program.NumStatements();
1765 e = GetExpression( TOP_PRIORITY );
1766 ExpectToken( ")" );
1767
1768 if ( ( e->initialized == idVarDef::initializedConstant ) && ( *e->value.intPtr != 0 ) ) {
1769 //FIXME: we can completely skip generation of this code in the opposite case
1770 ParseStatement();
1771 EmitOpcode( OP_GOTO, JumpTo( patch2 ), 0 );
1772 } else {
1773 patch1 = gameLocal.program.NumStatements();
1774 EmitOpcode( OP_IFNOT, e, 0 );
1775 ParseStatement();
1776 EmitOpcode( OP_GOTO, JumpTo( patch2 ), 0 );
1777 gameLocal.program.GetStatement( patch1 ).b = JumpFrom( patch1 );
1778 }
1779
1780 // fixup breaks and continues
1781 PatchLoop( patch2, patch2 );
1782
1783 loopDepth--;
1784}
1785
1786/*
1787================

Callers

nothing calls this directly

Calls 1

NumStatementsMethod · 0.45

Tested by

no test coverage detected