Goose  Diff

Differences From Artifact [e6a034da63]:

  • File bs/sema/inv-func.cpp — part of check-in [61cece933d] at 2019-01-27 16:05:44 on branch trunk — Sema: added a placeholder implementation for the function invocation rule. (user: achavasse size: 532)

To Artifact [a2d6943fbe]:

  • File bs/sema/inv-func.cpp — part of check-in [714e009000] at 2019-01-28 23:05:09 on branch trunk — Sema: refactor function invocation rules so that they can provide a signature of the callee, in addition of resolving a call. (user: achavasse size: 944)

1
2
3
4

















5
6
7
8
9
10
11
12
13
14
15
16
17
#include "sema.h"

namespace empathy::sema
{

















    void SetupFunctionInvocationRule( InvocationRuleSet& ruleSet )
    {
        ruleSet.addRule(
            ValueToIRExpr( Value( TSID( type ), TVEC( TSID( func ),
                ANYTERM( k ), ANYTERM( rt ), ANYTERM( p ) ) ) ),
            []( ptr< Env > env, const Value& callee, const Value& args ) -> optional< Value >
            {
                // Just a placeholder for now
                cout << "func invocation\n";
                return nullopt;
            } );
    }
}




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





<
<
<
|
<
<


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
#include "sema.h"

namespace empathy::sema
{
    class FunctionInvocationRule : public InvocationRule
    {
        public:
            virtual optional< Value > resolveInvocation( const ptr< Env >& env, const Value& callee, const Value& args ) const override
            {
                // Just a placeholder for now
                cout << "func invocation\n";
                return nullopt;
            }

            virtual Term getSignature( const ptr< Env >& env, const Value& callee ) const override
            {
                // Just a placeholder for now
                return TSID( func_sig_placeholder );
            }
    };

    void SetupFunctionInvocationRule( InvocationRuleSet& ruleSet )
    {
        ruleSet.addRule(
            ValueToIRExpr( Value( TSID( type ), TVEC( TSID( func ),
                ANYTERM( k ), ANYTERM( rt ), ANYTERM( p ) ) ) ),



                make_shared< FunctionInvocationRule >() );


    }
}