Goose  Diff

Differences From Artifact [db9078b07e]:

  • File bs/sema/uni-context.h — part of check-in [75bcd81044] at 2019-08-15 01:27:35 on branch trunk —
    • Implemented the DropValue() extension point, called when a previously pushed value is dropped without being used.
    • ir, sema: the complexity of an ir expression is now directly counted by ir::Vector, so that we don't have to deal with it in every unification rule (and it was missing from most of them, which caused incorrect overload resolutions in some cases).
    (user: achavasse size: 5463)

To Artifact [6129537eee]:

  • File bs/sema/uni-context.h — part of check-in [e38aee1ca0] at 2019-08-22 13:23:16 on branch trunk — You have failed me for the last time, CMake. (user: achavasse size: 5511)

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
80
81
82
83
            // Indicates whether we are in trhe second unification pass
            bool secondPass() const { return m_secondPass; }

            void setSecondPass() { m_secondPass = true; }

            const optional< Term >& getValue( uint32_t index ) const
            {
                assert( m_values.size() > index );
                return m_values[index].m_term;
            }

            template< typename T >
            void setValue( uint32_t index, T&& val )
            {
                assert( m_values.size() > index );

                if( m_values[index].m_required && !m_values[index].m_term )
                    --m_numUnknownValues;

                if( m_values[index].m_term )
                    m_complexity -= GetComplexity( *m_values[index].m_term );

                m_values = m_values.set( index, { forward< T >( val ), true } );

                m_complexity += GetComplexity( *m_values[index].m_term );
            }

            UnificationContext& flip()
            {
                swap( m_currentLHSNamespaceIndex, m_currentRHSNamespaceIndex );
                return *this;
            }







|
|





|

|


|
|

|

|







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
80
81
82
83
            // Indicates whether we are in trhe second unification pass
            bool secondPass() const { return m_secondPass; }

            void setSecondPass() { m_secondPass = true; }

            const optional< Term >& getValue( uint32_t index ) const
            {
                assert( m_pCow->values.size() > index );
                return m_pCow->values[index].m_term;
            }

            template< typename T >
            void setValue( uint32_t index, T&& val )
            {
                assert( m_pCow->values.size() > index );

                if( m_pCow->values[index].m_required && !m_pCow->values[index].m_term )
                    --m_numUnknownValues;

                if( m_pCow->values[index].m_term )
                    m_complexity -= GetComplexity( *m_pCow->values[index].m_term );

                CoW( m_pCow )->values[index] = { forward< T >( val ), true };

                m_complexity += GetComplexity( *m_pCow->values[index].m_term );
            }

            UnificationContext& flip()
            {
                swap( m_currentLHSNamespaceIndex, m_currentRHSNamespaceIndex );
                return *this;
            }
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
140
141
142

            struct StoredValue
            {
                optional< Term >    m_term;
                bool                m_required = false;
            };

            immer::vector< StoredValue >                m_values;

            uint32_t                                    m_currentLHSNamespaceIndex = 1;
            uint32_t                                    m_currentRHSNamespaceIndex = 2;
            uint32_t                                    m_nextNamespaceIndex = 3;

            uint32_t                                    m_numUnknownValues = 0;
            uint32_t                                    m_complexity = 0;

            uint32_t                                    m_numAnonymousHoles = 0;

            using HoleName = pair< StringId, uint32_t >;

            struct Cow
            {

                unordered_map< HoleName, uint32_t > holeDict;
                unordered_set< uint32_t > lockedHoles;
            };

            ptr< Cow >                                  m_pCow = make_shared< Cow >();

            bool                                        m_valuesAreRequired = true;
            bool                                        m_secondPass = false;
    };
}

#endif







<
<













>

|










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
140
141

            struct StoredValue
            {
                optional< Term >    m_term;
                bool                m_required = false;
            };



            uint32_t                                    m_currentLHSNamespaceIndex = 1;
            uint32_t                                    m_currentRHSNamespaceIndex = 2;
            uint32_t                                    m_nextNamespaceIndex = 3;

            uint32_t                                    m_numUnknownValues = 0;
            uint32_t                                    m_complexity = 0;

            uint32_t                                    m_numAnonymousHoles = 0;

            using HoleName = pair< StringId, uint32_t >;

            struct Cow
            {
                vector< StoredValue >               values;
                unordered_map< HoleName, uint32_t > holeDict;
                unordered_set< uint32_t >           lockedHoles;
            };

            ptr< Cow >                                  m_pCow = make_shared< Cow >();

            bool                                        m_valuesAreRequired = true;
            bool                                        m_secondPass = false;
    };
}

#endif