mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-07 07:28:45 +00:00
function type
This commit is contained in:
parent
7f3dfd71a1
commit
fa01d36a84
10 changed files with 87 additions and 64 deletions
|
|
@ -13,6 +13,8 @@ const static std::string TUPLE_IDENTIFIER = "Tuple";
|
|||
|
||||
const static std::string VARIANT_IDENTIFIER = "Variant";
|
||||
|
||||
const static std::string FUNCTION_IDENTIFIER = "Function";
|
||||
|
||||
const static std::string ARRAY_IDENTIFIER = "Array";
|
||||
|
||||
const static std::string OPTIONAL_IDENTIFIER = "Optional";
|
||||
|
|
@ -50,6 +52,7 @@ enum class Type {
|
|||
// -- containers
|
||||
TUPLE,
|
||||
VARIANT,
|
||||
FUNCTION,
|
||||
ARRAY,
|
||||
OPTIONAL,
|
||||
RESULT,
|
||||
|
|
@ -75,6 +78,8 @@ inline std::string to_string(Type type) {
|
|||
return TUPLE_IDENTIFIER;
|
||||
case Type::VARIANT:
|
||||
return VARIANT_IDENTIFIER;
|
||||
case Type::FUNCTION:
|
||||
return FUNCTION_IDENTIFIER;
|
||||
case Type::ARRAY:
|
||||
return ARRAY_IDENTIFIER;
|
||||
case Type::OPTIONAL:
|
||||
|
|
@ -118,6 +123,7 @@ inline Type to_type(const std::string &str) {
|
|||
// -- containers
|
||||
builtin_types[TUPLE_IDENTIFIER] = Type::TUPLE;
|
||||
builtin_types[VARIANT_IDENTIFIER] = Type::VARIANT;
|
||||
builtin_types[FUNCTION_IDENTIFIER] = Type::FUNCTION;
|
||||
builtin_types[ARRAY_IDENTIFIER] = Type::ARRAY;
|
||||
builtin_types[OPTIONAL_IDENTIFIER] = Type::OPTIONAL;
|
||||
builtin_types[RESULT_IDENTIFIER] = Type::RESULT;
|
||||
|
|
@ -161,6 +167,7 @@ inline std::optional<size_t> get_parameters_count(Type type) {
|
|||
// -- containers
|
||||
case Type::TUPLE:
|
||||
case Type::VARIANT:
|
||||
case Type::FUNCTION:
|
||||
return std::nullopt;
|
||||
case Type::ARRAY:
|
||||
case Type::OPTIONAL:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue