diff --git a/core/odin/ast/ast.odin b/core/odin/ast/ast.odin index 6570c0128..9c8e50f2e 100644 --- a/core/odin/ast/ast.odin +++ b/core/odin/ast/ast.odin @@ -713,15 +713,6 @@ Enum_Type :: struct { is_using: bool, } -Bit_Field_Type :: struct { - using node: Expr, - tok_pos: tokenizer.Pos, - align: ^Expr, - open: tokenizer.Pos, - fields: []^Field_Value, // Field_Value with ':' rather than '=' - close: tokenizer.Pos, -} - Bit_Set_Type :: struct { using node: Expr, tok_pos: tokenizer.Pos, diff --git a/core/odin/ast/clone.odin b/core/odin/ast/clone.odin index d210d8bd4..2ff37b052 100644 --- a/core/odin/ast/clone.odin +++ b/core/odin/ast/clone.odin @@ -269,8 +269,6 @@ clone_node :: proc(node: ^Node) -> ^Node { case Enum_Type: r.base_type = clone(r.base_type); r.fields = clone(r.fields); - case Bit_Field_Type: - r.fields = clone(r.fields); case Bit_Set_Type: r.elem = clone(r.elem); r.underlying = clone(r.underlying); diff --git a/core/odin/ast/walk.odin b/core/odin/ast/walk.odin index 9abdbffdd..d67cf478e 100644 --- a/core/odin/ast/walk.odin +++ b/core/odin/ast/walk.odin @@ -387,13 +387,6 @@ walk :: proc(v: ^Visitor, node: ^Node) { walk(v, n.base_type); } walk_expr_list(v, n.fields); - case Bit_Field_Type: - if n.align != nil { - walk(v, n.align); - } - for x in n.fields { - walk(v, x); - } case Bit_Set_Type: walk(v, n.elem); if n.underlying != nil { diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index 8e3ecbd4c..fb55b7424 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -415,7 +415,7 @@ is_semicolon_optional_for_node :: proc(p: ^Parser, node: ^ast.Node) -> bool { return is_semicolon_optional_for_node(p, n.type); case ast.Pointer_Type: return is_semicolon_optional_for_node(p, n.elem); - case ast.Struct_Type, ast.Union_Type, ast.Enum_Type, ast.Bit_Field_Type: + case ast.Struct_Type, ast.Union_Type, ast.Enum_Type: // Require semicolon within a procedure body return p.curr_proc == nil; case ast.Proc_Lit: @@ -2538,59 +2538,6 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr { et.close = close.pos; return et; - case .Bit_Field: - tok := expect_token(p, .Bit_Field); - - fields: [dynamic]^ast.Field_Value; - align: ^ast.Expr; - - prev_level := p.expr_level; - p.expr_level = -1; - - for allow_token(p, .Hash) { - tag := expect_token_after(p, .Ident, "#"); - switch tag.text { - case "align": - if align != nil { - error(p, tag.pos, "duplicate bit_field tag '#%s", tag.text); - } - align = parse_expr(p, true); - case: - error(p, tag.pos, "invalid bit_field tag '#%s", tag.text); - } - } - - p.expr_level = prev_level; - - open := expect_token_after(p, .Open_Brace, "bit_field"); - - for p.curr_tok.kind != .Close_Brace && p.curr_tok.kind != .EOF { - name := parse_ident(p); - colon := expect_token(p, .Colon); - value := parse_expr(p, true); - - fv := ast.new(ast.Field_Value, name.pos, value.end); - fv.field = name; - fv.sep = colon.pos; - fv.value = value; - append(&fields, fv); - - if !allow_token(p, .Comma) { - break; - } - } - - close := expect_token(p, .Close_Brace); - - bft := ast.new(ast.Bit_Field_Type, tok.pos, end_pos(close)); - bft.tok_pos = tok.pos; - bft.open = open.pos; - bft.fields = fields[:]; - bft.close = close.pos; - bft.align = align; - - return bft; - case .Bit_Set: tok := expect_token(p, .Bit_Set); open := expect_token(p, .Open_Bracket); @@ -2719,7 +2666,6 @@ is_literal_type :: proc(expr: ^ast.Expr) -> bool { ast.Enum_Type, ast.Dynamic_Array_Type, ast.Map_Type, - ast.Bit_Field_Type, ast.Bit_Set_Type, ast.Call_Expr: return true; diff --git a/core/odin/tokenizer/token.odin b/core/odin/tokenizer/token.odin index 174ae0b1e..1b37bae23 100644 --- a/core/odin/tokenizer/token.odin +++ b/core/odin/tokenizer/token.odin @@ -134,7 +134,6 @@ Token_Kind :: enum u32 { Struct, // struct Union, // union Enum, // enum - Bit_Field, // bit_field Bit_Set, // bit_set Map, // map Dynamic, // dynamic @@ -261,7 +260,6 @@ tokens := [Token_Kind.COUNT]string { "struct", "union", "enum", - "bit_field", "bit_set", "map", "dynamic", diff --git a/src/check_decl.cpp b/src/check_decl.cpp index c41090ecc..8d51edc66 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -201,7 +201,6 @@ bool is_type_distinct(Ast *node) { case Ast_StructType: case Ast_UnionType: case Ast_EnumType: - case Ast_BitFieldType: case Ast_ProcType: return true; diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 42e434f85..25e5550b5 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -10175,7 +10175,6 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type case Ast_MapType: case Ast_OpaqueType: case Ast_BitSetType: - case Ast_BitFieldType: o->mode = Addressing_Type; o->type = check_type(c, node); break; @@ -10594,21 +10593,6 @@ gbString write_expr_to_string(gbString str, Ast *node, bool shorthand) { str = write_expr_to_string(str, at->elem, shorthand); case_end; - case_ast_node(bf, BitFieldType, node); - str = gb_string_appendc(str, "bit_field "); - if (bf->align) { - str = gb_string_appendc(str, "#align "); - str = write_expr_to_string(str, bf->align, shorthand); - } - str = gb_string_appendc(str, "{"); - if (shorthand) { - str = gb_string_appendc(str, "..."); - } else { - str = write_struct_fields_to_string(str, bf->fields); - } - str = gb_string_appendc(str, "}"); - case_end; - case_ast_node(bs, BitSetType, node); str = gb_string_appendc(str, "bit_set["); str = write_expr_to_string(str, bs->elem, shorthand); diff --git a/src/check_type.cpp b/src/check_type.cpp index bf3c72499..df8a54806 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -3517,12 +3517,6 @@ bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, Type *named_t return true; case_end; - case_ast_node(et, BitFieldType, e); - error(e, "'bit_field' types have now been removed"); - error_line("\tSuggestion: package math/bits 'bitfield_extract' and 'bitfield_insert' are better replacements\n"); - return false; - case_end; - case_ast_node(bs, BitSetType, e); *type = alloc_type_bit_set(); set_base_type(named_type, *type); diff --git a/src/checker.cpp b/src/checker.cpp index 98afe38f7..511629447 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -333,7 +333,6 @@ void check_open_scope(CheckerContext *c, Ast *node) { case Ast_StructType: case Ast_EnumType: case Ast_UnionType: - case Ast_BitFieldType: case Ast_BitSetType: scope->flags |= ScopeFlag_Type; break; diff --git a/src/parser.cpp b/src/parser.cpp index 834aa664d..a833c6d25 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -100,7 +100,6 @@ Token ast_token(Ast *node) { case Ast_StructType: return node->StructType.token; case Ast_UnionType: return node->UnionType.token; case Ast_EnumType: return node->EnumType.token; - case Ast_BitFieldType: return node->BitFieldType.token; case Ast_BitSetType: return node->BitSetType.token; case Ast_MapType: return node->MapType.token; } @@ -417,10 +416,6 @@ Ast *clone_ast(Ast *node) { n->EnumType.base_type = clone_ast(n->EnumType.base_type); n->EnumType.fields = clone_ast_array(n->EnumType.fields); break; - case Ast_BitFieldType: - n->BitFieldType.fields = clone_ast_array(n->BitFieldType.fields); - n->BitFieldType.align = clone_ast(n->BitFieldType.align); - break; case Ast_BitSetType: n->BitSetType.elem = clone_ast(n->BitSetType.elem); n->BitSetType.underlying = clone_ast(n->BitSetType.underlying); @@ -1054,14 +1049,6 @@ Ast *ast_enum_type(AstFile *f, Token token, Ast *base_type, Array const & return result; } -Ast *ast_bit_field_type(AstFile *f, Token token, Array const &fields, Ast *align) { - Ast *result = alloc_ast_node(f, Ast_BitFieldType); - result->BitFieldType.token = token; - result->BitFieldType.fields = slice_from_array(fields); - result->BitFieldType.align = align; - return result; -} - Ast *ast_bit_set_type(AstFile *f, Token token, Ast *elem, Ast *underlying) { Ast *result = alloc_ast_node(f, Ast_BitSetType); result->BitSetType.token = token; @@ -1509,7 +1496,6 @@ bool is_semicolon_optional_for_node(AstFile *f, Ast *s) { case Ast_StructType: case Ast_UnionType: case Ast_EnumType: - case Ast_BitFieldType: // Require semicolon within a procedure body return f->curr_proc == nullptr; case Ast_ProcLit: @@ -2369,51 +2355,6 @@ Ast *parse_operand(AstFile *f, bool lhs) { return ast_enum_type(f, token, base_type, values); } break; - case Token_bit_field: { - Token token = expect_token(f, Token_bit_field); - auto fields = array_make(heap_allocator()); - Ast *align = nullptr; - Token open, close; - - isize prev_level = f->expr_level; - f->expr_level = -1; - - while (allow_token(f, Token_Hash)) { - Token tag = expect_token_after(f, Token_Ident, "#"); - if (tag.string == "align") { - if (align) { - syntax_error(tag, "Duplicate bit_field tag '#%.*s'", LIT(tag.string)); - } - align = parse_expr(f, true); - } else { - syntax_error(tag, "Invalid bit_field tag '#%.*s'", LIT(tag.string)); - } - } - - f->expr_level = prev_level; - - open = expect_token_after(f, Token_OpenBrace, "bit_field"); - - while (f->curr_token.kind != Token_EOF && - f->curr_token.kind != Token_CloseBrace) { - Ast *name = parse_ident(f); - Token colon = expect_token(f, Token_Colon); - Ast *value = parse_expr(f, true); - - Ast *field = ast_field_value(f, name, value, colon); - array_add(&fields, field); - - if (f->curr_token.kind != Token_Comma) { - break; - } - advance_token(f); - } - - close = expect_token(f, Token_CloseBrace); - - return ast_bit_field_type(f, token, fields, align); - } break; - case Token_bit_set: { Token token = expect_token(f, Token_bit_set); expect_token(f, Token_OpenBracket); @@ -2524,7 +2465,6 @@ bool is_literal_type(Ast *node) { case Ast_EnumType: case Ast_DynamicArrayType: case Ast_MapType: - case Ast_BitFieldType: case Ast_BitSetType: case Ast_CallExpr: return true; diff --git a/src/parser.hpp b/src/parser.hpp index b038b3b45..f4a642de8 100644 --- a/src/parser.hpp +++ b/src/parser.hpp @@ -594,11 +594,6 @@ AST_KIND(_TypeBegin, "", bool) \ Slice fields; /* FieldValue */ \ bool is_using; \ }) \ - AST_KIND(BitFieldType, "bit field type", struct { \ - Token token; \ - Slice fields; /* FieldValue with : */ \ - Ast * align; \ - }) \ AST_KIND(BitSetType, "bit set type", struct { \ Token token; \ Ast * elem; \ diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 3ef1e19fe..4dc1f1d51 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -102,7 +102,6 @@ TOKEN_KIND(Token__KeywordBegin, ""), \ TOKEN_KIND(Token_struct, "struct"), \ TOKEN_KIND(Token_union, "union"), \ TOKEN_KIND(Token_enum, "enum"), \ - TOKEN_KIND(Token_bit_field, "bit_field"), \ TOKEN_KIND(Token_bit_set, "bit_set"), \ TOKEN_KIND(Token_map, "map"), \ TOKEN_KIND(Token_dynamic, "dynamic"), \