Goose  Diff

Differences From Artifact [162bfa60aa]:

  • File bs/ir/term.h — part of check-in [568c366a36] at 2020-06-26 23:34:09 on branch trunk — Cleanup:
    • Removed the poorly thought out "domain" system that was intended to allow for different implementations of functions for runtime and for compilation time, which was adding an absurd amount of crap everywhere and should be unnecessary with the current planned approach for implementing data structures.
    • The using statement doesn't do lazy parsing anymore. Lazy parsing is better left to specific constructs that require them (such as function bodies and later on class/structs). This removes the only case of significant newline character in the language.
    (user: achavasse size: 2318)

To Artifact [ed761cde06]:

  • File bs/eir/term.h — part of check-in [7d2def7b75] at 2020-12-27 14:40:24 on branch trunk — Renamed "ir" to "eir" (expression intermediate representation) and "llr" to "cir" (code intermediate representation) for clarity. (user: achavasse size: 2330)

1
2


3
4

5
6
7
8
9
10
11


1
2
3

4
5
6
7
8
9
10
11
-
-
+
+

-
+







#ifndef GOOSE_IR_TERM_H
#define GOOSE_IR_TERM_H
#ifndef GOOSE_EIR_TERM_H
#define GOOSE_EIR_TERM_H

namespace goose::ir
namespace goose::eir
{
    class Vector;
    using pvec = ptr< Vector >;

    // We use a distinct type to store locations so that we can handle it differently
    // in the pattern matching algorithms. We consider all LocationId to be equal to one another
    // regardless of their value. This way we can keep it around in IR expessions without having
57
58
59
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
57
58
59
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







-
+




-
+

-
+






-
+


-
-
-
-
-
+
+
+
+
+


    static inline ostream& operator<<( ostream& out, const Term& t )
    {
       return ToString( out, t );
    }

    // A term associated with a location id.
    // Used to represent tokens and tokens/values coming out of the resolver.
    using TermLoc = pair< ir::Term, uint32_t >;
    using TermLoc = pair< eir::Term, uint32_t >;
}

namespace std
{
    template<> struct hash< goose::ir::Hole >
    template<> struct hash< goose::eir::Hole >
    {
        size_t operator()( const goose::ir::Hole& x ) const
        size_t operator()( const goose::eir::Hole& x ) const
        {
            return hash< goose::util::StringId >()( x.name );
        }
    };
}

#define TERM( x )           ir::Term( x )
#define TERM( x )           eir::Term( x )
#define TSTR( x )           TERM( string( x ) )
#define TSID( x )           TERM( #x##_sid )
#define HOLE( x )           TERM( ir::Hole{ x } )
#define ANYTERM( x )        TERM( ir::AnyTerm( #x##_sid ) )
#define VECOFLENGTH( x )    TERM( ir::VecOfLength( #x##_sid ) )
#define VEC( ... )          TERM( ir::Vector::Make( __VA_ARGS__ ) )
#define REPEAT( x )         ir::Repetition( x )
#define HOLE( x )           TERM( eir::Hole{ x } )
#define ANYTERM( x )        TERM( eir::AnyTerm( #x##_sid ) )
#define VECOFLENGTH( x )    TERM( eir::VecOfLength( #x##_sid ) )
#define VEC( ... )          TERM( eir::Vector::Make( __VA_ARGS__ ) )
#define REPEAT( x )         eir::Repetition( x )

#endif