Goose  Artifact [edac06ac27]

Artifact edac06ac2776baf7501cd1a8d4d36b2e3bc01d0a0a710351354ced3b822a5a43:

  • File bs/builtins/helpers.h — part of check-in [4fe418f4d0] at 2019-09-26 23:37:51 on branch trunk — Refactored the parsing of verification statements so that it works properly in all cases (regular functions, template functions, function type expressions, lambdas). (user: achavasse size: 974)

#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 );

    // 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