Changeset 3cd5fdd for src/AST


Ignore:
Timestamp:
Jun 5, 2019, 6:07:41 PM (5 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
c6a1e8a, d3b2c32a, dd857bb
Parents:
99d4584 (diff), 8568319 (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.
git-author:
Aaron Moss <a3moss@…> (06/05/19 18:02:23)
git-committer:
Aaron Moss <a3moss@…> (06/05/19 18:07:41)
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/AST
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r99d4584 r3cd5fdd  
    749749                        break;
    750750                case ast::ConstantExpr::String:
    751                         rslt = new ConstantExpr{Constant::from_string( node->rep )};
     751                        rslt = new ConstantExpr{Constant{
     752                                get<Type>().accept1( node->result ),
     753                                node->rep,
     754                                (long long unsigned int)0
     755                        }};
    752756                        break;
    753757                }
     
    21502154                                GET_ACCEPT_1(result, Type),
    21512155                                old->constant.get_value(),
    2152                                 (unsigned long long) old->intValue()
     2156                                (unsigned long long) old->intValue(),
     2157                                ast::ConstantExpr::Kind::Integer
    21532158                        );
    21542159                } else if (isFloatlikeConstantType(old->result)) {
     
    21602165                        );
    21612166                } else if (isStringlikeConstantType(old->result)) {
    2162                         rslt = ast::ConstantExpr::from_string(
    2163                                 old->location,
    2164                                 old->constant.get_value()
     2167                        rslt = new ast::ConstantExpr(
     2168                                old->location,
     2169                                GET_ACCEPT_1(result, Type),
     2170                                old->constant.get_value(),
     2171                                0,
     2172                                ast::ConstantExpr::Kind::String
    21652173                        );
    21662174                }
  • src/AST/Node.cpp

    r99d4584 r3cd5fdd  
    3434template< typename node_t, enum ast::Node::ref_type ref_t >
    3535void ast::ptr_base<node_t, ref_t>::_dec( const node_t * node ) { node->decrement(ref_t); }
     36
     37template< typename node_t, enum ast::Node::ref_type ref_t >
     38void ast::ptr_base<node_t, ref_t>::_check() const { if(node) assert(node->was_ever_strong == false || node->strong_count > 0); }
    3639
    3740template< typename node_t, enum ast::Node::ref_type ref_t >
  • src/AST/Node.hpp

    r99d4584 r3cd5fdd  
    4646        };
    4747
     48        bool unique() const { return strong_count == 1; }
     49
    4850private:
    4951        /// Make a copy of this node; should be overridden in subclass with more precise return type
     
    5658        mutable size_t strong_count = 0;
    5759        mutable size_t weak_count = 0;
     60        mutable bool was_ever_strong = false;
    5861
    5962        void increment(ref_type ref) const {
    6063                switch (ref) {
    61                         case ref_type::strong: strong_count++; break;
     64                        case ref_type::strong: strong_count++; was_ever_strong = true; break;
    6265                        case ref_type::weak  : weak_count  ++; break;
    6366                }
     
    176179        }
    177180
    178         const node_t * get() const { return  node; }
    179         const node_t * operator->() const { return  node; }
    180         const node_t & operator* () const { return *node; }
    181         explicit operator bool() const { return node; }
    182         operator const node_t * () const { return node; }
     181        const node_t * get() const { _check(); return  node; }
     182        const node_t * operator->() const { _check(); return  node; }
     183        const node_t & operator* () const { _check(); return *node; }
     184        explicit operator bool() const { _check(); return node; }
     185        operator const node_t * () const { _check(); return node; }
    183186
    184187        /// wrapper for convenient access to dynamic_cast
    185188        template<typename o_node_t>
    186         const o_node_t * as() const { return dynamic_cast<const o_node_t *>(node); }
     189        const o_node_t * as() const { _check(); return dynamic_cast<const o_node_t *>(node); }
    187190
    188191        /// wrapper for convenient access to strict_dynamic_cast
     
    208211        void _inc( const node_t * other );
    209212        void _dec( const node_t * other );
     213        void _check() const;
    210214
    211215protected:
Note: See TracChangeset for help on using the changeset viewer.