Ignore:
Timestamp:
Jun 30, 2016, 4:32:56 PM (9 years ago)
Author:
Thierry Delisle <tdelisle@…>
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, with_gc
Children:
ea29e73
Parents:
1b5c81ed (diff), 84d4d6f (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' into gc_noraii

Conflicts:

Jenkinsfile
src/SymTab/Validate.cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ExpressionNode.cc

    r1b5c81ed rf80e0218  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ExpressionNode.cc -- 
    8 // 
     7// ExpressionNode.cc --
     8//
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr  8 15:43:05 2016
    13 // Update Count     : 296
    14 // 
     12// Last Modified On : Mon Jun 13 14:46:17 2016
     13// Update Count     : 307
     14//
    1515
    1616#include <cassert>
     
    3232using namespace std;
    3333
    34 ExpressionNode::ExpressionNode() : ParseNode(), argName( 0 ) {}
    35 
    36 ExpressionNode::ExpressionNode( const string *name ) : ParseNode( name ), argName( 0 ) {}
    37 
    38 ExpressionNode::ExpressionNode( const ExpressionNode &other ) : ParseNode( other.name ) {
     34ExpressionNode::ExpressionNode() : ParseNode() {}
     35
     36ExpressionNode::ExpressionNode( const string *name ) : ParseNode( name ) {}
     37
     38ExpressionNode::ExpressionNode( const ExpressionNode &other ) : ParseNode( other.name ), extension( other.extension ) {
    3939        if ( other.argName ) {
    4040                argName = other.argName->clone();
     
    231231        // "abc" "def" "ghi" => "abcdefghi", remove new text from quotes and insert before last quote in old string.
    232232        value.insert( value.length() - 1, newValue->substr( 1, newValue->length() - 2 ) );
    233        
     233
    234234        delete newValue;                                                                        // allocated by lexer
    235235        return this;
     
    344344
    345345Expression *DesignatorNode::build() const {
    346         Expression * ret = get_argName()->build();
     346        Expression * ret = maybeBuild<Expression>(get_argName());
    347347
    348348        if ( isArrayIndex ) {
    349                 // need to traverse entire structure and change any instances of 0 or 1 to 
     349                // need to traverse entire structure and change any instances of 0 or 1 to
    350350                // ConstantExpr
    351351                DesignatorFixer fixer;
     
    389389        "Cond", "NCond",
    390390        // diadic
    391         "SizeOf", "AlignOf", "OffsetOf", "Attr", "CompLit", "?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&",
     391        "SizeOf", "AlignOf", "OffsetOf", "Attr", "?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&",
    392392        "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?",
    393393        "?=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
     
    440440}
    441441
    442 CompositeExprNode::CompositeExprNode( const CompositeExprNode &other ) : ExpressionNode( other ), function( maybeClone( other.function ) ) {
     442CompositeExprNode::CompositeExprNode( const CompositeExprNode &other ) : ExpressionNode( other ), function( maybeClone( other.function ) ), arguments( 0 ) {
    443443        ParseNode *cur = other.arguments;
    444444        while ( cur ) {
     
    466466
    467467        if ( ! ( op = dynamic_cast<OperatorNode *>( function ) ) ) { // function as opposed to operator
    468                 return new UntypedExpr( function->build(), args, maybeBuild< Expression >( get_argName() ));
     468                return new UntypedExpr( maybeBuild<Expression>(function), args, maybeBuild< Expression >( get_argName() ));
    469469        } // if
    470470
     
    550550                        if ( dynamic_cast< VoidType* >( targetType ) ) {
    551551                                delete targetType;
    552                                 return new CastExpr( expr_node->build(), maybeBuild< Expression >( get_argName() ) );
     552                                return new CastExpr( maybeBuild<Expression>(expr_node), maybeBuild< Expression >( get_argName() ) );
    553553                        } else {
    554                                 return new CastExpr( expr_node->build(),targetType, maybeBuild< Expression >( get_argName() ) );
     554                                return new CastExpr( maybeBuild<Expression>(expr_node),targetType, maybeBuild< Expression >( get_argName() ) );
    555555                        } // if
    556556                }
     
    608608                {
    609609                        assert( args.size() == 2 );
    610                        
     610
    611611                        if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args() ) ) {
    612612                                NameExpr *member = dynamic_cast<NameExpr *>( args.back() );
     
    621621                        assert( var );
    622622                        if ( ! get_args()->get_link() ) {
    623                                 return new AttrExpr( var->build(), ( Expression*)0);
     623                                return new AttrExpr( maybeBuild<Expression>(var), ( Expression*)0);
    624624                        } else if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()->get_link()) ) {
    625                                 return new AttrExpr( var->build(), arg->get_decl()->buildType());
     625                                return new AttrExpr( maybeBuild<Expression>(var), arg->get_decl()->buildType());
    626626                        } else {
    627                                 return new AttrExpr( var->build(), args.back());
    628                         } // if
    629                 }
    630           case OperatorNode::CompLit:
    631                 throw UnimplementedError( "C99 compound literals" );
    632                 // the short-circuited operators
     627                                return new AttrExpr( maybeBuild<Expression>(var), args.back());
     628                        } // if
     629                }
    633630          case OperatorNode::Or:
    634631          case OperatorNode::And:
     
    719716
    720717Expression *AsmExprNode::build() const {
    721         return new AsmExpr( maybeBuild< Expression >( inout ), (ConstantExpr *)constraint->build(), operand->build() );
     718        return new AsmExpr( maybeBuild< Expression >( inout ), (ConstantExpr *)maybeBuild<Expression>(constraint), maybeBuild<Expression>(operand) );
    722719}
    723720
     
    796793
    797794Expression *ValofExprNode::build() const {
    798         return new UntypedValofExpr ( get_body()->build(), maybeBuild< Expression >( get_argName() ) );
     795        return new UntypedValofExpr ( maybeBuild<Statement>(get_body()), maybeBuild< Expression >( get_argName() ) );
    799796}
    800797
     
    908905
    909906Expression *CompoundLiteralNode::build() const {
    910         Declaration * newDecl = type->build();                          // compound literal type
     907        Declaration * newDecl = maybeBuild<Declaration>(type); // compound literal type
    911908        if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { // non-sue compound-literal type
    912                 return new CompoundLiteralExpr( newDeclWithType->get_type(), kids->build() );
     909                return new CompoundLiteralExpr( newDeclWithType->get_type(), maybeBuild<Initializer>(kids) );
    913910        // these types do not have associated type information
    914911        } else if ( StructDecl * newDeclStructDecl = dynamic_cast< StructDecl * >( newDecl )  ) {
    915                 return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), kids->build() );
     912                return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybeBuild<Initializer>(kids) );
    916913        } else if ( UnionDecl * newDeclUnionDecl = dynamic_cast< UnionDecl * >( newDecl )  ) {
    917                 return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), kids->build() );
     914                return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybeBuild<Initializer>(kids) );
    918915        } else if ( EnumDecl * newDeclEnumDecl = dynamic_cast< EnumDecl * >( newDecl )  ) {
    919                 return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), kids->build() );
     916                return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybeBuild<Initializer>(kids) );
    920917        } else {
    921918                assert( false );
Note: See TracChangeset for help on using the changeset viewer.