Changeset 2c57025 for src/SynTree


Ignore:
Timestamp:
Nov 25, 2016, 6:11:03 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
0f35657
Parents:
186fd86
Message:

add support for built-in sized trait which decouples size/alignment information from otype parameters, add test for sized trait

Location:
src/SynTree
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/ApplicationExpr.cc

    r186fd86 r2c57025  
    3030        if ( &other == this ) return *this;
    3131        decl = other.decl;
     32        // xxx - this looks like a memory leak
    3233        actualType = maybeClone( other.actualType );
    3334        formalType = maybeClone( other.formalType );
  • src/SynTree/Declaration.h

    r186fd86 r2c57025  
    176176  public:
    177177        enum Kind { Any, Dtype, Ftype };
     178        /// Data extracted from a type decl
     179        struct Data {
     180                TypeDecl::Kind kind;
     181                bool isComplete;
     182                Data() : kind( (TypeDecl::Kind)-1 ), isComplete( false ) {}
     183                Data( TypeDecl * typeDecl ) : Data( typeDecl->get_kind(), typeDecl->isComplete() ) {}
     184                Data( Kind kind, bool isComplete ) : kind( kind ), isComplete( isComplete ) {}
     185                bool operator==(const Data & other) const { return kind == other.kind && isComplete == other.isComplete; }
     186                bool operator!=(const Data & other) const { return !(*this == other);}
     187        };
    178188
    179189        TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind );
     
    182192        Kind get_kind() const { return kind; }
    183193
     194        bool isComplete() const { return kind == Any || sized; }
     195        bool get_sized() const { return sized; }
     196        TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; }
     197
    184198        virtual TypeDecl *clone() const { return new TypeDecl( *this ); }
    185199        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    188202        virtual std::string typeString() const;
    189203        Kind kind;
     204        bool sized;
    190205};
    191206
     
    280295
    281296std::ostream & operator<<( std::ostream & out, const Declaration * decl );
     297std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data );
    282298
    283299#endif // DECLARATION_H
  • src/SynTree/ReferenceToType.cc

    r186fd86 r2c57025  
    128128}
    129129
     130TypeInstType::TypeInstType( const TypeInstType &other ) : Parent( other ), baseType( other.baseType ), isFtype( other.isFtype ) {
     131}
     132
     133
    130134TypeInstType::~TypeInstType() {
    131135        // delete baseType; //This is shared and should not be deleted
  • src/SynTree/Type.h

    r186fd86 r2c57025  
    337337        TypeInstType( const Type::Qualifiers &tq, const std::string &name, TypeDecl *baseType );
    338338        TypeInstType( const Type::Qualifiers &tq, const std::string &name, bool isFtype );
    339         TypeInstType( const TypeInstType &other ) : Parent( other ), baseType( other.baseType ), isFtype( other.isFtype ) {}
     339        TypeInstType( const TypeInstType &other );
    340340        ~TypeInstType();
    341341
  • src/SynTree/TypeDecl.cc

    r186fd86 r2c57025  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // TypeDecl.cc -- 
     7// TypeDecl.cc --
    88//
    99// Author           : Richard C. Bilson
     
    1818#include "Common/utility.h"
    1919
    20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ) : Parent( name, sc, type ), kind( kind ) {
     20TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ) : Parent( name, sc, type ), kind( kind ), sized( kind == Any ) {
    2121}
    2222
    23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ) {
     23TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ), sized( other.sized ) {
    2424}
    2525
     
    2929}
    3030
     31std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) {
     32  return os << data.kind << ", " << data.isComplete;
     33}
     34
    3135// Local Variables: //
    3236// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.