Changeset 000b914 for src/SynTree


Ignore:
Timestamp:
Dec 7, 2015, 11:31:53 AM (10 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
baf7fee
Parents:
e58be8e (diff), 47534159 (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 'master' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

Location:
src/SynTree
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    re58be8e r000b914  
    122122void SizeofExpr::print( std::ostream &os, int indent) const {
    123123        os << std::string( indent, ' ' ) << "Sizeof Expression on: ";
     124
     125        if (isType)
     126                type->print(os, indent + 2);
     127        else
     128                expr->print(os, indent + 2);
     129
     130        os << std::endl;
     131        Expression::print( os, indent );
     132}
     133
     134AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) :
     135                Expression( _aname ), expr(expr_), type(0), isType(false) {
     136        add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) );
     137}
     138
     139AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) :
     140                Expression( _aname ), expr(0), type(type_), isType(true) {
     141        add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) );
     142}
     143
     144AlignofExpr::AlignofExpr( const AlignofExpr &other ) :
     145        Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
     146}
     147
     148AlignofExpr::~AlignofExpr() {
     149        delete expr;
     150        delete type;
     151}
     152
     153void AlignofExpr::print( std::ostream &os, int indent) const {
     154        os << std::string( indent, ' ' ) << "Alignof Expression on: ";
    124155
    125156        if (isType)
  • src/SynTree/Expression.h

    re58be8e r000b914  
    2323#include "Constant.h"
    2424
     25/// Expression is the root type for all expressions
    2526class Expression {
    2627  public:
     
    4748};
    4849
    49 // ParamEntry contains the i.d. of a declaration and a type that is derived from that declaration,
    50 // but subject to decay-to-pointer and type parameter renaming
    51 
     50/// ParamEntry contains the i.d. of a declaration and a type that is derived from that declaration,
     51/// but subject to decay-to-pointer and type parameter renaming
    5252struct ParamEntry {
    5353        ParamEntry(): decl( 0 ), actualType( 0 ), formalType( 0 ), expr( 0 ) {}
     
    6565typedef std::map< UniqueId, ParamEntry > InferredParams;
    6666
    67 // ApplicationExpr represents the application of a function to a set of parameters.  This is the
    68 // result of running an UntypedExpr through the expression analyzer.
    69 
     67/// ApplicationExpr represents the application of a function to a set of parameters.  This is the
     68/// result of running an UntypedExpr through the expression analyzer.
    7069class ApplicationExpr : public Expression {
    7170  public:
     
    8988};
    9089
    91 // UntypedExpr represents the application of a function to a set of parameters, but where the
    92 // particular overload for the function name has not yet been determined.  Most operators are
    93 // converted into functional form automatically, to permit operator overloading.
    94 
     90/// UntypedExpr represents the application of a function to a set of parameters, but where the
     91/// particular overload for the function name has not yet been determined.  Most operators are
     92/// converted into functional form automatically, to permit operator overloading.
    9593class UntypedExpr : public Expression {
    9694  public:
     
    118116};
    119117
    120 // this class contains a name whose meaning is still not determined
     118/// NameExpr contains a name whose meaning is still not determined
    121119class NameExpr : public Expression {
    122120  public:
     
    139137// function-call format.
    140138
    141 // AddressExpr represents a address-of expression, e.g. &e
     139/// AddressExpr represents a address-of expression, e.g. &e
    142140class AddressExpr : public Expression {
    143141  public:
     
    174172};
    175173
    176 // CastExpr represents a type cast expression, e.g. (int)e
     174/// CastExpr represents a type cast expression, e.g. (int)e
    177175class CastExpr : public Expression {
    178176  public:
     
    193191};
    194192
    195 // UntypedMemberExpr represents a member selection operation, e.g. q.p before processing by the expression analyzer
     193/// UntypedMemberExpr represents a member selection operation, e.g. q.p before processing by the expression analyzer
    196194class UntypedMemberExpr : public Expression {
    197195  public:
     
    214212};
    215213
    216 // MemberExpr represents a member selection operation, e.g. q.p after processing by the expression analyzer
     214/// MemberExpr represents a member selection operation, e.g. q.p after processing by the expression analyzer
    217215class MemberExpr : public Expression {
    218216  public:
     
    235233};
    236234
    237 // VariableExpr represents an expression that simply refers to the value of a named variable
     235/// VariableExpr represents an expression that simply refers to the value of a named variable
    238236class VariableExpr : public Expression {
    239237  public:
     
    253251};
    254252
    255 // ConstantExpr represents an expression that simply refers to the value of a constant
     253/// ConstantExpr represents an expression that simply refers to the value of a constant
    256254class ConstantExpr : public Expression {
    257255  public:
     
    271269};
    272270
    273 // SizeofExpr represents a sizeof expression (could be sizeof(int) or sizeof 3+4)
     271/// SizeofExpr represents a sizeof expression (could be sizeof(int) or sizeof 3+4)
    274272class SizeofExpr : public Expression {
    275273  public:
     
    296294};
    297295
    298 // AttrExpr represents an @attribute expression (like sizeof, but user-defined)
     296/// AlignofExpr represents an alignof expression
     297class AlignofExpr : public Expression {
     298  public:
     299        AlignofExpr( Expression *expr, Expression *_aname = 0 );
     300        AlignofExpr( const AlignofExpr &other );
     301        AlignofExpr( Type *type, Expression *_aname = 0 );
     302        virtual ~AlignofExpr();
     303
     304        Expression *get_expr() const { return expr; }
     305        void set_expr( Expression *newValue ) { expr = newValue; }
     306        Type *get_type() const { return type; }
     307        void set_type( Type *newValue ) { type = newValue; }
     308        bool get_isType() const { return isType; }
     309        void set_isType( bool newValue ) { isType = newValue; }
     310
     311        virtual AlignofExpr *clone() const { return new AlignofExpr( *this ); }
     312        virtual void accept( Visitor &v ) { v.visit( this ); }
     313        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     314        virtual void print( std::ostream &os, int indent = 0 ) const;
     315  private:
     316        Expression *expr;
     317        Type *type;
     318        bool isType;
     319};
     320
     321/// AttrExpr represents an @attribute expression (like sizeof, but user-defined)
    299322class AttrExpr : public Expression {
    300323  public:
     
    324347};
    325348
    326 // LogicalExpr represents a short-circuit boolean expression (&& or ||)
     349/// LogicalExpr represents a short-circuit boolean expression (&& or ||)
    327350class LogicalExpr : public Expression {
    328351  public:
     
    347370};
    348371
    349 // ConditionalExpr represents the three-argument conditional ( p ? a : b )
     372/// ConditionalExpr represents the three-argument conditional ( p ? a : b )
    350373class ConditionalExpr : public Expression {
    351374  public:
     
    371394};
    372395
    373 // CommaExpr represents the sequence operator ( a, b )
     396/// CommaExpr represents the sequence operator ( a, b )
    374397class CommaExpr : public Expression {
    375398  public:
     
    392415};
    393416
    394 // TupleExpr represents a tuple expression ( [a, b, c] )
     417/// TupleExpr represents a tuple expression ( [a, b, c] )
    395418class TupleExpr : public Expression {
    396419  public:
     
    410433};
    411434
    412 // SolvedTupleExpr represents a TupleExpr whose components have been type-resolved. It is effectively a shell for the code generator to work on
     435/// SolvedTupleExpr represents a TupleExpr whose components have been type-resolved. It is effectively a shell for the code generator to work on
    413436class SolvedTupleExpr : public Expression {
    414437  public:
     
    428451};
    429452
    430 // TypeExpr represents a type used in an expression (e.g. as a type generator parameter)
     453/// TypeExpr represents a type used in an expression (e.g. as a type generator parameter)
    431454class TypeExpr : public Expression {
    432455  public:
     
    446469};
    447470
    448 // AsmExpr represents a GCC 'asm constraint operand' used in an asm statement: [output] "=f" (result)
     471/// AsmExpr represents a GCC 'asm constraint operand' used in an asm statement: [output] "=f" (result)
    449472class AsmExpr : public Expression {
    450473  public:
     
    472495};
    473496
    474 // ValofExpr represents a GCC 'lambda expression'
     497/// ValofExpr represents a GCC 'lambda expression'
    475498class UntypedValofExpr : public Expression {
    476499  public:
  • src/SynTree/Mutator.cc

    re58be8e r000b914  
    251251}
    252252
     253Expression *Mutator::mutate( AlignofExpr *alignofExpr ) {
     254        mutateAll( alignofExpr->get_results(), *this );
     255        if ( alignofExpr->get_isType() ) {
     256                alignofExpr->set_type( maybeMutate( alignofExpr->get_type(), *this ) );
     257        } else {
     258                alignofExpr->set_expr( maybeMutate( alignofExpr->get_expr(), *this ) );
     259        }
     260        return alignofExpr;
     261}
     262
    253263Expression *Mutator::mutate( AttrExpr *attrExpr ) {
    254264        mutateAll( attrExpr->get_results(), *this );
  • src/SynTree/Mutator.h

    re58be8e r000b914  
    6464        virtual Expression* mutate( ConstantExpr *constantExpr );
    6565        virtual Expression* mutate( SizeofExpr *sizeofExpr );
     66        virtual Expression* mutate( AlignofExpr *alignofExpr );
    6667        virtual Expression* mutate( AttrExpr *attrExpr );
    6768        virtual Expression* mutate( LogicalExpr *logicalExpr );
  • src/SynTree/SynTree.h

    re58be8e r000b914  
    6969class ConstantExpr;
    7070class SizeofExpr;
     71class AlignofExpr;
    7172class AttrExpr;
    7273class LogicalExpr;
  • src/SynTree/Visitor.cc

    re58be8e r000b914  
    210210}
    211211
     212void Visitor::visit( AlignofExpr *alignofExpr ) {
     213        acceptAll( alignofExpr->get_results(), *this );
     214        if ( alignofExpr->get_isType() ) {
     215                maybeAccept( alignofExpr->get_type(), *this );
     216        } else {
     217                maybeAccept( alignofExpr->get_expr(), *this );
     218        }
     219}
     220
    212221void Visitor::visit( AttrExpr *attrExpr ) {
    213222        acceptAll( attrExpr->get_results(), *this );
  • src/SynTree/Visitor.h

    re58be8e r000b914  
    6464        virtual void visit( ConstantExpr *constantExpr );
    6565        virtual void visit( SizeofExpr *sizeofExpr );
     66        virtual void visit( AlignofExpr *alignofExpr );
    6667        virtual void visit( AttrExpr *attrExpr );
    6768        virtual void visit( LogicalExpr *logicalExpr );
Note: See TracChangeset for help on using the changeset viewer.