Ignore:
Timestamp:
Mar 26, 2024, 3:17:51 PM (3 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
544b799
Parents:
84886499
Message:

Fused TypeData::Enum and TypeData::Aggregate, an enumeration is a kind of aggregate after all. There will always be some unused fields in Aggregate_t (but less in TypeData? overall) but the code is almost always simpler.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TypeData.h

    r84886499 r67467a3  
    4242        static const char * builtinTypeNames[];
    4343
    44         enum Kind { Basic, Pointer, Reference, Array, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic,
     44        enum Kind { Basic, Pointer, Reference, Array, Function, Aggregate, AggregateInst, EnumConstant, Symbolic,
    4545                                SymbolicInst, Tuple, Basetypeof, Typeof, Vtable, Builtin, GlobalScope, Qualified, Unknown };
    4646
     
    4848                ast::AggregateDecl::Aggregate kind;
    4949                const std::string * name = nullptr;
     50                // Polymorphics parameters. (Polymorphic types only.)
    5051                DeclarationNode * params = nullptr;
    51                 ExpressionNode * actuals = nullptr;                             // holds actual parameters later applied to AggInst
     52                // Arguments later applied to AggInst. (Polymorphic types only.)
     53                ExpressionNode * actuals = nullptr;
     54                // Only set if body is true. (Constants for enumerations.)
    5255                DeclarationNode * fields = nullptr;
    5356                std::vector<ast::ptr<ast::Attribute>> attributes;
     57                // Is this a declaration with a body (may have fields)?
    5458                bool body;
     59                // Is this type anonymous? (Name can still be set to generated name.)
    5560                bool anon;
     61                // Is this a typed enumeration? Type may be stored in base.
     62                bool typed;
     63                EnumHiding hiding;
    5664        };
    5765
     
    6674                bool isVarLen;
    6775                bool isStatic;
    68         };
    69 
    70         struct Enumeration_t {
    71                 const std::string * name = nullptr;
    72                 DeclarationNode * constants = nullptr;
    73                 bool body;
    74                 bool anon;
    75                 bool typed;
    76                 EnumHiding hiding;
    7776        };
    7877
     
    114113        AggInst_t aggInst;
    115114        Array_t array;
    116         Enumeration_t enumeration;
    117115        Function_t function;
    118116        Symbolic_t symbolic;
Note: See TracChangeset for help on using the changeset viewer.