Goose  Diff

Differences From Artifact [8636fa2d96]:

  • File bs/builtins/types/localvar/localvar.cpp — part of check-in [1f1faa7fe2] at 2023-12-11 00:08:09 on branch trunk — Move the local type inference code out of locvar and into its own function so it can be reused for struct members (user: zlodo size: 6033)

To Artifact [17759fe401]:

  • File bs/builtins/types/localvar/localvar.cpp — part of check-in [f1458583b5] at 2023-12-26 15:41:26 on branch trunk — Structs: add the Finalize extension point that finalizes the creation of a struct after gathering its content. (user: zlodo size: 6037)

39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

65
66
67
68
69
70
71
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

64
65
66
67
68
69
70
71







-
+

















-
+







        auto index = util::GenerateNewUID();
        LocalVar lv( name, ValueToEIR( typeVal ), index );
        bb->append( AllocVar( typeVal, index, locId ) );

        Value initResult;

        {
            DiagnosticsContext dc( 0, "When invoking Initialize." );
            DiagnosticsContext dc( 0, "When invoking _Initialize." );

            if( initializer )
            {
                initResult = InvokeOverloadSet( c,
                    c.env()->extInitialize(),
                    MakeClosedTuple( ToValue( lv ).setLocationId( locId ), *initializer ), locId );
            }
            else
            {
                initResult = InvokeOverloadSet( c,
                    c.env()->extInitialize(),
                    MakeClosedTuple( ToValue( lv ).setLocationId( locId ) ), locId );
            }
        }

        if( !initResult.isPoison() )
        {
            DiagnosticsContext dc2( initResult.locationId(), "When invoking DropValue." );
            DiagnosticsContext dc2( initResult.locationId(), "When invoking _DropValue." );
            InvokeOverloadSet( c, c.env()->extDropValue(),
                MakeClosedTuple( c.builder(), move( initResult ) ), initResult.locationId() );
        }

        auto locVar = ToValue( lv );
        auto identity = AppendToVectorTerm( c.identity(), name );

94
95
96
97
98
99
100
101

102
103
104
105
106
107
108
109

110
111
112
113
114
115
116
94
95
96
97
98
99
100

101
102
103
104
105
106
107
108

109
110
111
112
113
114
115
116







-
+







-
+








        // 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 LowerTypeForRuntime on it during codegen,
        // it will have a meaningful location for the error message to attach itself on.
        LocalVar lv( name, ValueToEIR( type ), index );
        bb->append( AllocVar( type, index, locId ) );

        DiagnosticsContext dc( 0, "When invoking Initialize." );
        DiagnosticsContext dc( 0, "When invoking _Initialize." );

        auto initResult = InvokeOverloadSet( c,
            c.env()->extInitialize(),
            MakeClosedTuple( ToValue( lv ).setLocationId( locId ), initVal ) );

        if( !initResult.isPoison() )
        {
            DiagnosticsContext dc2( initResult.locationId(), "When invoking DropValue." );
            DiagnosticsContext dc2( initResult.locationId(), "When invoking _DropValue." );
            InvokeOverloadSet( c, c.env()->extDropValue(),
                MakeClosedTuple( c.builder(), move( initResult ) ) );
        }

        auto locVar = ToValue( lv );

        if( name != ""_sid )