16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
auto& dm = DiagnosticsManager::GetInstance();
auto pPrecBB = p.currentBB();
auto np = p.makeNestedParser();
if( !np.parseExpression( precedence::IfStmt ) )
{
dm.emitErrorMessage( locationId, "expected an expression following the #if statement1.", 0 );
return false;
}
auto condVal = np.popValue();
if( !condVal )
{
dm.emitErrorMessage( locationId, "expected an expression following the #if statement2.", 0 );
return false;
}
const auto& context = p.resolver()->context();
auto converted = ConvertValueToType( context, *condVal, GetValueType< bool >() );
if( holds_alternative< ValUnifyError >( converted ) )
{
|
|
|
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
auto& dm = DiagnosticsManager::GetInstance();
auto pPrecBB = p.currentBB();
auto np = p.makeNestedParser();
if( !np.parseExpression( precedence::IfStmt ) )
{
dm.emitSyntaxErrorMessage( locationId, "expected an expression following the #if statement1.", 0 );
return false;
}
auto condVal = np.popValue();
if( !condVal )
{
dm.emitSyntaxErrorMessage( locationId, "expected an expression following the #if statement2.", 0 );
return false;
}
const auto& context = p.resolver()->context();
auto converted = ConvertValueToType( context, *condVal, GetValueType< bool >() );
if( holds_alternative< ValUnifyError >( converted ) )
{
|
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
dm.emitErrorMessage( condVal->locationId(), "the #if condition doesn't evaluate to a bool constant." );
return false;
}
auto next = p.resolver()->lookAheadUnresolved();
if( !next )
{
dm.emitErrorMessage( p.resolver()->getCurrentLocation(), "brace block expected.", 0 );
return false;
}
auto decomp = Decompose( next->first, Val< Delimiter >() );
if( !decomp || *decomp != Delimiter::OpenBrace )
{
dm.emitErrorMessage( p.resolver()->getCurrentLocation(), "brace block expected.", 0 );
return false;
}
// Deal with the then block.
if( *cond )
{
if( !p.parseBraceBlock() )
|
|
|
|
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
dm.emitErrorMessage( condVal->locationId(), "the #if condition doesn't evaluate to a bool constant." );
return false;
}
auto next = p.resolver()->lookAheadUnresolved();
if( !next )
{
dm.emitSyntaxErrorMessage( p.resolver()->getCurrentLocation(), "brace block expected.", 0 );
return false;
}
auto decomp = Decompose( next->first, Val< Delimiter >() );
if( !decomp || *decomp != Delimiter::OpenBrace )
{
dm.emitSyntaxErrorMessage( p.resolver()->getCurrentLocation(), "brace block expected.", 0 );
return false;
}
// Deal with the then block.
if( *cond )
{
if( !p.parseBraceBlock() )
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
{
p.resolver()->consumeUnresolved();
auto next = p.resolver()->lookAheadUnresolved();
auto decomp = Decompose( next->first, Val< Delimiter >() );
if( !decomp || *decomp != Delimiter::OpenBrace )
{
dm.emitErrorMessage( p.resolver()->getCurrentLocation(), "brace block expected.", 0 );
return false;
}
// Deal with the else block.
if( !*cond )
{
if( !p.parseBraceBlock() )
|
|
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
{
p.resolver()->consumeUnresolved();
auto next = p.resolver()->lookAheadUnresolved();
auto decomp = Decompose( next->first, Val< Delimiter >() );
if( !decomp || *decomp != Delimiter::OpenBrace )
{
dm.emitSyntaxErrorMessage( p.resolver()->getCurrentLocation(), "brace block expected.", 0 );
return false;
}
// Deal with the else block.
if( !*cond )
{
if( !p.parseBraceBlock() )
|