Changeset 7ff30d07 for src


Ignore:
Timestamp:
Jun 14, 2016, 1:23:18 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:
545ef59, c738ca4, ee51534
Parents:
6cbc25a (diff), c8c03683 (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:software/cfa/cfa-cc

Conflicts:

Makefile.in
aclocal.m4
configure
src/Makefile.in
src/Tests/Context.c
src/driver/Makefile.in
src/examples/Makefile.in
src/examples/ctxts.c
src/examples/esskaykay.c
src/libcfa/Makefile.in

Location:
src
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r6cbc25a r7ff30d07  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri May 06 16:01:00 2016
    13 // Update Count     : 255
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jun  9 13:21:00 2016
     13// Update Count     : 256
    1414//
    1515
     
    251251        //*** Expressions
    252252        void CodeGenerator::visit( ApplicationExpr *applicationExpr ) {
     253                extension( applicationExpr );
    253254                if ( VariableExpr *varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) {
    254255                        OperatorInfo opInfo;
     
    366367
    367368        void CodeGenerator::visit( UntypedExpr *untypedExpr ) {
     369                extension( untypedExpr );
    368370                if ( NameExpr *nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) {
    369371                        OperatorInfo opInfo;
     
    450452
    451453        void CodeGenerator::visit( NameExpr *nameExpr ) {
     454                extension( nameExpr );
    452455                OperatorInfo opInfo;
    453456                if ( operatorLookup( nameExpr->get_name(), opInfo ) ) {
     
    460463
    461464        void CodeGenerator::visit( AddressExpr *addressExpr ) {
     465                extension( addressExpr );
    462466                output << "(&";
    463467                // this hack makes sure that we don't convert "constant_zero" to "0" if we're taking its address
     
    471475
    472476        void CodeGenerator::visit( CastExpr *castExpr ) {
     477                extension( castExpr );
    473478                output << "(";
    474479                if ( castExpr->get_results().empty() ) {
     
    493498
    494499        void CodeGenerator::visit( MemberExpr *memberExpr ) {
     500                extension( memberExpr );
    495501                memberExpr->get_aggregate()->accept( *this );
    496502                output << "." << mangleName( memberExpr->get_member() );
     
    498504
    499505        void CodeGenerator::visit( VariableExpr *variableExpr ) {
     506                extension( variableExpr );
    500507                OperatorInfo opInfo;
    501508                if ( variableExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && operatorLookup( variableExpr->get_var()->get_name(), opInfo ) && opInfo.type == OT_CONSTANT ) {
     
    508515        void CodeGenerator::visit( ConstantExpr *constantExpr ) {
    509516                assert( constantExpr->get_constant() );
     517                extension( constantExpr );
    510518                constantExpr->get_constant()->accept( *this );
    511519        }
    512520
    513521        void CodeGenerator::visit( SizeofExpr *sizeofExpr ) {
     522                extension( sizeofExpr );
    514523                output << "sizeof(";
    515524                if ( sizeofExpr->get_isType() ) {
     
    522531
    523532        void CodeGenerator::visit( AlignofExpr *alignofExpr ) {
     533                extension( alignofExpr );
    524534                // use GCC extension to avoid bumping std to C11
    525535                output << "__alignof__(";
     
    537547
    538548        void CodeGenerator::visit( OffsetofExpr *offsetofExpr ) {
     549                extension( offsetofExpr );
    539550                // use GCC builtin
    540551                output << "__builtin_offsetof(";
     
    549560
    550561        void CodeGenerator::visit( LogicalExpr *logicalExpr ) {
     562                extension( logicalExpr );
    551563                output << "(";
    552564                logicalExpr->get_arg1()->accept( *this );
     
    561573
    562574        void CodeGenerator::visit( ConditionalExpr *conditionalExpr ) {
     575                extension( conditionalExpr );
    563576                output << "(";
    564577                conditionalExpr->get_arg1()->accept( *this );
     
    571584
    572585        void CodeGenerator::visit( CommaExpr *commaExpr ) {
     586                extension( commaExpr );
    573587                output << "(";
    574588                commaExpr->get_arg1()->accept( *this );
     
    583597
    584598        void CodeGenerator::visit( AsmExpr *asmExpr ) {
     599                extension( asmExpr );
    585600                if ( asmExpr->get_inout() ) {
    586601                        output << "[ ";
  • src/CodeGen/CodeGenerator.h

    r6cbc25a r7ff30d07  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:32:24 2016
    13 // Update Count     : 28
     12// Last Modified On : Thu Jun  9 13:15:58 2016
     13// Update Count     : 29
    1414//
    1515
     
    9696                        std::ostream& operator()(std::ostream & os);
    9797                };
     98
     99                void extension( Expression *expr ) {
     100                        if ( expr->get_extension() ) {
     101                                output << "__extension__ ";
     102                        } // if
     103                } // extension
    98104          private:
    99105
  • src/Common/utility.h

    r6cbc25a r7ff30d07  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Apr 28 13:18:24 2016
    13 // Update Count     : 16
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Jun  8 17:33:59 2016
     13// Update Count     : 22
    1414//
    1515
     
    3333}
    3434
     35template<typename T, typename U>
     36struct maybeBuild_t {
     37        static T * doit( const U *orig ) {
     38                if ( orig ) {
     39                        return orig->build();
     40                } else {
     41                        return 0;
     42                } // if
     43        }
     44};
     45
    3546template< typename T, typename U >
    3647static inline T * maybeBuild( const U *orig ) {
    37         if ( orig ) {
    38                 return orig->build();
    39         } else {
    40                 return 0;
    41         } // if
     48        return maybeBuild_t<T,U>::doit(orig);
    4249}
    4350
  • src/Parser/ExpressionNode.cc

    r6cbc25a r7ff30d07  
    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
     12// Last Modified On : Mon Jun 13 14:46:17 2016
     13// Update Count     : 307
    1414//
    1515
     
    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();
     
    344344
    345345Expression *DesignatorNode::build() const {
    346         Expression * ret = get_argName()->build();
     346        Expression * ret = maybeBuild<Expression>(get_argName());
    347347
    348348        if ( isArrayIndex ) {
     
    389389        "Cond", "NCond",
    390390        // diadic
    391         "SizeOf", "AlignOf", "OffsetOf", "Attr", "CompLit", "?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&",
     391        "SizeOf", "AlignOf", "OffsetOf", "Attr", "?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&",
    392392        "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?",
    393393        "?=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
     
    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                }
     
    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 );
  • src/Parser/ParseNode.h

    r6cbc25a r7ff30d07  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:28:16 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Apr 14 15:37:52 2016
    13 // Update Count     : 205
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Jun 13 16:04:47 2016
     13// Update Count     : 240
    1414//
    1515
     
    2020#include <list>
    2121#include <iterator>
     22#include <memory>
    2223
    2324#include "Common/utility.h"
    2425#include "Parser/LinkageSpec.h"
    2526#include "SynTree/Type.h"
     27#include "SynTree/Expression.h"
    2628//#include "SynTree/Declaration.h"
    2729#include "Common/UniqueName.h"
     
    7981        ExpressionNode *set_argName( const std::string *aName );
    8082        ExpressionNode *set_argName( ExpressionNode *aDesignator );
     83        bool get_extension() const { return extension; }
     84        ExpressionNode *set_extension( bool exten ) { extension = exten; return this; }
    8185
    8286        virtual void print( std::ostream &, int indent = 0) const = 0;
     
    8791        void printDesignation ( std::ostream &, int indent = 0) const;
    8892  private:
    89         ExpressionNode *argName;
     93        ExpressionNode *argName = 0;
     94        bool extension = false;
     95};
     96
     97template< typename T >
     98struct maybeBuild_t<Expression, T> {
     99        static inline Expression * doit( const T *orig ) {
     100                if ( orig ) {
     101                        Expression *p = orig->build();
     102                        p->set_extension( orig->get_extension() );
     103                        return p;
     104                } else {
     105                        return 0;
     106                } // if
     107        }
    90108};
    91109
     
    179197                                Cond, NCond,
    180198                                // diadic
    181                                 SizeOf, AlignOf, OffsetOf, Attr, CompLit, Plus, Minus, Mul, Div, Mod, Or, And,
     199                                SizeOf, AlignOf, OffsetOf, Attr, Plus, Minus, Mul, Div, Mod, Or, And,
    182200                                BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq,
    183201                                Assign, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,
     
    574592        while ( cur ) {
    575593                try {
    576                         SynTreeType *result = dynamic_cast< SynTreeType *>( cur->build() );
     594//                      SynTreeType *result = dynamic_cast< SynTreeType *>( maybeBuild<typename std::result_of<decltype(&NodeType::build)(NodeType)>::type>( cur ) );
     595                        SynTreeType *result = dynamic_cast< SynTreeType *>( maybeBuild<typename std::pointer_traits<decltype(cur->build())>::element_type>( cur ) );
    577596                        if ( result ) {
    578597                                *out++ = result;
  • src/Parser/StatementNode.cc

    r6cbc25a r7ff30d07  
    1010// Created On       : Sat May 16 14:59:41 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 30 14:39:39 2015
    13 // Update Count     : 130
     12// Last Modified On : Thu Jun  9 14:18:46 2016
     13// Update Count     : 132
    1414//
    1515
     
    222222                                branches.pop_front();
    223223                        } // if
    224                         return new IfStmt( labs, notZeroExpr( get_control()->build() ), thenb, elseb );
     224                        return new IfStmt( labs, notZeroExpr( maybeBuild<Expression>(get_control()) ), thenb, elseb );
    225225                }
    226226          case While:
    227227                assert( branches.size() == 1 );
    228                 return new WhileStmt( labs, notZeroExpr( get_control()->build() ), branches.front() );
     228                return new WhileStmt( labs, notZeroExpr( maybeBuild<Expression>(get_control()) ), branches.front() );
    229229          case Do:
    230230                assert( branches.size() == 1 );
    231                 return new WhileStmt( labs, notZeroExpr( get_control()->build() ), branches.front(), true );
     231                return new WhileStmt( labs, notZeroExpr( maybeBuild<Expression>(get_control()) ), branches.front(), true );
    232232          case For:
    233233                {
     
    244244                        Expression *cond = 0;
    245245                        if ( ctl->get_condition() != 0 )
    246                                 cond = notZeroExpr( ctl->get_condition()->build() );
     246                                cond = notZeroExpr( maybeBuild<Expression>(ctl->get_condition()) );
    247247
    248248                        Expression *incr = 0;
    249249                        if ( ctl->get_change() != 0 )
    250                                 incr = ctl->get_change()->build();
     250                                incr = maybeBuild<Expression>(ctl->get_change());
    251251
    252252                        return new ForStmt( labs, init, cond, incr, branches.front() );
    253253                }
    254254          case Switch:
    255                 return new SwitchStmt( labs, get_control()->build(), branches );
     255                return new SwitchStmt( labs, maybeBuild<Expression>(get_control()), branches );
    256256          case Choose:
    257                 return new ChooseStmt( labs, get_control()->build(), branches );
     257                return new ChooseStmt( labs, maybeBuild<Expression>(get_control()), branches );
    258258          case Fallthru:
    259259                return new FallthruStmt( labs );
    260260          case Case:
    261                 return new CaseStmt( labs, get_control()->build(), branches );
     261                return new CaseStmt( labs, maybeBuild<Expression>(get_control()), branches );
    262262          case Default:
    263263                return new CaseStmt( labs, 0, branches, true );
     
    266266                        if ( get_target() == "" ) {                                     // computed goto
    267267                                assert( get_control() != 0 );
    268                                 return new BranchStmt( labs, get_control()->build(), BranchStmt::Goto );
     268                                return new BranchStmt( labs, maybeBuild<Expression>(get_control()), BranchStmt::Goto );
    269269                        } // if
    270270
  • src/Parser/parser.cc

    r6cbc25a r7ff30d07  
    52995299/* Line 1806 of yacc.c  */
    53005300#line 432 "parser.yy"
    5301     { (yyval.en) = (yyvsp[(2) - (2)].en); }
     5301    { (yyval.en) = (yyvsp[(2) - (2)].en)->set_extension( true ); }
    53025302    break;
    53035303
     
    58095809/* Line 1806 of yacc.c  */
    58105810#line 685 "parser.yy"
    5811     { (yyval.sn) = new StatementNode( (yyvsp[(2) - (2)].decl) ); }
     5811    { (yyval.sn) = new StatementNode( (yyvsp[(2) - (2)].decl) )/*->set_extension( true )*/; }
    58125812    break;
    58135813
     
    71227122/* Line 1806 of yacc.c  */
    71237123#line 1475 "parser.yy"
    7124     { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
     7124    { (yyval.decl) = (yyvsp[(2) - (3)].decl)/*->set_extension( true )*/; }
    71257125    break;
    71267126
     
    71297129/* Line 1806 of yacc.c  */
    71307130#line 1478 "parser.yy"
    7131     { (yyval.decl) = (yyvsp[(2) - (3)].decl); }
     7131    { (yyval.decl) = (yyvsp[(2) - (3)].decl)/*->set_extension( true )*/; }
    71327132    break;
    71337133
     
    79137913/* Line 1806 of yacc.c  */
    79147914#line 1994 "parser.yy"
    7915     { (yyval.decl) = (yyvsp[(2) - (2)].decl); }
     7915    { (yyval.decl) = (yyvsp[(2) - (2)].decl)/*->set_extension( true )*/; }
    79167916    break;
    79177917
  • src/Parser/parser.yy

    r6cbc25a r7ff30d07  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun  7 08:08:31 2016
    13 // Update Count     : 1560
     12// Last Modified On : Mon Jun 13 15:00:23 2016
     13// Update Count     : 1578
    1414//
    1515
     
    430430                { $$ = $1; }
    431431        | EXTENSION cast_expression                                                     // GCC
    432                 { $$ = $2; }
     432                { $$ = $2->set_extension( true ); }
    433433        | ptrref_operator cast_expression                                       // CFA
    434434                { $$ = new CompositeExprNode( $1, $2 ); }
     
    683683                { $$ = new StatementNode( $1 ); }
    684684        | EXTENSION declaration                                                         // GCC
    685                 { $$ = new StatementNode( $2 ); }
     685                { $$ = new StatementNode( $2 )/*->set_extension( true )*/; }
    686686        | function_definition
    687687                { $$ = new StatementNode( $1 ); }
     
    14731473        new_field_declaring_list ';'                                            // CFA, new style field declaration
    14741474        | EXTENSION new_field_declaring_list ';'                        // GCC
    1475                 { $$ = $2; }
     1475                { $$ = $2/*->set_extension( true )*/; }
    14761476        | field_declaring_list ';'
    14771477        | EXTENSION field_declaring_list ';'                            // GCC
    1478                 { $$ = $2; }
     1478                { $$ = $2/*->set_extension( true )*/; }
    14791479        ;
    14801480
     
    19921992                }
    19931993        | EXTENSION external_definition
    1994                 { $$ = $2; }
     1994                { $$ = $2/*->set_extension( true )*/; }
    19951995        ;
    19961996
  • src/ResolvExpr/AlternativeFinder.cc

    r6cbc25a r7ff30d07  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sat May 16 23:52:08 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Apr 20 14:24:03 2016
    13 // Update Count     : 24
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Jun 13 16:13:54 2016
     13// Update Count     : 25
    1414//
    1515
     
    757757                for ( std::list< DeclarationWithType* >::iterator i = declList.begin(); i != declList.end(); ++i ) {
    758758                        VariableExpr newExpr( *i, nameExpr->get_argName() );
     759                        newExpr.set_extension( nameExpr->get_extension() );
    759760                        alternatives.push_back( Alternative( newExpr.clone(), env, Cost() ) );
    760761                        PRINT(
  • src/SynTree/Expression.cc

    r6cbc25a r7ff30d07  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri May 13 13:23:11 2016
    13 // Update Count     : 40
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Jun 13 16:03:39 2016
     13// Update Count     : 42
    1414//
    1515
     
    3232Expression::Expression( Expression *_aname ) : env( 0 ), argName( _aname ) {}
    3333
    34 Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ) {
     34Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) {
    3535        cloneAll( other.results, results );
    3636}
     
    5959                os << std::string( indent, ' ' ) << "with designator:";
    6060                argName->print( os, indent+2 );
     61        } // if
     62
     63        if ( extension ) {
     64                os << std::string( indent, ' ' ) << "with extension:";
    6165        } // if
    6266}
  • src/SynTree/Expression.h

    r6cbc25a r7ff30d07  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Apr 27 17:06:49 2016
    13 // Update Count     : 21
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Jun  8 17:05:30 2016
     13// Update Count     : 22
    1414//
    1515
     
    3838        Expression *get_argName() const { return argName; }
    3939        void set_argName( Expression *name ) { argName = name; }
     40        bool get_extension() const { return extension; }
     41        void set_extension( bool exten ) { extension = exten; }
    4042
    4143        virtual Expression *clone() const = 0;
     
    4749        TypeSubstitution *env;
    4850        Expression* argName; // if expression is used as an argument, it can be "designated" by this name
     51        bool extension = false;
    4952};
    5053
  • src/Tests/Abstype.c

    r6cbc25a r7ff30d07  
    1 type T | { T x( T ); };
     1otype T | { T x( T ); };
    22
    33T y( T t ) {
     
    66}
    77
    8 forall( type T ) lvalue T *?( T * );
     8forall( otype T ) lvalue T *?( T * );
    99int ?++( int * );
    1010int ?=?( int *, int );
    1111forall( dtype DT ) DT * ?=?( DT **, DT * );
    1212
    13 type U = int *;
     13otype U = int *;
    1414
    1515U x( U u ) {
  • src/Tests/Attributes.c

    r6cbc25a r7ff30d07  
    66//    @max
    77//
    8 // 2. a direct application to a manifest type
     8// 2. a direct application to a manifest otype
    99//
    1010//    @max( int )
    1111//
    12 // 3. constraining a type variable; the application is implicitly performed at the call site as in (2)
     12// 3. constraining a otype variable; the application is implicitly performed at the call site as in (2)
    1313//
    14 //    forall( type T | { T @max( T ); } ) T x( T t );
     14//    forall( otype T | { T @max( T ); } ) T x( T t );
    1515//
    1616//
     
    2323//    x = (*attr_var);
    2424//
    25 // 2. an indirect application to a manifest type
     25// 2. an indirect application to a manifest otype
    2626//
    2727//    (*attr_var)( int )
    2828//
    29 // 3. a direct application to a type variable
     29// 3. a direct application to a otype variable
    3030//
    3131//    @max( T )
     
    4747// 3. polymorphic
    4848//
    49 //    forall( type T | constraint( T ) ) int @attr( T );
     49//    forall( otype T | constraint( T ) ) int @attr( T );
    5050
    5151int @max = 3;
     
    5353int main() {
    5454    int x;
    55     type @type(type t);                                                                 // compiler intrinsic
    56     type @widest(type t);
    57     @type(x) *y;                                                                                // gcc: typeof(x) *y;
    58     const @widest(double) *w;                                                   // gcc: const typeof(x) *w;
    59     * @type(3 + 4) z;                                                                   // cfa declaration syntax
     55    otype @otype(otype t);                                                                      // compiler intrinsic
     56    otype @widest(otype t);
     57    @otype(x) *y;                                                                               // gcc: otypeof(x) *y;
     58    const @widest(double) *w;                                                   // gcc: const otypeof(x) *w;
     59    * @otype(3 + 4) z;                                                                  // cfa declaration syntax
    6060    y = @max;           
    6161    z = @max(x) + @size(int);
  • src/Tests/InferParam.c

    r6cbc25a r7ff30d07  
    33double ?=?( double*, double );
    44
    5 forall( type T, type U | { U f(T); } ) U g(T);
     5forall( otype T, otype U | { U f(T); } ) U g(T);
    66float f( int );
    77double f( int );
     
    1313}
    1414
    15 context has_f_and_j( type T, type U ) {
     15context has_f_and_j( otype T, otype U ) {
    1616        U f( T );
    1717        U j( T, U );
     
    1919
    2020float j( int, float );
    21 forall( type T, type U | has_f_and_j( T, U ) ) U k( T );
     21forall( otype T, otype U | has_f_and_j( T, U ) ) U k( T );
    2222
    2323void l() {
  • src/Tests/Makefile

    r6cbc25a r7ff30d07  
    1 CFA ?= ../cfa-cpp
     1CFA ?= ../driver/cfa-cpp
    22CFAOPT ?= -a
    33OUTPUT ?= Output
     
    3232
    3333${OUTPUTDIR} :
    34         mkdir $@
     34        mkdir -p $@
    3535
    3636# remove the expected results directories to generate new ones from the current output
  • src/Tests/Members.c

    r6cbc25a r7ff30d07  
    33float ?=?( float*, float );
    44forall( dtype DT ) DT * ?=?( DT**, DT* );
    5 forall(type T) lvalue T *?( T* );
     5forall(otype T) lvalue T *?( T* );
    66char *__builtin_memcpy();
    77
  • src/Tests/OccursError.c

    r6cbc25a r7ff30d07  
    1 forall( type T ) void f( void (*)( T, T* ) );
    2 forall( type U ) void g( U*, U );
     1forall( otype T ) void f( void (*)( T, T* ) );
     2forall( otype U ) void g( U*, U );
    33
    44void test() {
  • src/Tests/Quad.c

    r6cbc25a r7ff30d07  
    22int ?*?( int, int );
    33
    4 forall( type T | { T ?*?( T, T ); } )
     4forall( otype T | { T ?*?( T, T ); } )
    55T square( T t ) {
    66        return t * t;
    77}
    88
    9 forall( type U | { U square( U ); } )
     9forall( otype U | { U square( U ); } )
    1010U quad( U u ) {
    1111        return square( square( u ) );
  • src/Tests/Rank2.c

    r6cbc25a r7ff30d07  
    33
    44void a() {
    5         forall( type T ) void f( T );
    6         void g( forall( type U ) void p( U ) );
     5        forall( otype T ) void f( T );
     6        void g( forall( otype U ) void p( U ) );
    77        g( f );
    88}
     
    1010void g() {
    1111        void h( int *null );
    12         forall( type T ) T id( T );
     12        forall( otype T ) T id( T );
    1313        forall( dtype T ) T *0;
    1414        int 0;
  • src/driver/cc1.cc

    r6cbc25a r7ff30d07  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun  2 17:24:26 2016
    13 // Update Count     : 79
     12// Last Modified On : Fri Jun 10 09:27:37 2016
     13// Update Count     : 80
    1414//
    1515
     
    151151                                i += 1;                                                                 // and the argument
    152152                                cpp_flag = true;
    153                         } else if ( arg == "-D__CFA__" ) {
     153                        } else if ( arg == "-D__CFA_PREPROCESS__" ) {
    154154                                CFA_flag = true;
    155                         } else if ( arg == "-D" && string( argv[i + 1] ) == "__CFA__" ) {
     155                        } else if ( arg == "-D" && string( argv[i + 1] ) == "__CFA_PREPROCESS__" ) {
    156156                                i += 1;                                                                 // and the argument
    157157                                CFA_flag = true;
  • src/driver/cfa.cc

    r6cbc25a r7ff30d07  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun  2 17:24:25 2016
    13 // Update Count     : 137
     12// Last Modified On : Fri Jun 10 09:26:19 2016
     13// Update Count     : 138
    1414//
    1515
     
    263263        args[nargs] = ( *new string( string("-D__CFA_PATCHLEVEL__=") + Patch ) ).c_str();
    264264        nargs += 1;
    265         args[nargs] = "-D__CFORALL__=1";
     265        args[nargs] = "-D__CFA__";
     266        nargs += 1;
     267        args[nargs] = "-D__CFORALL__";
    266268        nargs += 1;
    267269
     
    272274
    273275        if ( CFA_flag ) {
    274                 args[nargs] = "-D__CFA__";
     276                args[nargs] = "-D__CFA_PREPROCESS_";
    275277                nargs += 1;
    276278        } // if
  • src/libcfa/Makefile.am

    r6cbc25a r7ff30d07  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Wed Jun  8 14:20:34 2016
    14 ## Update Count     : 165
     13## Last Modified On : Mon Jun 13 14:27:22 2016
     14## Update Count     : 166
    1515###############################################################################
    1616
     
    5050        @BACKEND_CC@ -c -o $@ $<
    5151
    52 CFLAGS = -g -Wall -Wno-unused-function -B${abs_top_srcdir}/src/driver -XCFA -t  # TEMPORARY: does not build with -O2
     52CFLAGS = -quiet -g -Wall -Wno-unused-function -B${abs_top_srcdir}/src/driver -XCFA -t  # TEMPORARY: does not build with -O2
    5353CC = ${abs_top_srcdir}/src/driver/cfa
    5454
  • src/tests/Array.c

    r6cbc25a r7ff30d07  
    11//Testing array declarations
    22int a1[];
    3 int a2[*];
    4 double a4[3.0];
     3//int a2[*];
     4//double a4[3.0];
    55
    66int m1[][3];
    7 int m2[*][*];
     7//int m2[*][*];
    88int m4[3][3];
    99
     
    1111
    1212int fred() {
    13         int a1[];
    14         int a2[*];
     13//      int a1[];
     14//      int a2[*];
    1515        int a4[3];
    1616        int T[3];
  • src/tests/Forall.c

    r6cbc25a r7ff30d07  
    77
    88void g1() {
    9         forall( type T ) T f( T );
     9        forall( otype T ) T f( T );
    1010        void f( int );
    1111        void h( void (*p)(void) );
     
    2424
    2525void g2() {
    26         forall( type T ) void f( T, T );
    27         forall( type T, type U ) void f( T, U );
     26        forall( otype T ) void f( T, T );
     27        forall( otype T, otype U ) void f( T, U );
    2828 
    2929        int x;
     
    3737}
    3838
    39 typedef forall ( type T ) int (*f)( int );
     39typedef forall ( otype T ) int (*f)( int );
    4040
    41 forall( type T )
     41forall( otype T )
    4242void swap( T left, T right ) {
    4343        T temp = left;
     
    4646}
    4747
    48 context sumable( type T ) {
     48context sumable( otype T ) {
    4949        const T 0;
    5050        T ?+?(T, T);
     
    5353};
    5454
    55 type T1 | { const T1 0; T1 ?+?(T1, T1); T1 ?++(T1); [T1] ?+=?(T1,T1); },
    56         T2(type P1, type P2 ),
     55otype T1 | { const T1 0; T1 ?+?(T1, T1); T1 ?++(T1); [T1] ?+=?(T1,T1); },
     56        T2(otype P1, otype P2 ),
    5757        T3 | sumable(T3);
    5858
    59 type T2(type P1, type P2) | sumable(T2(P1,P2)) = struct { P1 i; P2 j; };
     59otype T2(otype P1, otype P2) | sumable(T2(P1,P2)) = struct { P1 i; P2 j; };
    6060
    6161T2(int, int) w1;
    6262typedef T2(int, int) w2;
    6363w2 g2;
    64 type w3 = T2(int, int);
     64otype w3 = T2(int, int);
    6565w3 g3;
    6666
    67 forall( type T | sumable( T ) )
     67forall( otype T | sumable( T ) )
    6868T sum( int n, T a[] ) {
    6969        T total = 0;
     
    7474}
    7575
    76 forall( type T | { const T 0; T ?+?(T, T); T ?++(T); [T] ?+=?(T,T); } )
     76forall( otype T | { const T 0; T ?+?(T, T); T ?++(T); [T] ?+=?(T,T); } )
    7777T twice( T t ) {
    7878        return t + t;
    7979}
    8080
    81 forall( type T | { const T 0; int ?!=?(T, T); int ?<?(T, T); } )
     81forall( otype T | { const T 0; int ?!=?(T, T); int ?<?(T, T); } )
    8282T min( T t1, T t2 ) {
    8383        return t1 < t2 ? t1 : t2;
  • src/tests/Functions.c

    r6cbc25a r7ff30d07  
    2828int ((*f12())[])[3] {}
    2929
    30 // "implicit int" type specifier (not ANSI)
     30// "implicit int" otype specifier (not ANSI)
    3131
    3232fII1( int i ) {}
  • src/tests/GccExtensions.c

    r6cbc25a r7ff30d07  
    1919    __signed s2;
    2020
    21     __typeof(s1) t1;
    22     __typeof__(s1) t2;
     21    __otypeof(s1) t1;
     22    __otypeof__(s1) t2;
    2323
    2424    __volatile int v1;
  • src/tests/Scope.c

    r6cbc25a r7ff30d07  
    33typedef float t;
    44y z;
    5 type u = struct { int a; double b; };
     5otype u = struct { int a; double b; };
    66int f( int y );
    77y q;
    88
    99y w( y y, u v ) {
    10         type x | { x t(u); };
     10        otype x | { x t(u); };
    1111        u u = y;
    1212        x z = t(u);
     
    1515y p;
    1616
    17 context has_u( type z ) {
     17context has_u( otype z ) {
    1818        z u(z);
    1919};
    2020
    21 forall( type t | has_u( t ) )
     21forall( otype t | has_u( t ) )
    2222y q( t the_t ) {
    2323        t y = u( the_t );
  • src/tests/Subrange.c

    r6cbc25a r7ff30d07  
    1 // A small context defining the notion of an ordered type.  (The standard
     1// A small context defining the notion of an ordered otype.  (The standard
    22// library should probably contain a context for this purpose.)
    3 context ordered(type T) {
     3context ordered(otype T) {
    44    int ?<?(T, T), ?<=?(T, T);
    55};
    66
    7 // A subrange type resembling an Ada subtype with a base type and a range
     7// A subrange otype resembling an Ada subotype with a base otype and a range
    88// constraint.
    9 type subrange(type base_t | ordered(base_t), base_t low = 0, base_t high = 8) = base_t;
     9otype subrange(otype base_t | ordered(base_t), base_t low = 0, base_t high = 8) = base_t;
    1010
    11 // Note that subrange() can be applied to floating-point and pointer types, not
    12 // just integral types.
    13 //   This requires a "type generator" extension to Cforall.  Type generators
    14 // must accept type and non-type parameters, which is beyond what we discussed
     11// Note that subrange() can be applied to floating-point and pointer otypes, not
     12// just integral otypes.
     13//   This requires a "otype generator" extension to Cforall.  Type generators
     14// must accept otype and non-otype parameters, which is beyond what we discussed
    1515// previously.  Type parameters must be usable in the declaration of
    1616// subsequent parameters: parameter T is used to declare parameters "low"
     
    2222subrange(int, 0, (rand() & 0xF) ) foo;
    2323
    24 // What sorts of expressions can be used as arguments of type generators?  Is
     24// What sorts of expressions can be used as arguments of otype generators?  Is
    2525// "subrange(int, 0, rand() & 0xF)" legal?  Probably.  The nearest C equivalent
    2626// to the "low" and "high" arguments is the array size in a variable-length
     
    2828
    2929// Convenient access to subrange bounds, for instance for iteration:
    30 forall (type T, T low, T high)
     30forall (otype T, T low, T high)
    3131T lbound( subrange(T, low, high) v) {
    3232    return low;
    3333}
    3434
    35 forall (type T, T low, T high)
     35forall (otype T, T low, T high)
    3636T hbound( subrange(T, low, high) v) {
    3737    return high;
     
    4141unsigned lday = lbound(day_of_month);
    4242
    43 // Assignment from the base type, with bounds checking.  I'll ignore the issue
     43// Assignment from the base otype, with bounds checking.  I'll ignore the issue
    4444// of exception handling here.  Inlining allows the compiler to eliminate
    4545// bounds checks.
    46 forall (type T | ordered(T), T low, T high)
     46forall (otype T | ordered(T), T low, T high)
    4747inline subrange(T, low, high) ?=?(subrange(T, low, high)* target, T source) {
    4848    if (low <= source && source <= high) *((T*)target) = source;
     
    5151}
    5252
    53 // Assignment between subranges with a common base type.  The bounds check
     53// Assignment between subranges with a common base otype.  The bounds check
    5454// compares range bounds so that the compiler can optimize checks away when the
    5555// ranges are known to overlap.
    56 forall (type T | ordered(T), T t_low, T t_high, T s_low, T s_high)
     56forall (otype T | ordered(T), T t_low, T t_high, T s_low, T s_high)
    5757inline subrange(T, t_low, t_high) ?=?(subrange(T, t_low, t_high)* target,
    5858                                      subrange(T, s_low, s_high) source) {
  • src/tests/TypeGenerator.c

    r6cbc25a r7ff30d07  
    1 context addable( type T ) {
     1context addable( otype T ) {
    22        T ?+?( T,T );
    33        T ?=?( T*, T);
    44};
    55
    6 type List1( type T | addable( T ) ) = struct { T data; List1( T ) *next; } *;
     6otype List1( otype T | addable( T ) ) = struct { T data; List1( T ) *next; } *;
    77typedef List1( int ) ListOfIntegers;
    88//List1( int ) li;
     
    1111[int] h( * List1( int ) p );                                                    // new declaration syntax
    1212
    13 struct( type T ) S2 { T i; };                                                   // actual definition
     13struct( otype T ) S2 { T i; };                                                  // actual definition
    1414struct( int ) S3 v1, *p;                                                                // expansion and instantiation
    15 struct( type T )( int ) S24 { T i; } v2;                                // actual definition, expansion and instantiation
    16 struct( type T )( int ) { T i; } v2;                                    // anonymous actual definition, expansion and instantiation
     15struct( otype T )( int ) S24 { T i; } v2;                               // actual definition, expansion and instantiation
     16struct( otype T )( int ) { T i; } v2;                                   // anonymous actual definition, expansion and instantiation
    1717
    18 struct( type T | addable( T ) ) node { T data; struct( T ) node *next; };
    19 type List( type T ) = struct( T ) node *;
     18struct( otype T | addable( T ) ) node { T data; struct( T ) node *next; };
     19otype List( otype T ) = struct( T ) node *;
    2020List( int ) my_list;
    2121
    22 type Complex | addable( Complex );
     22otype Complex | addable( Complex );
    2323
    2424int main() {
  • src/tests/Typedef.c

    r6cbc25a r7ff30d07  
    1818a c;
    1919
    20 typedef typeof(3) x, y;  // GCC
     20typedef otypeof(3) x, y;  // GCC
    2121
    2222x p;
     
    2424
    2525int main() {
    26     typedef typeof(3) z, p;
     26    typedef otypeof(3) z, p;
    2727    z w;
    2828    p x;
  • src/tests/Typeof.c

    r6cbc25a r7ff30d07  
    11int main() {
    22    int *v1;
    3     typeof(v1) v2;
    4     typeof(*v1) v3[4];
     3    otypeof(v1) v2;
     4    otypeof(*v1) v3[4];
    55    char *v4[4];
    6     typeof(typeof(char *)[4]) v5;
    7     typeof (int *) v6;
    8     typeof( int ( int, int p ) ) *v7;
    9     typeof( [int] ( int, int p ) ) *v8;
     6    otypeof(otypeof(char *)[4]) v5;
     7    otypeof (int *) v6;
     8    otypeof( int ( int, int p ) ) *v7;
     9    otypeof( [int] ( int, int p ) ) *v8;
    1010}
  • src/tests/io.c

    r6cbc25a r7ff30d07  
    1111// Created On       : Wed Mar  2 16:56:02 2016
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Thu May 26 10:06:00 2016
    14 // Update Count     : 28
     13// Last Modified On : Wed Jun  8 22:52:04 2016
     14// Update Count     : 30
    1515//
    1616
     
    3434        long double _Complex ldc;
    3535        char s1[10], s2[10];
     36
     37        int x = 3, y = 5, z = 7;
     38        sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl;
     39        sout | 1 | 2 | 3 | endl;
     40        sout | '1' | '2' | '3' | endl;
     41        sout | 1 | "" | 2 | "" | 3 | endl;
     42        sout | endl;
    3643
    3744        ifstream in;                                                                                            // create / open file
Note: See TracChangeset for help on using the changeset viewer.