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

Namespaces

 details
 

Classes

struct  Typedef
 A type definition within a contract. More...
 
struct  Contract
 A contract is a list of typed arguments that a function can follow. 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. More...
 
ARK_API void generateError (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. More...
 
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 
)

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

◆ displayContract()

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

◆ generateError()

void Ark::types::generateError ( 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 82 of file TypeChecker.cpp.

References displayContract().

Referenced by Ark::VM::safeRun().

◆ typeListToString()

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

Definition at line 13 of file TypeChecker.cpp.

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

Referenced by displayContract().