Goose  Artifact [510cd93d03]

Artifact 510cd93d037e3e36e1c27db6e102a3972c3a7370df537f34a5ed098b12d24c0c:

  • File bs/builtins/types/basic.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: 1793)

#ifndef GOOSE_BUILTINS_TYPES_BASIC_H
#define GOOSE_BUILTINS_TYPES_BASIC_H

namespace goose::builtins
{
    extern void SetupBasicTypes( Env& e );

    struct ValuePatternT
    {
        static const Term& GetPattern();
    };

    template< typename T >
    struct PatternValueTypeOf
    {
        static const Term& GetPattern()
        {
            static auto pat = GetValueType< T >();
            return pat;
        }
    };

    template< typename T >
    using ValueTypeOf = CustomPattern< Value, PatternValueTypeOf< T > >;
}

namespace goose::ir
{
    template<>
    struct Bridge< void >
    {
        static const Term& Type();
    };

    template<>
    struct Bridge< bool >
    {
        static const Term& Type();
        static Value ToValue( bool x );
        static optional< bool > FromValue( const Value& v );
    };

    template<>
    struct Bridge< BigInt >
    {
        static const Term& Type();

        template< typename T >
        static Value ToValue( T&& x )
        {
            return Value( Type(), TERM( BigInt( forward< T >( x ) ) ) );
        }

        static const BigInt* FromValue( const Value& v );
    };

    template<>
    struct Bridge< char32_t >
    {
        static const Term& Type();
        static Value ToValue( char32_t x );
        static optional< char32_t> FromValue( const Value& v );
    };

    template<>
    struct Bridge< string >
    {
        static const Term& Type();
        static Value ToValue( const string& x );
        static const string* FromValue( const Value& v );
    };

    template<>
    struct Bridge< Value >
    {
        static const Term& Type();
        static const Value& ToValue( const Value& v ) { return v; }
        static const Value* FromValue( const Value& v ) { return &v; }
    };
}

#endif