ArkScript
A small, fast, functional and scripting language for video games
Ark::types Namespace Reference

Namespaces

namespace  details
 

Classes

struct  Contract
 A contract is a list of typed arguments that a function can follow. More...
 
class  TypeCheckingError
 
struct  Typedef
 A type definition within a contract. More...
 

Functions

template<typename... Ts, typename = details::AllSame<ValueType, Ts...>>
bool check (const std::vector< Value > &args, Ts... types)
 Helper to see if a builtin has been given a wanted set of types.
 
ARK_API void generateError (const std::string_view &funcname, const std::vector< Contract > &contracts, const std::vector< Value > &args, std::ostream &os=std::cout, bool colorize=true)
 Generate an error message based on a given set of types contracts provided argument list.
 
std::string typeListToString (const std::vector< ValueType > &types)
 
void displayContract (const Contract &contract, const std::vector< Value > &args, std::ostream &os, const bool colorize)
 

Function Documentation

◆ check()

template<typename... Ts, typename = details::AllSame<ValueType, Ts...>>
bool Ark::types::check ( const std::vector< Value > & args,
Ts... types )
nodiscard

Helper to see if a builtin has been given a wanted set of types.

Template Parameters
TsVariadic argument list composed of ValueTypes
Parameters
argsarguments passed to the function
typesaccepted types
Returns
true if the contract is respected
false otherwise

Definition at line 54 of file TypeChecker.hpp.

References Ark::types::details::checkN().

◆ displayContract()

void Ark::types::displayContract ( const Contract & contract,
const std::vector< Value > & args,
std::ostream & os,
const bool colorize )

◆ generateError()

void Ark::types::generateError ( const std::string_view & funcname,
const std::vector< Contract > & contracts,
const std::vector< Value > & args,
std::ostream & os = std::cout,
bool colorize = true )

Generate an error message based on a given set of types contracts provided argument list.

Parameters
funcnameArkScript name of the function
contractstypes contracts the function can follow
argsprovided argument list
osoutput stream, default to cout
colorizeenable output colorizing

Definition at line 110 of file TypeChecker.cpp.

References displayContract(), Ark::Undefined, and Ark::Value::valueType().

Referenced by Ark::types::TypeCheckingError::details().

◆ typeListToString()

std::string Ark::types::typeListToString ( const std::vector< ValueType > & types)

Definition at line 12 of file TypeChecker.cpp.

References Ark::Any, and Ark::types_to_str.

Referenced by displayContract().