Goose  Diff

Differences From Artifact [a32d889980]:

  • File bs/compile/compiler.cpp — part of check-in [12f37d77cb] at 2019-12-05 17:40:07 on branch trunk — Implemented a helper to check whether a type is compile-time only. (user: achavasse size: 4052)

To Artifact [fecae2d23e]:

  • File bs/compile/compiler.cpp — part of check-in [b3aeaae2df] at 2020-01-11 18:28:15 on branch trunk —
    • Moved the cfg and lifetime management stuff into a CodeBuilder object owned by sema::Context. This is in preparation to allow alternative implementations of the builder, for instance to build classes.
    • Pass the context to intrinsic functions, which removes their dependency to the parser the need for the ugly "GetCurrentParser" static function.
    (user: achavasse size: 4193)

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
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 );

        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." );
                r->currentLocation(), "syntax error." );
        }

        if( p.cfg()->currentBB() && !cfg->currentBB()->terminator() )
        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 );
            p.emitTerminator( llr::Ret() );
            cb->emitTerminator( r->currentLocation(), llr::Ret() );
        }

        verify::Func fv( cfg );
        if( !fv.verify() )
            return nullptr;

        return cfg;