Goose  Diff

Differences From Artifact [e9cbae6050]:

  • File bs/builtins/types/template/build.cpp — part of check-in [c4abb2a3ed] at 2019-08-10 14:26:37 on branch trunk — Refactored the lexer (and the resolver) to output Terms associated with location Ids. (user: achavasse size: 3168)

To Artifact [44b2b5baf1]:

  • File bs/builtins/types/template/build.cpp — part of check-in [4a121b956a] at 2019-08-11 18:59:54 on branch trunk — Converted all the remaining error messages to use the diagnostics manager. (user: achavasse size: 3601)

32
33
34
35
36
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
32
33
34
35
36
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







+
-
+














+
-
+








        bool success = true;
        ForEachInVectorTerm( tft.params(), [&]( auto&& param )
        {
            auto teSig = BuildTemplateSignature( c, param );
            if( !teSig )
            {
                DiagnosticsManager::GetInstance().emitErrorMessage( ValueFromIRExpr( param )->locationId(),
                cout << "Invalid template parameter.\n";
                    "Invalid template parameter." );
                success = false;
                return false;
            }

            vt.push_back( move( *teSig ) );
            return true;
        } );

        if( !success )
            return nullopt;

        auto rtSig = BuildTemplateSignature( c, tft.returnType() );
        if( !rtSig )
        {
            DiagnosticsManager::GetInstance().emitErrorMessage( ValueFromIRExpr( tft.returnType() )->locationId(),
            cout << "Invalid template return type or texpr.\n";
                "Invalid template return type or texpr." );
            return nullopt;
        }

        return TVEC(
            tft.domain(),
            TERM( make_shared< Vector >( vt.persistent() ) ),
            *rtSig );
80
81
82
83
84
85
86

87

88
89
90
91
92
93
94
95
96
97
98
99
100
101

102

103
104
105
106
107
108
109
110
111
112
82
83
84
85
86
87
88
89

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

106
107
108
109
110
111
112
113
114
115
116







+
-
+














+
-
+











        bool success = true;
        ForEachInVectorTerm( ftype->params(), [&]( auto&& param )
        {
            auto teArgPat = BuildTemplateArgPattern( c, param );
            if( !teArgPat )
            {
                DiagnosticsManager::GetInstance().emitErrorMessage( ValueFromIRExpr( param )->locationId(),
                cout << "Invalid template parameter.\n";
                    "Invalid template parameter." );
                success = false;
                return false;
            }

            apvt.push_back( move( *teArgPat ) );
            return true;
        } );

        if( !success )
            return nullopt;

        auto rtArgPat = BuildTemplateArgPattern( c, ftype->returnType() );
        if( !rtArgPat )
        {
            DiagnosticsManager::GetInstance().emitErrorMessage( ValueFromIRExpr( ftype->returnType() )->locationId(),
            cout << "Invalid template return type or texpr.\n";
                "Invalid template return type or texpr." );
            return nullopt;
        }

        return TVEC(
            ftype->domain(),
            TERM( make_shared< Vector >( apvt.persistent() ) ),
            *rtArgPat
        );
    }
}