aboutsummaryrefslogtreecommitdiff
path: root/src/checker.c
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-06-03 22:27:23 +0100
committerGinger Bill <bill@gingerbill.org>2017-06-03 22:27:23 +0100
commit2c0e59ae064b273899a56cb8d3c53b6967466fa2 (patch)
tree0e1a9dc2ac94b7dfc408166f1cc1e0b921a5aba3 /src/checker.c
parent9d1a4c304a27c0b762809bc3c1d6c70fdb5137be (diff)
`bit_field`; Lexical sugar operators ≠ ≤ ≥
Example below: // See: https://en.wikipedia.org/wiki/Bit_field BoxProps :: bit_field { opaque : 1, fill_colour : 3, _ : 4, show_border : 1, border_colour : 3, border_style : 2, _ : 2, width : 4, height : 4, _ : 8, }
Diffstat (limited to 'src/checker.c')
-rw-r--r--src/checker.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/checker.c b/src/checker.c
index 47842d913..a7f8ec950 100644
--- a/src/checker.c
+++ b/src/checker.c
@@ -126,19 +126,19 @@ gb_global BuiltinProc builtin_procs[BuiltinProc_Count] = {
#include "types.c"
typedef enum AddressingMode {
- Addressing_Invalid, // invalid addressing mode
- Addressing_NoValue, // no value (void in C)
- Addressing_Value, // computed value (rvalue)
- Addressing_Immutable, // immutable computed value (const rvalue)
- Addressing_Variable, // addressable variable (lvalue)
- Addressing_Constant, // constant
- Addressing_Type, // type
- Addressing_Builtin, // built-in procedure
- Addressing_Overload, // overloaded procedure
- Addressing_MapIndex, // map index expression -
- // lhs: acts like a Variable
- // rhs: acts like OptionalOk
- Addressing_OptionalOk, // rhs: acts like a value with an optional boolean part (for existence check)
+ Addressing_Invalid, // invalid addressing mode
+ Addressing_NoValue, // no value (void in C)
+ Addressing_Value, // computed value (rvalue)
+ Addressing_Immutable, // immutable computed value (const rvalue)
+ Addressing_Variable, // addressable variable (lvalue)
+ Addressing_Constant, // constant
+ Addressing_Type, // type
+ Addressing_Builtin, // built-in procedure
+ Addressing_Overload, // overloaded procedure
+ Addressing_MapIndex, // map index expression -
+ // lhs: acts like a Variable
+ // rhs: acts like OptionalOk
+ Addressing_OptionalOk, // rhs: acts like a value with an optional boolean part (for existence check)
} AddressingMode;
// Operand is used as an intermediate value whilst checking
@@ -947,6 +947,9 @@ void add_type_info_type(Checker *c, Type *t) {
return;
}
t = default_type(t);
+ if (is_type_bit_field_value(t)) {
+ t = default_bit_field_value_type(t);
+ }
if (is_type_untyped(t)) {
return; // Could be nil
}
@@ -1200,7 +1203,7 @@ void init_preload(Checker *c) {
- if (record->variant_count != 21) {
+ if (record->variant_count != 22) {
compiler_error("Invalid `TypeInfo` layout");
}
t_type_info_named = record->variants[ 1]->type;
@@ -1223,6 +1226,7 @@ void init_preload(Checker *c) {
t_type_info_union = record->variants[18]->type;
t_type_info_enum = record->variants[19]->type;
t_type_info_map = record->variants[20]->type;
+ t_type_info_bit_field = record->variants[21]->type;
t_type_info_named_ptr = make_type_pointer(c->allocator, t_type_info_named);
t_type_info_integer_ptr = make_type_pointer(c->allocator, t_type_info_integer);
@@ -1244,6 +1248,7 @@ void init_preload(Checker *c) {
t_type_info_union_ptr = make_type_pointer(c->allocator, t_type_info_union);
t_type_info_enum_ptr = make_type_pointer(c->allocator, t_type_info_enum);
t_type_info_map_ptr = make_type_pointer(c->allocator, t_type_info_map);
+ t_type_info_bit_field_ptr = make_type_pointer(c->allocator, t_type_info_bit_field);
}
if (t_allocator == NULL) {