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...
 
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)
 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)
 

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 52 of file TypeChecker.hpp.

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

◆ displayContract()

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

◆ generateError()

void Ark::types::generateError ( const std::string_view & funcname,
const std::vector< Contract > & contracts,
const std::vector< Value > & args )

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

Definition at line 87 of file TypeChecker.cpp.

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

Referenced by Ark::helper::head(), Ark::VM::safeRun(), and Ark::helper::tail().

◆ 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().