Changeset 361bf01 for src/AST/Type.hpp


Ignore:
Timestamp:
Dec 11, 2020, 11:20:45 PM (4 years ago)
Author:
Fangren Yu <f37yu@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
5b9a0ae
Parents:
a6e0e4c
Message:

remove ParameterizedType? and put content into FunctionType?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Type.hpp

    ra6e0e4c r361bf01  
    267267};
    268268
    269 /// Base type for potentially forall-qualified types
    270 class ParameterizedType : public Type {
    271 protected:
    272         /// initializes forall with substitutor
    273         void initWithSub( const ParameterizedType & o, Pass< ForallSubstitutor > & sub );
    274 public:
    275         using ForallList = std::vector<ptr<TypeDecl>>;
    276 
    277         ForallList forall;
    278 
    279         ParameterizedType( ForallList&& fs = {}, CV::Qualifiers q = {},
    280                 std::vector<ptr<Attribute>> && as = {} )
    281         : Type(q, std::move(as)), forall(std::move(fs)) {}
    282 
    283         ParameterizedType( CV::Qualifiers q, std::vector<ptr<Attribute>> && as = {} )
    284         : Type(q, std::move(as)), forall() {}
    285 
    286         // enforce use of ForallSubstitutor to copy parameterized type
    287         ParameterizedType( const ParameterizedType & ) = delete;
    288 
    289         ParameterizedType( ParameterizedType && ) = default;
    290 
    291         // no need to change destructor, and operator= deleted in Node
    292 
    293 private:
    294         virtual ParameterizedType * clone() const override = 0;
    295         MUTATE_FRIEND
    296 };
    297 
    298269/// Function variable arguments flag
    299270enum ArgumentFlag { FixedArgs, VariableArgs };
    300271
    301272/// Type of a function `[R1, R2](*)(P1, P2, P3)`
    302 class FunctionType final : public ParameterizedType {
    303 public:
     273class FunctionType final : public Type {
     274        protected:
     275        /// initializes forall with substitutor
     276        void initWithSub( const FunctionType & o, Pass< ForallSubstitutor > & sub );
     277public:
     278        using ForallList = std::vector<ptr<TypeDecl>>;
     279        ForallList forall;
     280
    304281        std::vector<ptr<Type>> returns;
    305282        std::vector<ptr<Type>> params;
     
    313290
    314291        FunctionType( ArgumentFlag va = FixedArgs, CV::Qualifiers q = {} )
    315         : ParameterizedType(q), returns(), params(), isVarArgs(va) {}
     292        : Type(q), returns(), params(), isVarArgs(va) {}
    316293
    317294        FunctionType( const FunctionType & o );
     
    329306
    330307/// base class for types that refer to types declared elsewhere (aggregates and typedefs)
    331 class BaseInstType : public ParameterizedType {
    332 protected:
    333         /// Initializes forall and parameters based on substitutor
    334         void initWithSub( const BaseInstType & o, Pass< ForallSubstitutor > & sub );
     308class BaseInstType : public Type {
    335309public:
    336310        std::vector<ptr<Expr>> params;
     
    340314        BaseInstType(
    341315                const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} )
    342         : ParameterizedType(q, std::move(as)), params(), name(n) {}
     316        : Type(q, std::move(as)), params(), name(n) {}
    343317
    344318        BaseInstType(
    345319                const std::string& n, std::vector<ptr<Expr>> && params,
    346320                CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} )
    347         : ParameterizedType(q, std::move(as)), params(std::move(params)), name(n) {}
    348 
    349         BaseInstType( const BaseInstType & o );
     321        : Type(q, std::move(as)), params(std::move(params)), name(n) {}
     322
     323        BaseInstType( const BaseInstType & o ) = default;
    350324
    351325        /// Gets aggregate declaration this type refers to
     
    433407        : BaseInstType( n, q, std::move(as) ), base(), kind( k ) {}
    434408
    435         TypeInstType( const TypeInstType & o );
     409        TypeInstType( const TypeInstType & o ) = default;
    436410
    437411        /// sets `base`, updating `kind` correctly
Note: See TracChangeset for help on using the changeset viewer.