Changes in / [d66e7b7:896737b]


Ignore:
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • driver/Makefile.am

    rd66e7b7 r896737b  
    1919
    2020# applies to both programs
    21 AM_CXXFLAGS = @HOST_FLAGS@ -Wall -O2 -g -std=c++14 -I${abs_top_srcdir}/src
     21AM_CXXFLAGS = @HOST_FLAGS@ -Wall -O2 -g -std=c++14 -I${abs_top_srcdir}/src -I${abs_top_srcdir}/src/include
    2222
    2323# don't install cfa directly
  • driver/Makefile.in

    rd66e7b7 r896737b  
    334334
    335335# applies to both programs
    336 AM_CXXFLAGS = @HOST_FLAGS@ -Wall -O2 -g -std=c++14 -I${abs_top_srcdir}/src
     336AM_CXXFLAGS = @HOST_FLAGS@ -Wall -O2 -g -std=c++14 -I${abs_top_srcdir}/src -I${abs_top_srcdir}/src/include
    337337cfa_SOURCES = cfa.cc
    338338
  • src/AST/Decl.hpp

    rd66e7b7 r896737b  
    101101        ptr<Expr> bitfieldWidth;
    102102
    103         ObjectDecl( const CodeLocation& loc, const std::string& name, Type* type, Init* init = nullptr,
    104                 Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C, Expr* bitWd = nullptr,
    105                 std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {})
     103        ObjectDecl( const CodeLocation & loc, const std::string & name, const Type * type, Init * init = nullptr,
     104                Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C, Expr * bitWd = nullptr,
     105                std::vector< ptr<Attribute> > && attrs = {}, Function::Specs fs = {})
    106106        : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), type( type ),
    107107          init( init ), bitfieldWidth( bitWd ) {}
  • src/AST/DeclReplacer.cpp

    rd66e7b7 r896737b  
    1414//
    1515
    16 #error unimplemented
     16#warning unimplemented
    1717
    1818// Local Variables: //
  • src/AST/Expr.cpp

    rd66e7b7 r896737b  
    9595        Type * addrType( const Type * type ) {
    9696                if ( const ReferenceType * refType = dynamic_cast< const ReferenceType * >( type ) ) {
    97                         CV::Qualifiers quals = refType->qualifiers;
    9897                        return new ReferenceType{ addrType( refType->base ), refType->qualifiers };
    9998                } else {
     
    118117                                result = res;
    119118                        } else {
    120                                 SemanticError( loc, arg->result,
     119                                SemanticError( loc, arg->result.get(),
    121120                                        "Attempt to take address of non-lvalue expression: " );
    122121                        }
     
    283282// --- ConstructorExpr
    284283
    285 ConstructorExpr::ConstructorExpr( const CodeLocation & loc, const Expr * call ) 
     284ConstructorExpr::ConstructorExpr( const CodeLocation & loc, const Expr * call )
    286285: Expr( loc ), callExpr( call ) {
    287         // allow resolver to type a constructor used as an expression if it has the same type as its 
     286        // allow resolver to type a constructor used as an expression if it has the same type as its
    288287        // first argument
    289288        assert( callExpr );
     
    310309TupleIndexExpr::TupleIndexExpr( const CodeLocation & loc, const Expr * t, unsigned i )
    311310: Expr( loc ), tuple( t ), index( i ) {
    312         const TupleType * type = strict_dynamic_cast< const TupleType * >( tuple->result );
     311        const TupleType * type = strict_dynamic_cast< const TupleType * >( tuple->result.get() );
    313312        assertf( type->size() > index, "TupleIndexExpr index out of bounds: tuple size %d, requested "
    314313                "index %d in expr %s", type->size(), index, toString( tuple ).c_str() );
     
    319318// --- TupleAssignExpr
    320319
    321 TupleAssignExpr::TupleAssignExpr( 
    322         const CodeLocation & loc, std::vector<ptr<Expr>> && assigns, 
     320TupleAssignExpr::TupleAssignExpr(
     321        const CodeLocation & loc, std::vector<ptr<Expr>> && assigns,
    323322        std::vector<ptr<ObjectDecl>> && tempDecls )
    324323: Expr( loc, Tuples::makeTupleType( assigns ) ), stmtExpr() {
    325         // convert internally into a StmtExpr which contains the declarations and produces the tuple of 
     324        // convert internally into a StmtExpr which contains the declarations and produces the tuple of
    326325        // the assignments
    327326        std::list<ptr<Stmt>> stmts;
     
    337336// --- StmtExpr
    338337
    339 StmtExpr::StmtExpr( const CodeLocation & loc, const CompoundStmt * ss ) 
     338StmtExpr::StmtExpr( const CodeLocation & loc, const CompoundStmt * ss )
    340339: Expr( loc ), stmts( ss ), returnDecls(), dtors() { computeResult(); }
    341340
     
    344343        const std::list<ptr<Stmt>> & body = stmts->kids;
    345344        if ( ! returnDecls.empty() ) {
    346                 // prioritize return decl for result type, since if a return decl exists, then the StmtExpr 
     345                // prioritize return decl for result type, since if a return decl exists, then the StmtExpr
    347346                // is currently in an intermediate state where the body will always give a void result type
    348347                result = returnDecls.front()->get_type();
     
    360359unsigned long long UniqueExpr::nextId = 0;
    361360
    362 UniqueExpr::UniqueExpr( const CodeLocation & loc, const Expr * e, unsigned long long i = -1 )
     361UniqueExpr::UniqueExpr( const CodeLocation & loc, const Expr * e, unsigned long long i )
    363362: Expr( loc, e->result ), id( i ) {
    364363        assert( expr );
    365         if ( id == -1 ) {
    366                 assert( nextId != -1 );
     364        if ( id == -1ull ) {
     365                assert( nextId != -1ull );
    367366                id = nextId++;
    368367        }
     368}
     369
    369370}
    370371
  • src/AST/Fwd.hpp

    rd66e7b7 r896737b  
    125125class ConstructorInit;
    126126
    127 class Constant;
    128 
    129127class Label;
    130128
     
    135133std::string toString( const Node * );
    136134
     135template < typename ... Params >
     136std::string toString( const Params & ... params );
     137
    137138typedef unsigned int UniqueId;
    138139
  • src/AST/Node.cpp

    rd66e7b7 r896737b  
    1616#include "Node.hpp"
    1717#include "Fwd.hpp"
     18
     19#include "Attribute.hpp"
    1820#include "Decl.hpp"
    1921#include "Expr.hpp"
     22#include "Init.hpp"
    2023#include "Stmt.hpp"
    2124#include "Type.hpp"
     25#include "TypeSubstitution.hpp"
    2226
    2327template< typename node_t, enum ast::Node::ref_type ref_t >
     
    2630template< typename node_t, enum ast::Node::ref_type ref_t >
    2731void ast::ptr_base<node_t, ref_t>::_dec( const node_t * node ) { node->decrement(ref_t); }
     32
     33/// Sets this pointer to a mutated version of a pointer (possibly) owned elsehere.
     34/// Returns a mutable version of the pointer in this node.
     35template< typename node_t, enum ast::Node::ref_type ref_t >
     36node_t * ast::ptr_base<node_t, ref_t>::set_and_mutate( const node_t * n ) {
     37        // ensure ownership of `n` by this node to avoid spurious single-owner mutates
     38        assign( n );
     39        // get mutable version of `n`
     40        auto r = mutate( node );
     41        // re-assign mutable version in case `mutate()` produced a new pointer
     42        assign( r );
     43        return r;
     44}
    2845
    2946template class ast::ptr_base< ast::Node, ast::Node::ref_type::weak >;
     
    227244template class ast::ptr_base< ast::ConstructorInit, ast::Node::ref_type::weak >;
    228245template class ast::ptr_base< ast::ConstructorInit, ast::Node::ref_type::strong >;
    229 template class ast::ptr_base< ast::Constant, ast::Node::ref_type::weak >;
    230 template class ast::ptr_base< ast::Constant, ast::Node::ref_type::strong >;
    231246template class ast::ptr_base< ast::Attribute, ast::Node::ref_type::weak >;
    232247template class ast::ptr_base< ast::Attribute, ast::Node::ref_type::strong >;
  • src/AST/Node.hpp

    rd66e7b7 r896737b  
    143143        /// Sets this pointer to a mutated version of a pointer (possibly) owned elsehere.
    144144        /// Returns a mutable version of the pointer in this node.
    145         node_t * set_and_mutate( const node_t * n ) {
    146                 // ensure ownership of `n` by this node to avoid spurious single-owner mutates
    147                 assign( n );
    148                 // get mutable version of `n`
    149                 auto r = mutate( node );
    150                 // re-assign mutable version in case `mutate()` produced a new pointer
    151                 assign( r );
    152                 return r;
    153         }
     145        node_t * set_and_mutate( const node_t * n );
    154146
    155147        using ptr = const node_t *;
  • src/AST/Pass.hpp

    rd66e7b7 r896737b  
    175175        const ast::Init *             visit( const ast::ListInit             * ) override final;
    176176        const ast::Init *             visit( const ast::ConstructorInit      * ) override final;
    177         const ast::Constant *         visit( const ast::Constant             * ) override final;
    178177        const ast::Attribute *        visit( const ast::Attribute            * ) override final;
    179178        const ast::TypeSubstitution * visit( const ast::TypeSubstitution     * ) override final;
  • src/AST/Pass.impl.hpp

    rd66e7b7 r896737b  
    791791
    792792//--------------------------------------------------------------------------
     793// CatchStmt
     794template< typename pass_t >
     795const ast::Stmt * ast::Pass< pass_t >::visit( const ast::CatchStmt * node ) {
     796        VISIT_START( node );
     797
     798        VISIT({
     799                // catch statements introduce a level of scope (for the caught exception)
     800                guard_indexer guard { *this };
     801                maybe_accept( node, &CatchStmt::decl );
     802                maybe_accept( node, &CatchStmt::cond );
     803                maybe_accept( node, &CatchStmt::body );
     804        })
     805
     806        VISIT_END( Stmt, node );
     807}
     808
     809//--------------------------------------------------------------------------
     810// FinallyStmt
     811template< typename pass_t >
     812const ast::Stmt * ast::Pass< pass_t >::visit( const ast::FinallyStmt * node ) {
     813        VISIT_START( node );
     814
     815        VISIT(
     816                maybe_accept( node, &FinallyStmt::body );
     817        )
     818
     819        VISIT_END( Stmt, node );
     820}
     821
     822//--------------------------------------------------------------------------
     823// WaitForStmt
     824template< typename pass_t >
     825const ast::Stmt * ast::Pass< pass_t >::visit( const ast::WaitForStmt * node ) {
     826        VISIT_START( node );
     827                // for( auto & clause : node->clauses ) {
     828                //      maybeAccept_impl( clause.target.function, *this );
     829                //      maybeAccept_impl( clause.target.arguments, *this );
     830
     831                //      maybeAccept_impl( clause.statement, *this );
     832                //      maybeAccept_impl( clause.condition, *this );
     833                // }
     834
     835        #define maybe_accept(field) \
     836                if(node->field) { \
     837                        auto nval = call_accept( node->field ); \
     838                        if(nval != node->field ) { \
     839                                auto nparent = mutate(node); \
     840                                nparent->field = nval; \
     841                                node = nparent; \
     842                        } \
     843                }
     844
     845        VISIT(
     846                maybe_accept( timeout.time );
     847                maybe_accept( timeout.stmt );
     848                maybe_accept( timeout.cond );
     849                maybe_accept( orElse.stmt  );
     850                maybe_accept( orElse.cond  );
     851        )
     852
     853        #undef maybe_accept
     854
     855        VISIT_END( Stmt, node );
     856}
     857
     858//--------------------------------------------------------------------------
     859// WithStmt
     860template< typename pass_t >
     861const ast::Stmt * ast::Pass< pass_t >::visit( const ast::WithStmt * node ) {
     862        VISIT_START( node );
     863
     864        VISIT(
     865                maybe_accept( node, &WithStmt::exprs );
     866                {
     867                        // catch statements introduce a level of scope (for the caught exception)
     868                        guard_indexer guard { *this };
     869                        __pass::indexer::addWith( pass, 0, node->exprs, node );
     870                        maybe_accept( node, &WithStmt::stmt );
     871                }
     872        )
     873        VISIT_END( Stmt, node );
     874}
     875
     876//--------------------------------------------------------------------------
     877// NullStmt
     878template< typename pass_t >
     879const ast::NullStmt * ast::Pass< pass_t >::visit( const ast::NullStmt * node ) {
     880        VISIT_START( node );
     881        VISIT_END( NullStmt, node );
     882}
     883
     884//--------------------------------------------------------------------------
     885// DeclStmt
     886template< typename pass_t >
     887const ast::Stmt * ast::Pass< pass_t >::visit( const ast::DeclStmt * node ) {
     888        VISIT_START( node );
     889
     890        VISIT(
     891                maybe_accept( node, &DeclStmt::decl );
     892        )
     893
     894        VISIT_END( Stmt, node );
     895}
     896
     897//--------------------------------------------------------------------------
     898// ImplicitCtorDtorStmt
     899template< typename pass_t >
     900const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ImplicitCtorDtorStmt * node ) {
     901        VISIT_START( node );
     902
     903        // For now this isn't visited, it is unclear if this causes problem
     904        // if all tests are known to pass, remove this code
     905        // VISIT(
     906        //      maybe_accept( node, &ImplicitCtorDtorStmt::callStmt );
     907        // )
     908
     909        VISIT_END( Stmt, node );
     910}
     911
     912
     913
     914
     915
     916
     917//--------------------------------------------------------------------------
    793918// SingleInit
    794919template< typename pass_t >
  • src/AST/Pass.proto.hpp

    rd66e7b7 r896737b  
    241241                INDEXER_FUNC1( addUnion  , const UnionDecl *     );
    242242                INDEXER_FUNC1( addTrait  , const TraitDecl *     );
    243                 INDEXER_FUNC2( addWith   , const std::list< ptr<Expr> > &, const Node * );
     243                INDEXER_FUNC2( addWith   , const std::vector< ptr<Expr> > &, const Node * );
     244                INDEXER_FUNC2( addWith   , const std::list  < ptr<Expr> > &, const Node * );
    244245
    245246                // A few extra functions have more complicated behaviour, they are hand written
  • src/AST/Visitor.hpp

    rd66e7b7 r896737b  
    111111    virtual const ast::Init *             visit( const ast::ListInit             * ) = 0;
    112112    virtual const ast::Init *             visit( const ast::ConstructorInit      * ) = 0;
    113     virtual const ast::Constant *         visit( const ast::Constant             * ) = 0;
    114113    virtual const ast::Attribute *        visit( const ast::Attribute            * ) = 0;
    115114    virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution     * ) = 0;
  • src/Common/SemanticError.h

    rd66e7b7 r896737b  
    1717
    1818#include "ErrorObjects.h"
     19#include "AST/Node.hpp"
    1920#include <cstring>
    2021
  • src/InitTweak/InitTweak.cc

    rd66e7b7 r896737b  
    437437                // const ast::Expr * callArg( const CallExpr * call, unsigned int pos ) {
    438438                //      if( pos >= call->args.size() ) {
    439                 //              assertf( false, "getCallArg for argument that doesn't exist: (%u); %s.", 
     439                //              assertf( false, "getCallArg for argument that doesn't exist: (%u); %s.",
    440440                //                      pos, toString( call ).c_str() );
    441441                //      }
     
    467467        }
    468468        const ast::Expr * getCallArg( const ast::Expr * call, unsigned pos ) {
    469                 assert(!"implemented; needs to build AST/Expr.cpp");
     469                (void)call;
     470                (void)pos;
     471                #warning unimplemented; needs to build AST/Expr.cpp
     472                assertf(false, "unimplemented; needs to build AST/Expr.cpp");
    470473                // if ( auto app = dynamic_cast< const ast::ApplicationExpr * >( call ) ) {
    471474                //      return callArg( app, pos );
     
    482485                //      return getCallArg( ctor->callExpr, pos );
    483486                // } else {
    484                 //      assertf( false, "Unexpected expression type passed to getCallArg: %s", 
     487                //      assertf( false, "Unexpected expression type passed to getCallArg: %s",
    485488                //              toString( call ).c_str() );
    486489                // }
     
    548551        }
    549552        const ast::Type* getPointerBase( const ast::Type* t ) {
    550                 assert(!"needs to build Type.cpp before inclusion");
     553                (void)t;
     554                #warning needs to build Type.cpp before inclusion
     555                assertf(false, "needs to build Type.cpp before inclusion");
    551556                // if ( const auto * p = dynamic_cast< const ast::PointerType * >( t ) ) {
    552557                //      return p->base;
  • src/SynTree/Declaration.cc

    rd66e7b7 r896737b  
    3131
    3232Declaration::Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage )
    33                 : name( name ), linkage( linkage ), storageClasses( scs ), uniqueId( 0 ) {
     33                : name( name ), linkage( linkage ), uniqueId( 0 ), storageClasses( scs ) {
    3434}
    3535
    3636Declaration::Declaration( const Declaration &other )
    37         : BaseSyntaxNode( other ), name( other.name ), linkage( other.linkage ), extension( other.extension ), storageClasses( other.storageClasses ), uniqueId( other.uniqueId ) {
     37        : BaseSyntaxNode( other ), name( other.name ), linkage( other.linkage ), extension( other.extension ), uniqueId( other.uniqueId ), storageClasses( other.storageClasses ) {
    3838}
    3939
  • src/Tuples/TupleExpansion.cc

    rd66e7b7 r896737b  
    320320        }
    321321        const ast::Type * makeTupleType( const std::vector<ast::ptr<ast::Expr>> & exprs ) {
    322                 assert(!"implemented; needs Type.cpp in build");
     322                (void) exprs;
     323                #warning Not implemented; needs Type.cpp in build
     324                assertf(false, "Not implemented; needs Type.cpp in build");
    323325                // // produce the TupleType which aggregates the types of the exprs
    324326                // std::vector<ast::ptr<ast::Type>> types;
    325                 // ast::CV::Qualifiers quals{ 
    326                 //      ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Lvalue | 
     327                // ast::CV::Qualifiers quals{
     328                //      ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Lvalue |
    327329                //      ast::CV::Atomic | ast::CV::Mutex };
    328                
     330
    329331                // for ( const ast::Expr * expr : exprs ) {
    330332                //      assert( expr->result );
  • src/Tuples/Tuples.h

    rd66e7b7 r896737b  
    2929namespace Tuples {
    3030        // TupleAssignment.cc
    31         void handleTupleAssignment( ResolvExpr::AlternativeFinder & currentFinder, UntypedExpr * assign, 
     31        void handleTupleAssignment( ResolvExpr::AlternativeFinder & currentFinder, UntypedExpr * assign,
    3232                std::vector< ResolvExpr::AlternativeFinder >& args );
    33        
     33
    3434        // TupleExpansion.cc
    3535        /// expands z.[a, b.[x, y], c] into [z.a, z.b.x, z.b.y, z.c], inserting UniqueExprs as appropriate
     
    4848        /// returns a TypeInstType if `type` is a ttype, nullptr otherwise
    4949        TypeInstType * isTtype( Type * type );
     50        const ast::TypeInstType * isTtype( const ast::Type * type );
    5051
    5152        /// returns true if the expression may contain side-effects.
Note: See TracChangeset for help on using the changeset viewer.