Goose  Artifact [6e91002f65]

Artifact 6e91002f6516d775f5fecfea3ee31ad8be401e82035950a19b80d051ffbf969a:

  • File bs/builtins/helpers.h — part of check-in [af650a9e95] at 2019-09-22 14:37:55 on branch trunk — Project renaming. (user: achavasse size: 1076)

#ifndef GOOSE_BUILTINS_HELPERS_H
#define GOOSE_BUILTINS_HELPERS_H

#include "parse/parse.h"

namespace goose::builtins
{
    extern void RegisterRule( sema::Env& env, const StringId& name, parse::Rule&& rule );
    extern void RegisterVerificationRule( sema::Env& env, const StringId& name, parse::Rule&& rule );

    // Utility function used to parse flow control statements, such as if and loops.
    // This parses a sub statement, which can be enclosed in a brace block or not.
    // It will get its own scope, with visibility rules setup to see the current
    // scope.
    // It returns a pointer to the final basic block generated by the statement.
    ptr< llr::BasicBlock > ParseSubStatement( parse::Parser& p, uint32_t precedence );

    enum class ValUnifyError
    {
        NoSolution,
        Ambiguous
    };

    // Unify the provided value with a value placeholder of the specified type,
    // and return the result or an error code.
    variant< Value, ValUnifyError > ConvertValueToType( const Context& c, const Value& val, const Term& type );
}

#endif