Goose  Diff

Differences From Artifact [346d29ed03]:

  • File bs/builtins/operators/comma.cpp — part of check-in [26c691ecb9] at 2021-01-02 18:24:23 on branch trunk — Yet one more reference/address refactor: each calculation step (getting temp addr, getting var addr, selecting a member) is now a separate cir instruction. We need this level of generalization to be able to obtain addresses from anywhere, including variables and function parameters. (user: achavasse size: 3900)

To Artifact [2f9dd7b669]:

  • File bs/builtins/operators/comma.cpp — part of check-in [3eebbcff0c] at 2021-01-03 18:34:23 on branch trunk — Fixed a bug with addresses computed during compilation time execution. Mutating values through references passed as parameters now works, at compilation time at least. (user: achavasse size: 3028)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "builtins/builtins.h"
#include "precedence.h"
#include "helpers.h"

using namespace goose;
using namespace goose::eir;
using namespace goose::parse;

namespace goose::builtins
{
    void SetupCommaOp( Env& e )
    {
        using LocVarOfAnyType =
            CustomPattern< LocalVar, LocalVar::PatternAny >;

        using RefOfAnyType =
            CustomPattern< Value, ReferenceType::PatternAny >;

        BuildParseRule( e, ","_sid,
            LeftAssInfixOp( "operator_comma"_sid, precedence::CommaOp,

                // Overload: open tuple, open tuple












<
<
<







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



13
14
15
16
17
18
19
#include "builtins/builtins.h"
#include "precedence.h"
#include "helpers.h"

using namespace goose;
using namespace goose::eir;
using namespace goose::parse;

namespace goose::builtins
{
    void SetupCommaOp( Env& e )
    {



        using RefOfAnyType =
            CustomPattern< Value, ReferenceType::PatternAny >;

        BuildParseRule( e, ","_sid,
            LeftAssInfixOp( "operator_comma"_sid, precedence::CommaOp,

                // Overload: open tuple, open tuple
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
                // Overload: anything, anything
                ForType< Value >(
                []( auto&& c, auto&& lhs, auto&& rhs ) -> Value
                {
                    return AppendToTuple( AppendToTuple( EmptyTuple(), lhs ), rhs );
                } ),

                // By default, locvars return their content during type checking.
                // Since we want to keep them as is in tuples, we need specific overloads that will
                // get locvars as such.
                ForType< LocVarOfAnyType >(
                []( auto&& c, auto&& lhs, auto&& rhs ) -> Value
                {
                    return AppendToTuple( AppendToTuple( EmptyTuple(), lhs ), rhs );
                } ),

                ForTypes< CustomPattern< Value, TupleOpenPattern >, LocVarOfAnyType >(
                []( auto&& c, auto&& lhs, auto&& rhs ) -> Value
                {
                    return AppendToTuple( lhs, rhs );
                } ),

                ForTypes< LocVarOfAnyType, CustomPattern< Value, TupleOpenPattern > >(
                []( auto&& c, auto&& lhs, auto&& rhs ) -> Value
                {
                    return PrependToTuple( lhs, rhs );
                } ),

                // Likewise for references.
                ForType< RefOfAnyType >(
                []( auto&& c, auto&& lhs, auto&& rhs ) -> Value
                {
                    return AppendToTuple( AppendToTuple( EmptyTuple(), lhs ), rhs );
                } ),

                ForTypes< Value, RefOfAnyType >(







<
<
<
<
<
<
<
<
|
<
<
<
<
<
|
<
<
<
<
<
|
<







40
41
42
43
44
45
46








47





48





49

50
51
52
53
54
55
56
                // Overload: anything, anything
                ForType< Value >(
                []( auto&& c, auto&& lhs, auto&& rhs ) -> Value
                {
                    return AppendToTuple( AppendToTuple( EmptyTuple(), lhs ), rhs );
                } ),









                // We want to be able to put references in tuples without them getting





                // automatically dereferenced, so we have specific overloads that treat





                // them explicitely.

                ForType< RefOfAnyType >(
                []( auto&& c, auto&& lhs, auto&& rhs ) -> Value
                {
                    return AppendToTuple( AppendToTuple( EmptyTuple(), lhs ), rhs );
                } ),

                ForTypes< Value, RefOfAnyType >(