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

Method ParseIfStatement

neo/game/script/Script_Compiler.cpp:1924–1948  ·  view source on GitHub ↗

================ idCompiler::ParseIfStatement ================ */

Source from the content-addressed store, hash-verified

1922================
1923*/
1924void idCompiler::ParseIfStatement( void ) {
1925 idVarDef *e;
1926 int patch1;
1927 int patch2;
1928
1929 ExpectToken( "(" );
1930 e = GetExpression( TOP_PRIORITY );
1931 ExpectToken( ")" );
1932
1933 //FIXME: add check for constant expression
1934 patch1 = gameLocal.program.NumStatements();
1935 EmitOpcode( OP_IFNOT, e, 0 );
1936
1937 ParseStatement();
1938
1939 if ( CheckToken( "else" ) ) {
1940 patch2 = gameLocal.program.NumStatements();
1941 EmitOpcode( OP_GOTO, 0, 0 );
1942 gameLocal.program.GetStatement( patch1 ).b = JumpFrom( patch1 );
1943 ParseStatement();
1944 gameLocal.program.GetStatement( patch2 ).a = JumpFrom( patch2 );
1945 } else {
1946 gameLocal.program.GetStatement( patch1 ).b = JumpFrom( patch1 );
1947 }
1948}
1949
1950/*
1951============

Callers

nothing calls this directly

Calls 1

NumStatementsMethod · 0.45

Tested by

no test coverage detected