Goose  Diff

Differences From Artifact [4806c44a7b]:

  • File bs/builtins/types/func/invoke.cpp — part of check-in [55beba911a] at 2021-09-12 16:48:57 on branch trunk —
    • Started work on extensibility api
    • some code cleanup
    (user: achavasse size: 5093)

To Artifact [d907dd9dce]:

  • File bs/builtins/types/func/invoke.cpp — part of check-in [4a571387ed] at 2021-09-17 23:04:29 on branch trunk — g0api, builtins: got rid of TermWrapper and ValueWrapper, use specializations of TypeWrapper instead to allow for more generic code (user: achavasse size: 5109)

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







-
+













-
+







                    return GetBuiltinIntrinsicFuncWrapper( preparedCallee )( c, move( typeCheckedArgs ) );

                auto ft = *FromValue< FuncType >( *EIRToValue( preparedCallee.type() ) );

                if( ft.intrinsic() )
                {
                    // Intrinsic call: we insert the code builder wrapper as first param,
                    // wrap all args with ValueWrapper, and execute the function directly.
                    // wrap all args with TypeWrapper< Value >, and execute the function directly.
                    auto argList = BuildArgListForIntrinsicCall( c, ft, typeCheckedArgs );
                    if( !argList )
                        return PoisonValue();

                    execute::VM vm;
                    auto result = vm.execute( cir::Call( preparedCallee, move( *argList ) ) );
                    if( ft.returnType() == GetValueType< void >() )
                        return Value( GetValueType< void >(), 0U );

                    if( !result )
                        return PoisonValue();

                    // Unwrap the returned value
                    auto unwrapped = FromValue< ValueWrapper >( *result );
                    auto unwrapped = FromValue< TypeWrapper< Value > >( *result );
                    return unwrapped ? *unwrapped : PoisonValue();
                }

                auto argList = BuildArgListForCall( c, ft, typeCheckedArgs );
                if( !argList )
                    return PoisonValue();