Goose  Diff

Differences From Artifact [512eeed115]:

  • File bs/sema/uni-context.cpp — part of check-in [ecf8c6820f] at 2019-03-30 16:28:15 on branch trunk —
    • Fixed the conversion of a type type value to an ir expression.
    • Fixed anonymous holes not being counted in unification scores.
    (user: achavasse size: 2380)

To Artifact [600969f91d]:

  • File bs/sema/uni-context.cpp — part of check-in [fc331f1703] at 2019-04-06 14:16:09 on branch trunk —
    • Simplified TDecl: the right hand side can now only be a TVar. Removed the colon operator.
    • Added the possibility in unification to make hole resolution non mandatory for a sub expression.
    • Higher order polymorphism: implemented the unification of a polymorphic tfunc type param with a template lambda.
    (user: achavasse size: 2812)

37
38
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



72
73
74
75
76
77
78
37
38
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96







-
+

+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+











+
+
+












+
+
+







        return InvalidIndex;

    return it->second;
}

uint32_t UnificationContext::createValue()
{
    m_values = m_values.push_back( { nullopt,0 } );
    m_values = m_values.push_back( StoredValue() );
    uint32_t index = m_values.size() - 1;
    return index;
}
    ++m_numUnknownValues;
    return index;
}

void UnificationContext::setValueRequired( uint32_t index )
{
    assert( m_values.size() > index );

    if( m_values[index].m_required )
        return;

    m_values = m_values.set( index, { m_values[index].m_term, m_values[index].m_complexity, true } );

    if( !m_values[index].m_term )
        ++m_numUnknownValues;
}

void UnificationContext::setLHSHoleIndex( const StringId& name, uint32_t index )
{
    if( name == "_"_sid )
    {
        ++m_numAnonymousHoles;
        return;
    }

    HoleName holeName( name, m_currentLHSNamespaceIndex );
    CoW( m_pCow )->holeDict.emplace( holeName, index );

    if( m_valuesAreRequired )
        setValueRequired( index );
}

void UnificationContext::setRHSHoleIndex( const StringId& name, uint32_t index )
{
    if( name == "_"_sid )
    {
        ++m_numAnonymousHoles;
        return;
    }

    HoleName holeName( name, m_currentRHSNamespaceIndex );
    CoW( m_pCow )->holeDict.emplace( holeName, index );

    if( m_valuesAreRequired )
        setValueRequired( index );
}

void UnificationContext::eraseLHSName( const StringId& name )
{
    HoleName holeName( name, m_currentLHSNamespaceIndex );
    CoW( m_pCow )->holeDict.erase( holeName );
}