Goose  Diff

Differences From Artifact [6cf9ea1568]:

  • File bs/g0api/extensibility/term.cpp — part of check-in [13e21deeef] at 2021-09-12 21:38:03 on branch trunk —
    • Fixed TermRef
    • Began implementing the api to manipulate the EIR
    (user: achavasse size: 6456)

To Artifact [6cf8d326a8]:

  • File bs/g0api/extensibility/eir.cpp — part of check-in [51f288ba2a] at 2021-09-13 21:52:06 on branch trunk —
    • Implemented a generic wrapper for the simple native types that can be embedded in Terms
    • Added more specific overloads for the assignment operator that should work only on builtin types, so that library and user defined types will be able to choose whether they're copyable
    • The EIR representation for all builtin runtime types are now prefixed with "rt_type" to more easily write generic matching rules against them
    • EIR: Fixed long standing bugs in Enumerate and Decompose that surfaced because of the above
    • Miscellaneous code cleaning
    (user: achavasse size: 6396)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "g0api/g0api.h"
#include "eir/eir.h"
#include "parse/parse.h"
#include "builtins/helpers.h"

using namespace goose;
using namespace goose::parse;
using namespace goose::builtins;

namespace goose::g0api
{
    void SetupTermExtensibilityFuncs( Env& e )
    {
        // Constants.
        DefineConstant( e, "DelimiterOpenParen"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( Delimiter::OpenParen ) ) ) );
        DefineConstant( e, "DelimiterOpenBrace"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( Delimiter::OpenBrace ) ) ) );
        DefineConstant( e, "DelimiterOpenBracket"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( Delimiter::OpenBracket ) ) ) );
        DefineConstant( e, "DelimiterCloseParen"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( Delimiter::CloseParen ) ) ) );
        DefineConstant( e, "DelimiterCloseBrace"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( Delimiter::CloseBrace ) ) ) );











|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "g0api/g0api.h"
#include "eir/eir.h"
#include "parse/parse.h"
#include "builtins/helpers.h"

using namespace goose;
using namespace goose::parse;
using namespace goose::builtins;

namespace goose::g0api
{
    void SetupEIRExtensibilityFuncs( Env& e )
    {
        // Constants.
        DefineConstant( e, "DelimiterOpenParen"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( Delimiter::OpenParen ) ) ) );
        DefineConstant( e, "DelimiterOpenBrace"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( Delimiter::OpenBrace ) ) ) );
        DefineConstant( e, "DelimiterOpenBracket"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( Delimiter::OpenBracket ) ) ) );
        DefineConstant( e, "DelimiterCloseParen"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( Delimiter::CloseParen ) ) ) );
        DefineConstant( e, "DelimiterCloseBrace"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( Delimiter::CloseBrace ) ) ) );
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
            VecOfLength,
            Vec,
            BigInt,
            FixedInt,
            Internal
        };

        // These must match the order of the Term variant.
        DefineConstant( e, "TermTypeUInt32"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::UInt32 ) ) ) );
        DefineConstant( e, "TermTypeLocationId"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::LocationId ) ) ) );
        DefineConstant( e, "TermTypeString"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::String ) ) ) );
        DefineConstant( e, "TermTypeStringId"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::StringId ) ) ) );
        DefineConstant( e, "TermTypeDelimiter"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::Delimiter ) ) ) );
        DefineConstant( e, "TermTypeHole"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::Hole ) ) ) );
        DefineConstant( e, "TermTypeAnyTerm"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::AnyTerm ) ) ) );







<







32
33
34
35
36
37
38

39
40
41
42
43
44
45
            VecOfLength,
            Vec,
            BigInt,
            FixedInt,
            Internal
        };


        DefineConstant( e, "TermTypeUInt32"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::UInt32 ) ) ) );
        DefineConstant( e, "TermTypeLocationId"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::LocationId ) ) ) );
        DefineConstant( e, "TermTypeString"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::String ) ) ) );
        DefineConstant( e, "TermTypeStringId"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::StringId ) ) ) );
        DefineConstant( e, "TermTypeDelimiter"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::Delimiter ) ) ) );
        DefineConstant( e, "TermTypeHole"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::Hole ) ) ) );
        DefineConstant( e, "TermTypeAnyTerm"_sid, ValueToEIR( ToValue( static_cast< uint8_t >( TermType::AnyTerm ) ) ) );