95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
format( "can't open '{}'.", filename ) );
return nullptr;
}
sema::Context c( e, identity, returnType );
DiagnosticsContext dc( 0, true );
VerbosityContext vc( Verbosity::Normal, true );
auto r = make_shared< parse::Resolver >(
make_shared< lex::Lexer >( sourcefile, filename ), c );
parse::Parser p( r );
auto cfg = make_shared< llr::CFG >( 0 );
cfg->createBB();
p.setCFG( cfg );
p.cfg()->setCurrentBB( cfg->entryBB() );
p.parseSequence();
if( cfg->isPoisoned() )
return cfg;
if( !r->eos() )
{
DiagnosticsManager::GetInstance().emitSyntaxErrorMessage(
r->getCurrentLocation(), "syntax error." );
}
if( p.cfg()->currentBB() && !cfg->currentBB()->terminator() )
{
// TODO implement a "default return value"
// system so that omitting the return statement
// at the top level does the right thing.
p.emitTerminator( llr::Ret() );
}
verify::Func fv( cfg );
if( !fv.verify() )
return nullptr;
return cfg;
|
>
>
>
>
>
>
>
<
<
<
<
<
|
|
>
>
|
|
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
format( "can't open '{}'.", filename ) );
return nullptr;
}
sema::Context c( e, identity, returnType );
DiagnosticsContext dc( 0, true );
VerbosityContext vc( Verbosity::Normal, true );
auto cfg = make_shared< llr::CFG >( 0 );
cfg->createBB();
cfg->setCurrentBB( cfg->entryBB() );
auto cb = make_shared< CodeBuilder >( cfg );
c.setBuilder( cb );
auto r = make_shared< parse::Resolver >(
make_shared< lex::Lexer >( sourcefile, filename ), c );
parse::Parser p( r );
p.parseSequence();
if( cfg->isPoisoned() )
return cfg;
if( !r->eos() )
{
DiagnosticsManager::GetInstance().emitSyntaxErrorMessage(
r->currentLocation(), "syntax error." );
}
if( cfg->currentBB() && !cfg->currentBB()->terminator() )
{
// TODO implement a "default return value"
// system so that omitting the return statement
// at the top level does the right thing.
p.flushValue();
cb->destroyAllLiveValues( c );
cb->emitTerminator( r->currentLocation(), llr::Ret() );
}
verify::Func fv( cfg );
if( !fv.verify() )
return nullptr;
return cfg;
|