Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Type.h

    rea6332d r5ccb10d  
    1616#pragma once
    1717
    18 #include <strings.h>         // for ffs
    19 #include <cassert>           // for assert, assertf
    20 #include <list>              // for list, _List_iterator
    21 #include <ostream>           // for ostream, operator<<, basic_ostream
    22 #include <string>            // for string
    23 
    24 #include "BaseSyntaxNode.h"  // for BaseSyntaxNode
    25 #include "Common/utility.h"  // for operator+
    26 #include "Mutator.h"         // for Mutator
    27 #include "SynTree.h"         // for AST nodes
    28 #include "Visitor.h"         // for Visitor
     18#include "BaseSyntaxNode.h"
     19#include "Mutator.h"
     20#include "SynTree.h"
     21#include "Visitor.h"
     22#include <strings.h>                                                                    // ffs
    2923
    3024class Type : public BaseSyntaxNode {
     
    168162
    169163        /// return type without outer pointers and arrays
    170         Type *stripDeclarator();
     164        Type * stripDeclarator();
     165
     166        /// return type without outer references
     167        Type * stripReferences();
     168
     169        /// return the number of references occuring consecutively on the outermost layer of this type (i.e. do not count references nested within other types)
     170        virtual int referenceDepth() const;
    171171
    172172        virtual bool isComplete() const { return true; }
     
    262262        bool is_array() const { return isStatic || isVarLen || dimension; }
    263263
     264        virtual bool isComplete() const { return ! isVarLen; }
     265
    264266        virtual PointerType *clone() const { return new PointerType( *this ); }
    265267        virtual void accept( Visitor & v ) { v.visit( this ); }
     
    296298};
    297299
     300class ReferenceType : public Type {
     301public:
     302        Type *base;
     303
     304        ReferenceType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     305        ReferenceType( const ReferenceType & );
     306        virtual ~ReferenceType();
     307
     308        Type *get_base() { return base; }
     309        void set_base( Type *newValue ) { base = newValue; }
     310
     311        virtual int referenceDepth() const;
     312
     313        // Since reference types act like value types, their size is the size of the base.
     314        // This makes it simple to cast the empty tuple to a reference type, since casts that increase
     315        // the number of values are disallowed.
     316        virtual unsigned size() const { return base->size(); }
     317
     318        virtual ReferenceType *clone() const { return new ReferenceType( *this ); }
     319        virtual void accept( Visitor & v ) { v.visit( this ); }
     320        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     321        virtual void print( std::ostream & os, int indent = 0 ) const;
     322};
     323
    298324class FunctionType : public Type {
    299325  public:
Note: See TracChangeset for help on using the changeset viewer.