Goose  Diff

Differences From Artifact [b301f2e8a5]:

  • File bs/compiler.cpp — part of check-in [3c074f1b7d] at 2019-07-30 22:05:49 on branch trunk —
    • Builtin functions are now explicitely marked if they need to be evaluated eagerly.
    • Using errors out if the expression doesn't evaluate to a constant.
    (user: achavasse size: 1994)

To Artifact [e90acc8f22]:

  • File bs/compiler.cpp — part of check-in [d19a6bf065] at 2019-07-31 14:05:40 on branch trunk — Fixed some cyclic reference issues with cyclic CFGs:
    • Moved and renamed sema::CFGBuilder to llr::CFG.
    • llr::Func now owns a CFG pointer, rather than a pointer to its entry BB.
    • Branch and CondBranch now store weak pointers to their target BB.
    (user: achavasse size: 1944)

48
49
50
51
52
53
54
55
56
57



58
59
60
61
62
63
64
65
66
67

68
69
70
71
72
73
74

75
76
77
78
79
48
49
50
51
52
53
54



55
56
57
58
59
60
61
62
63
64
65
66

67
68
69
70
71
72
73

74
75
76
77
78
79







-
-
-
+
+
+









-
+






-
+





uint64_t Compiler::execute( istream& source, const ptr< string >& filename )
{
    sema::Context c( m_pEnv, builtins::RootIdentity(), GetValueType< uint64_t >() );

    auto r = make_shared< parse::Resolver >( make_shared< lex::Lexer >( source, filename ), c );
    parse::Parser p( r );

    auto cfgBuilder = make_shared< sema::CFGBuilder >();
    p.setCFGBuilder( cfgBuilder );
    p.setCurrentBB( cfgBuilder->entryBB() );
    auto cfg = make_shared< llr::CFG >();
    p.setCFG( cfg );
    p.setCurrentBB( cfg->entryBB() );

    p.parseSequence();

    if( !r->eos() )
    {
        cout << "syntax error.\n";
        return 0;
    }

    if( !cfgBuilder->entryBB()->canBeExecuted() )
    if( !cfg->entryBB()->canBeExecuted() )
    {
        cout << "front end can not be executed.\n";
        return 0;
    }

    execute::VM vm;
    auto result = vm.execute( cfgBuilder->entryBB() );
    auto result = vm.execute( cfg->entryBB() );
    if( !result )
        return 1;

    return *FromValue< uint64_t >( *result );
}