Parser - Changes to AST for the if instruction
The "else" case is now specific (to value 0), while the "then" case is the default.
This commit is contained in:
parent
e8460456e6
commit
f97bb9b596
1 changed files with 8 additions and 6 deletions
14
opparser.cc
14
opparser.cc
|
@ -1195,19 +1195,21 @@ M_INSTR_( If )
|
|||
return;
|
||||
}
|
||||
|
||||
cond.setCase( 1 , parseBlock( cond , input[ 2 ] ) );
|
||||
if ( cond.hasCase( 1 ) ) {
|
||||
cond.getCase( 1 ).location( ) = input[ 2 ].location( );
|
||||
cond.setDefaultCase( parseBlock( cond , input[ 2 ] ) );
|
||||
if ( cond.hasDefaultCase( ) ) {
|
||||
cond.defaultCase( ).location( ) = input[ 2 ].location( );
|
||||
}
|
||||
|
||||
if ( input.size( ) > 3 ) {
|
||||
cond.setDefaultCase( parseBlock( cond , input[ 3 ] ) );
|
||||
if ( cond.hasDefaultCase( ) ) {
|
||||
cond.defaultCase( ).location( ) = input[ 3 ].location( );
|
||||
cond.setCase( 0 , parseBlock( cond , input[ 3 ] ) );
|
||||
if ( cond.hasCase( 0 ) ) {
|
||||
cond.getCase( 0 ).location( ) = input[ 3 ].location( );
|
||||
}
|
||||
if ( input.size( ) > 4 ) {
|
||||
errors.addNew( "too many arguments" , input[ 4 ].location( ) );
|
||||
}
|
||||
} else {
|
||||
cond.setCase( 0 , NewOwned< T_InstrListNode >( cond ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue