Goose  Diff

Differences From Artifact [249577d0f3]:

  • File bs/builtins/types/localvar/localvar.cpp — part of check-in [48a020a1fa] at 2019-08-17 14:49:29 on branch trunk —
    • Intrinsics automatically set their domain depending on the domain restrictions of the builtin types that they use.
    • Declaring a local variable of a compile-time only type is now properly rejected during codegen.
    • Improved error messages for operators and extension point invocations.
    (user: achavasse size: 7991)

To Artifact [199de4cfe3]:

  • File bs/builtins/types/localvar/localvar.cpp — part of check-in [a504aedf6c] at 2019-08-18 18:52:09 on branch trunk —
    • Implemented the break and the continue statements.
    • Fixed cfg generation issues with nested control statements.
    • Fixed unreachable code error messages not emitted in some cases.
    (user: achavasse size: 8111)

16
17
18
19
20
21
22
23




24
25
26
27
28
29
30
16
17
18
19
20
21
22

23
24
25
26
27
28
29
30
31
32
33







-
+
+
+
+







    Value DeclareLocalVar( Parser& p, const Term& type, StringId name, const optional< Value >& initializer )
    {
        auto cfgId = p.cfg()->uniqueId();
        auto index = p.cfg()->getNewTemporaryIndex();

        LocalVar lv( type, cfgId, index );

        auto bb = p.currentBB();
        auto bb = p.cfg()->currentBB();
        if( !bb )
            return PoisonValue();

        auto typeVal = *ValueFromIRExpr( type );
        bb->emplace_back( AllocVar( typeVal, cfgId, index ) );

        if( initializer )
        {
            DiagnosticsContext dc( 0, "When invoking InitializeLocalVar." );

49
50
51
52
53
54
55




56
57
58
59
60
61
62
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69







+
+
+
+








        p.resolver()->clearLookAheadCache();
        return locVar;
    }

    Value DeclareLocalVarWithTypeInference( Parser& p, const Term& typeTExpr, StringId name, const Value& initVal )
    {
        auto bb = p.cfg()->currentBB();
        if( !bb )
            return PoisonValue();

        const auto& c = p.resolver()->context();

        // To infer the type and obtain a suitable initialization function,
        // we want the declaration to behave as if it were the following function call:
        // Params: ( $T,  _ ( LocalVar[$T], initVal ) initFunc )
        // Args:   ( pat, InitializeLocalVar                   )
        //
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
161
162
163
164
165
166
167

168
169
170
171
172
173
174







-








        // Retrieve the texpr's location and set it on the inferred type. This way if an
        // error occurs later with it, for instance when calling LowerType on it during codegen,
        // it will have a meaningful location for the error message to attach itself on.
        uint32_t typeLoc = ValueFromIRExpr( typeTExpr )->locationId();
        LocalVar lv( type, cfgId, index );

        auto bb = p.currentBB();
        bb->emplace_back( AllocVar( ValueFromIRExpr( lv.type() )->setLocationId( typeLoc ), cfgId, index ) );

        p.pushValue( ResolveInvocation( c, GetInvocationRule( *c.env(), initializerVal ), initializerVal,
            MakeTuple( ToValue( lv ), initVal ) ) );

        auto locVar = ToValue( lv );
        auto identity = AppendToVectorTerm( p.resolver()->context().identity(), name );