Changeset d76c588 for src/AST/Type.hpp


Ignore:
Timestamp:
May 30, 2019, 4:10:24 PM (5 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
8d70648
Parents:
eba615c
Message:

Stubs for new resolver, implementation of new indexer, type environment

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Type.hpp

    reba615c rd76c588  
    2525#include "Decl.hpp"          // for AggregateDecl subclasses
    2626#include "Fwd.hpp"
    27 #include "Node.hpp"          // for Node, ptr
     27#include "Node.hpp"          // for Node, ptr, ptr_base
    2828#include "TypeVar.hpp"
    2929#include "Visitor.hpp"
     
    5858        virtual bool isVoid() const { return size() == 0; }
    5959        /// Get the i'th component of this type
    60         virtual const Type * getComponent( unsigned i );
     60        virtual const Type * getComponent( unsigned i ) const;
    6161
    6262        /// type without outer pointers and arrays
    63         const Type * stripDeclarator();
     63        const Type * stripDeclarator() const;
    6464        /// type without outer references
    65         const Type * stripReferences();
     65        const Type * stripReferences() const;
    6666        /// number of reference occuring consecutively on the outermost layer of this type
    6767        /// (i.e. do not count references nested within other types)
     
    7575        MUTATE_FRIEND
    7676};
     77
     78/// Set the `is_lvalue` qualifier on this type, cloning only if necessary
     79template< enum Node::ref_type ref_t >
     80void add_lvalue( ptr_base< Type, ref_t > & p ) {
     81        if ( ! p->qualifiers.is_lvalue ) p.get_and_mutate()->qualifiers.is_lvalue = true;
     82}
     83
     84/// Clear the qualifiers on this type, cloning only if necessary
     85template< enum Node::ref_type ref_t >
     86void clear_qualifiers( ptr_base< Type, ref_t > & p ) {
     87        if ( p->qualifiers != CV::Qualifiers{} ) p.get_and_mutate()->qualifiers = CV::Qualifiers{};
     88}
    7789
    7890/// `void`
     
    437449        unsigned size() const override { return types.size(); }
    438450
    439         const Type * getComponent( unsigned i ) override {
     451        const Type * getComponent( unsigned i ) const override {
    440452                assertf( i < size(), "TupleType::getComponent: index %d must be less than size %d",
    441453                        i, size() );
Note: See TracChangeset for help on using the changeset viewer.