Changeset 4f748c5 for src/SynTree


Ignore:
Timestamp:
Nov 2, 2017, 11:45:10 AM (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:
6de43b6
Parents:
b1e68d03 (diff), fde89cf6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'fix-missing-cast-warning'

Location:
src/SynTree
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/ApplicationExpr.cc

    rb1e68d03 r4f748c5  
    5959
    6060ApplicationExpr::ApplicationExpr( const ApplicationExpr &other ) :
    61                 Expression( other ), function( maybeClone( other.function ) ), inferParams( other.inferParams ) {
     61                Expression( other ), function( maybeClone( other.function ) ) {
    6262        cloneAll( other.args, args );
    6363}
     
    6666        delete function;
    6767        deleteAll( args );
    68 }
    69 
    70 void printInferParams( const InferredParams & inferParams, std::ostream &os, Indenter indent, int level ) {
    71         if ( ! inferParams.empty() ) {
    72                 os << indent << "with inferred parameters " << level << ":" << std::endl;
    73                 for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) {
    74                         os << indent+1;
    75                         Declaration::declFromId( i->second.decl )->printShort( os, indent+1 );
    76                         os << std::endl;
    77                         printInferParams( *i->second.inferParams, os, indent+1, level+1 );
    78                 } // for
    79         } // if
    8068}
    8169
     
    8876                printAll( args, os, indent+1 );
    8977        } // if
    90         printInferParams( inferParams, os, indent+1, 0 );
    9178        Expression::print( os, indent );
    9279}
  • src/SynTree/Declaration.h

    rb1e68d03 r4f748c5  
    200200        typedef NamedTypeDecl Parent;
    201201  public:
    202         enum Kind { Any, Dtype, Ftype, Ttype };
     202        enum Kind { Dtype, Ftype, Ttype };
    203203
    204204        Type * init;
     
    216216        };
    217217
    218         TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init = nullptr );
     218        TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init = nullptr );
    219219        TypeDecl( const TypeDecl &other );
    220220        virtual ~TypeDecl();
     
    225225        TypeDecl * set_init( Type * newValue ) { init = newValue; return this; }
    226226
    227         bool isComplete() const { return kind == Any || sized; }
     227        bool isComplete() const { return sized; }
    228228        bool get_sized() const { return sized; }
    229229        TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; }
  • src/SynTree/Expression.cc

    rb1e68d03 r4f748c5  
    3333#include "GenPoly/Lvalue.h"
    3434
     35void printInferParams( const InferredParams & inferParams, std::ostream &os, Indenter indent, int level ) {
     36        if ( ! inferParams.empty() ) {
     37                os << indent << "with inferred parameters " << level << ":" << std::endl;
     38                for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) {
     39                        os << indent+1;
     40                        Declaration::declFromId( i->second.decl )->printShort( os, indent+1 );
     41                        os << std::endl;
     42                        printInferParams( *i->second.inferParams, os, indent+1, level+1 );
     43                } // for
     44        } // if
     45}
     46
    3547Expression::Expression() : result( 0 ), env( 0 ) {}
    3648
    37 Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ) {
     49Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ), inferParams( other.inferParams ) {
    3850}
    3951
     
    4456
    4557void Expression::print( std::ostream &os, Indenter indent ) const {
     58        printInferParams( inferParams, os, indent+1, 0 );
     59
    4660        if ( env ) {
    4761                os << std::endl << indent << "... with environment:" << std::endl;
  • src/SynTree/Expression.h

    rb1e68d03 r4f748c5  
    3131
    3232
    33 /// Expression is the root type for all expressions
    34 class Expression : public BaseSyntaxNode{
    35   public:
    36         Type * result;
    37         TypeSubstitution * env;
    38         bool extension = false;
    39 
    40         Expression();
    41         Expression( const Expression & other );
    42         virtual ~Expression();
    43 
    44         Type *& get_result() { return result; }
    45         const Type * get_result() const { return result; }
    46         void set_result( Type * newValue ) { result = newValue; }
    47 
    48         TypeSubstitution * get_env() const { return env; }
    49         void set_env( TypeSubstitution * newValue ) { env = newValue; }
    50         bool get_extension() const { return extension; }
    51         Expression * set_extension( bool exten ) { extension = exten; return this; }
    52 
    53         virtual Expression * clone() const override = 0;
    54         virtual void accept( Visitor & v ) override = 0;
    55         virtual Expression * acceptMutator( Mutator & m ) override = 0;
    56         virtual void print( std::ostream & os, Indenter indent = {} ) const override;
    57 };
    58 
    5933struct ParamEntry;
    6034
     
    7347        Type * actualType;
    7448        Type * formalType;
    75         Expression* expr;
     49        Expression * expr;
    7650        std::unique_ptr< InferredParams > inferParams;
     51};
     52
     53/// Expression is the root type for all expressions
     54class Expression : public BaseSyntaxNode {
     55  public:
     56        Type * result;
     57        TypeSubstitution * env;
     58        bool extension = false;
     59        InferredParams inferParams;
     60
     61        Expression();
     62        Expression( const Expression & other );
     63        virtual ~Expression();
     64
     65        Type *& get_result() { return result; }
     66        const Type * get_result() const { return result; }
     67        void set_result( Type * newValue ) { result = newValue; }
     68
     69        TypeSubstitution * get_env() const { return env; }
     70        void set_env( TypeSubstitution * newValue ) { env = newValue; }
     71        bool get_extension() const { return extension; }
     72        Expression * set_extension( bool exten ) { extension = exten; return this; }
     73
     74        InferredParams & get_inferParams() { return inferParams; }
     75
     76        virtual Expression * clone() const override = 0;
     77        virtual void accept( Visitor & v ) override = 0;
     78        virtual Expression * acceptMutator( Mutator & m ) override = 0;
     79        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
    7780};
    7881
     
    8386        Expression * function;
    8487        std::list<Expression *> args;
    85         InferredParams inferParams;
    8688
    8789        ApplicationExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() );
     
    9294        void set_function( Expression * newValue ) { function = newValue; }
    9395        std::list<Expression *>& get_args() { return args; }
    94         InferredParams & get_inferParams() { return inferParams; }
    9596
    9697        virtual ApplicationExpr * clone() const { return new ApplicationExpr( * this ); }
  • src/SynTree/TypeDecl.cc

    rb1e68d03 r4f748c5  
    2121#include "Type.h"            // for Type, Type::StorageClasses
    2222
    23 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Any || kind == Ttype ), kind( kind ) {
     23TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Ttype || sized ), kind( kind ) {
    2424}
    2525
     
    3232
    3333std::string TypeDecl::typeString() const {
    34         static const std::string kindNames[] = { "type", "incomplete type", "function type", "tuple type" };
    35         return (kind != Any && isComplete() ? "sized " : "") + kindNames[ kind ];
     34        static const std::string kindNames[] = { "object type", "function type", "tuple type" };
     35        assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "typeString: kindNames is out of sync." );
     36        assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
     37        return (isComplete() ? "sized " : "") + kindNames[ kind ];
    3638}
    3739
    3840std::string TypeDecl::genTypeString() const {
    39         static const std::string kindNames[] = { "otype", "dtype", "ftype", "ttype" };
     41        static const std::string kindNames[] = { "dtype", "ftype", "ttype" };
     42        assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." );
     43        assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
    4044        return kindNames[ kind ];
    4145}
Note: See TracChangeset for help on using the changeset viewer.