diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-06-26 11:57:26 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-06-26 11:57:26 +0100 |
| commit | c642e326cecd3dc33ca5a9efb6330e757c378dd9 (patch) | |
| tree | c8bd1554fa2fc9e9d31012d4e98261755a7ced3a /src/types.cpp | |
| parent | 362a11878283eea69cf5a18b7f05c964643a7a64 (diff) | |
Undef value `---` (for setting a value to be uninitialized/undefined)
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/types.cpp b/src/types.cpp index 8f645b431..41ce0a19d 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -38,6 +38,7 @@ enum BasicKind { Basic_UntypedString, Basic_UntypedRune, Basic_UntypedNil, + Basic_UntypedUndef, Basic_COUNT, @@ -267,6 +268,7 @@ gb_global Type basic_types[] = { {Type_Basic, {Basic_UntypedString, BasicFlag_String | BasicFlag_Untyped, 0, STR_LIT("untyped string")}}, {Type_Basic, {Basic_UntypedRune, BasicFlag_Integer | BasicFlag_Untyped, 0, STR_LIT("untyped rune")}}, {Type_Basic, {Basic_UntypedNil, BasicFlag_Untyped, 0, STR_LIT("untyped nil")}}, + {Type_Basic, {Basic_UntypedUndef, BasicFlag_Untyped, 0, STR_LIT("untyped undefined")}}, }; // gb_global Type basic_type_aliases[] = { @@ -311,6 +313,7 @@ gb_global Type *t_untyped_complex = &basic_types[Basic_UntypedComplex]; gb_global Type *t_untyped_string = &basic_types[Basic_UntypedString]; gb_global Type *t_untyped_rune = &basic_types[Basic_UntypedRune]; gb_global Type *t_untyped_nil = &basic_types[Basic_UntypedNil]; +gb_global Type *t_untyped_undef = &basic_types[Basic_UntypedUndef]; gb_global Type *t_u8_ptr = NULL; @@ -905,6 +908,10 @@ bool is_type_untyped_nil(Type *t) { t = base_type(t); return (t->kind == Type_Basic && t->Basic.kind == Basic_UntypedNil); } +bool is_type_untyped_undef(Type *t) { + t = base_type(t); + return (t->kind == Type_Basic && t->Basic.kind == Basic_UntypedUndef); +} @@ -1001,6 +1008,11 @@ bool is_type_generic(Type *t) { } +bool type_has_undef(Type *t) { + t = base_type(t); + return true; +} + bool type_has_nil(Type *t) { t = base_type(t); switch (t->kind) { |