Ignore:
Timestamp:
Nov 8, 2023, 2:01:11 PM (10 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
3e4bf0d, f5ec35a
Parents:
790d835
Message:

Remove BaseSyntaxNode? and clean-up.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/GenPoly.h

    r790d835 rc6b4432  
    2323#include "AST/Fwd.hpp"            // for ApplicationExpr, BaseInstType, Func...
    2424#include "SymTab/Mangler.h"       // for Mangler
    25 #include "SynTree/Declaration.h"  // for TypeDecl::Data, AggregateDecl, Type...
    26 #include "SynTree/SynTree.h"      // for Visitor Nodes
    2725
    2826namespace ast {
     
    3230namespace GenPoly {
    3331
    34         typedef ErasableScopedMap< std::string, TypeDecl::Data > TyVarMap;
    3532        struct TypeVarMap : public ErasableScopedMap<ast::TypeEnvKey, ast::TypeData> {
    3633                TypeVarMap() : ErasableScopedMap( ast::TypeData() ) {}
     
    3835
    3936        /// Replaces a TypeInstType by its referrent in the environment, if applicable
    40         Type* replaceTypeInst( Type* type, const TypeSubstitution* env );
    41         const Type* replaceTypeInst( const Type* type, const TypeSubstitution* env );
    4237        const ast::Type * replaceTypeInst( const ast::Type *, const ast::TypeSubstitution * );
    4338
    4439        /// returns polymorphic type if is polymorphic type, NULL otherwise; will look up substitution in env if provided
    45         Type *isPolyType( Type *type, const TypeSubstitution *env = 0 );
    4640        const ast::Type * isPolyType(const ast::Type * type, const ast::TypeSubstitution * env = nullptr);
    4741
    4842        /// returns polymorphic type if is polymorphic type in tyVars, NULL otherwise; will look up substitution in env if provided
    49         Type *isPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
    5043        const ast::Type * isPolyType( const ast::Type * type, const TypeVarMap & typeVars, const ast::TypeSubstitution * subst = nullptr );
    5144
    5245        /// returns dynamic-layout type if is dynamic-layout type in tyVars, NULL otherwise; will look up substitution in env if provided
    53         ReferenceToType *isDynType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
    5446        const ast::BaseInstType *isDynType( const ast::Type * type, const TypeVarMap & typeVars, const ast::TypeSubstitution * subst = 0 );
    5547
    5648        /// true iff function has dynamic-layout return type under the given type variable map
    57         ReferenceToType *isDynRet( FunctionType *function, const TyVarMap &tyVars );
    5849        const ast::BaseInstType *isDynRet( const ast::FunctionType * type, const TypeVarMap & typeVars );
    5950
    6051        /// true iff function has dynamic-layout return type under the type variable map generated from its forall-parameters
    61         ReferenceToType *isDynRet( FunctionType *function );
    6252        const ast::BaseInstType *isDynRet( const ast::FunctionType * func );
    6353
    6454        /// A function needs an adapter if it returns a dynamic-layout value or if any of its parameters have dynamic-layout type
    65         bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVarr );
    6655        bool needsAdapter( ast::FunctionType const * adaptee, const TypeVarMap & typeVars );
    6756
    68         /// returns polymorphic type if is pointer to polymorphic type, NULL otherwise; will look up substitution in env if provided
    69         Type *isPolyPtr( Type *type, const TypeSubstitution *env = 0 );
    70 
    7157        /// returns polymorphic type if is pointer to polymorphic type in tyVars, NULL otherwise; will look up substitution in env if provided
    72         Type *isPolyPtr( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
    7358        const ast::Type * isPolyPtr( const ast::Type * type, const TypeVarMap & typeVars, const ast::TypeSubstitution * env = 0 );
    74 
    75         /// if the base type (after dereferencing N >= 0 pointers) is a polymorphic type, returns the base type, NULL otherwise;
    76         /// N will be stored in levels, if provided, will look up substitution in env if provided
    77         Type *hasPolyBase( Type *type, int *levels = 0, const TypeSubstitution *env = 0 );
    7859
    7960        /// if the base type (after dereferencing N >= 0 pointers) is a polymorphic type in tyVars, returns the base type, NULL otherwise;
    8061        /// N will be stored in levels, if provided, will look up substitution in env if provided
    81         Type *hasPolyBase( Type *type, const TyVarMap &tyVars, int *levels = 0, const TypeSubstitution *env = 0 );
    8262        const ast::Type * hasPolyBase( const ast::Type * type, const TypeVarMap & typeVars, int * levels = 0, const ast::TypeSubstitution * env = 0 );
    8363
    84         /// true iff this type or some base of this type after dereferencing pointers is either polymorphic or a generic type with at least one
    85         /// polymorphic parameter; will look up substitution in env if provided.
    86         bool includesPolyType( Type *type, const TypeSubstitution *env = 0 );
    87 
    88         /// true iff this type or some base of this type after dereferencing pointers is either polymorphic in tyVars, or a generic type with
    89         /// at least one polymorphic parameter in tyVars; will look up substitution in env if provided.
    90         bool includesPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
    91 
    9264        /// Returns a pointer to the base FunctionType if ty is the type of a function (or pointer to one), NULL otherwise
    93         FunctionType *getFunctionType( Type *ty );
    9465        const ast::FunctionType * getFunctionType( const ast::Type * ty );
    9566
    96         /// If expr (after dereferencing N >= 0 pointers) is a variable expression, returns the variable expression, NULL otherwise;
    97         /// N will be stored in levels, if provided
    98         VariableExpr *getBaseVar( Expression *expr, int *levels = 0 );
    99 
    10067        /// true iff types are structurally identical, where TypeInstType's match any type.
    101         bool typesPolyCompatible( Type *aty, Type *bty );
    10268        bool typesPolyCompatible( ast::Type const * lhs, ast::Type const * rhs );
    10369
    10470        /// true if arg requires boxing given exprTyVars
    105         bool needsBoxing( Type * param, Type * arg, const TyVarMap &exprTyVars, const TypeSubstitution * env );
    10671        bool needsBoxing( const ast::Type * param, const ast::Type * arg, const TypeVarMap & typeVars, const ast::TypeSubstitution * subst );
    10772
    10873        /// true if arg requires boxing in the call to appExpr
    109         bool needsBoxing( Type * param, Type * arg, ApplicationExpr * appExpr, const TypeSubstitution * env );
    11074        bool needsBoxing( const ast::Type * param, const ast::Type * arg, const ast::ApplicationExpr * expr, const ast::TypeSubstitution * subst );
    11175
    11276        /// Adds the type variable `tyVar` to `tyVarMap`
    113         void addToTyVarMap( TypeDecl * tyVar, TyVarMap &tyVarMap );
    11477        void addToTypeVarMap( const ast::TypeDecl * type, TypeVarMap & typeVars );
    11578        void addToTypeVarMap( const ast::TypeInstType * type, TypeVarMap & typeVars );
    11679
    11780        /// Adds the declarations in the forall list of type (and its pointed-to type if it's a pointer type) to `tyVarMap`
    118         void makeTyVarMap( Type *type, TyVarMap &tyVarMap );
    11981        void makeTypeVarMap( const ast::Type * type, TypeVarMap & typeVars );
    12082        void makeTypeVarMap( const ast::FunctionDecl * decl, TypeVarMap & typeVars );
    121 
    122         /// Prints type variable map
    123         void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap );
    124 
    125         /// Gets the mangled name of this type; alias for SymTab::Mangler::mangleType().
    126         inline std::string mangleType( const Type *ty ) { return SymTab::Mangler::mangleType( ty ); }
    12783
    12884        /// Gets the name of the sizeof parameter for the type, given its mangled name
     
    13692
    13793        /// Gets the name of the layout function for a given aggregate type, given its declaration
    138         inline std::string layoutofName( AggregateDecl *decl ) { return std::string( "_layoutof_" ) + decl->get_name(); }
    13994        inline std::string layoutofName( ast::AggregateDecl const * decl ) {
    14095                return std::string( "_layoutof_" ) + decl->name;
Note: See TracChangeset for help on using the changeset viewer.