Goose  Diff

Differences From Artifact [5d87fc2673]:

  • File bs/sema/uni-context.cpp — part of check-in [293c45270a] at 2018-12-31 08:51:16 on branch trunk — Work in progress on holes unification. (user: achavasse size: 1420)

To Artifact [f5a892b705]:

  • File bs/sema/uni-context.cpp — part of check-in [ce11e48c1b] at 2019-01-03 13:43:26 on branch trunk — First draft implementation of hole vs hole unification. (user: achavasse size: 1406)

1
2
3
4
5
6
7
8
9
10
11
12
13
14

15
16
17
18
19
20

21
22
23
24
25

26
27
28
29
30
31

32
33
34
35
36
37
38
1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19

20
21
22
23
24

25
26
27
28
29
30

31
32
33
34
35
36
37
38













-
+





-
+




-
+





-
+







#include "sema.h"

using namespace empathy;
using namespace empathy::sema;

UnificationContext::UnificationContext( const ptr< UnificationRuleSet >& rules ) :
    m_rules( rules )
{}

UnificationContext::UnificationContext( ptr< UnificationRuleSet >&& rules ) :
    m_rules( move( rules ) )
{}

optional< uint32_t > UnificationContext::getLHSHoleIndex( const StringId& name ) const
uint32_t UnificationContext::getLHSHoleIndex( const StringId& name ) const
{
    HoleName holeName( name, m_currentLHSNamespaceIndex );

    auto it = m_pCoW->m_holes.find( holeName );
    if( it == m_pCoW->m_holes.end() )
        return nullopt;
        return InvalidIndex;

    return it->second;
}

optional< uint32_t > UnificationContext::getRHSHoleIndex( const StringId& name ) const
uint32_t UnificationContext::getRHSHoleIndex( const StringId& name ) const
{
    HoleName holeName( name, m_currentRHSNamespaceIndex );

    auto it = m_pCoW->m_holes.find( holeName );
    if( it == m_pCoW->m_holes.end() )
        return nullopt;
        return InvalidIndex;

    return it->second;
}

uint32_t UnificationContext::createValue()
{
    m_values = m_values.push_back( nullopt );