Changeset 4e13e2a for src


Ignore:
Timestamp:
Sep 17, 2019, 12:56:32 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
8e1467d
Parents:
a6f26ca
Message:

Added setting of result in Comma expression.
Added asserts in candidate finder to catch null pointers earlier.
ForAll? substituter now properly uses ShallowCopy?.
Added missing makefile.in

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.hpp

    ra6f26ca r4e13e2a  
    541541
    542542        CommaExpr( const CodeLocation & loc, const Expr * a1, const Expr * a2 )
    543         : Expr( loc ), arg1( a1 ), arg2( a2 ) {}
     543        : Expr( loc ), arg1( a1 ), arg2( a2 ) {
     544                this->result = a2->result;
     545        }
    544546
    545547        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
  • src/AST/ForallSubstitutionTable.cpp

    ra6f26ca r4e13e2a  
    1919#include <vector>
    2020
     21#include "Copy.hpp"                // for shallowCopy
    2122#include "Decl.hpp"
    2223#include "Node.hpp"
     
    2627namespace ast {
    2728
    28 std::vector< ptr< TypeDecl > > ForallSubstitutionTable::clone( 
    29         const std::vector< ptr< TypeDecl > > & forall, Visitor & v 
     29std::vector< ptr< TypeDecl > > ForallSubstitutionTable::clone(
     30        const std::vector< ptr< TypeDecl > > & forall, Visitor & v
    3031) {
    3132        std::vector< ptr< TypeDecl > > new_forall;
     
    3435        for ( const ast::TypeDecl * d : forall ) {
    3536                // create cloned type decl and insert into substitution map before further mutation
    36                 auto new_d = new ast::TypeDecl{
    37                         d->location, d->name, d->storage, d->base, d->kind, d->sized, d->init };
     37                auto new_d = shallowCopy( d );
    3838                decls.insert( d, new_d );
    3939                // perform other mutations and add to output
  • src/ResolvExpr/Candidate.hpp

    ra6f26ca r4e13e2a  
    5151
    5252        Candidate( const ast::Expr * x, const ast::TypeEnvironment & e )
    53         : expr( x ), cost( Cost::zero ), cvtCost( Cost::zero ), env( e ), open(), need() {}
     53        : expr( x ), cost( Cost::zero ), cvtCost( Cost::zero ), env( e ), open(), need() {
     54                assert(x->result);
     55        }
    5456
    5557        Candidate( const Candidate & o, const ast::Expr * x, const Cost & addedCost = Cost::zero )
    5658        : expr( x ), cost( o.cost + addedCost ), cvtCost( Cost::zero ), env( o.env ), open( o.open ),
    57           need( o.need ) {}
     59          need( o.need ) {
     60                assert(x->result);
     61        }
    5862
    5963        Candidate(
    60                 const ast::Expr * x, const ast::TypeEnvironment & e, const ast::OpenVarSet & o, 
     64                const ast::Expr * x, const ast::TypeEnvironment & e, const ast::OpenVarSet & o,
    6165                const ast::AssertionSet & n, const Cost & c, const Cost & cvt = Cost::zero )
    62         : expr( x ), cost( c ), cvtCost( cvt ), env( e ), open( o ), need( n.begin(), n.end() ) {}
     66        : expr( x ), cost( c ), cvtCost( cvt ), env( e ), open( o ), need( n.begin(), n.end() ) {
     67                assert(x->result);
     68        }
    6369
    6470        Candidate(
     
    6672                ast::AssertionSet && n, const Cost & c, const Cost & cvt = Cost::zero )
    6773        : expr( x ), cost( c ), cvtCost( cvt ), env( std::move( e ) ), open( std::move( o ) ),
    68           need( n.begin(), n.end() ) {}
     74          need( n.begin(), n.end() ) {
     75                assert(x->result);
     76        }
    6977};
    7078
  • src/ResolvExpr/CandidateFinder.cpp

    ra6f26ca r4e13e2a  
    14851485                        {
    14861486                                ast::ptr< ast::Type > newType = candidate->expr->result;
     1487                                assertf(candidate->expr->result, "Result of expression %p for candidate is null", candidate->expr.get());
    14871488                                candidate->env.apply( newType );
    14881489                                mangleName = Mangle::mangle( newType );
  • src/ResolvExpr/RenameVars.cc

    ra6f26ca r4e13e2a  
    8383                        auto it = nameMap.find( type->name );
    8484                        if ( it != nameMap.end() ) {
    85                                 // unconditionally mutate because map will *always* have different name, 
     85                                // unconditionally mutate because map will *always* have different name,
    8686                                // if this mutates, will *always* have been mutated by ForallSubstitutor above
    8787                                ast::TypeInstType * mut = ast::mutate( type );
     
    9696                const NodeT * openLevel( const NodeT * type ) {
    9797                        if ( type->forall.empty() ) return type;
    98                        
     98
    9999                        nameMap.beginScope();
    100100
     
    121121                void closeLevel( const ast::ParameterizedType * type ) {
    122122                        if ( type->forall.empty() ) return;
    123                        
     123
    124124                        nameMap.endScope();
    125125                }
     
    141141                }
    142142        };
    143        
     143
    144144        struct RenameVars_new /*: public ast::WithForallSubstitutor*/ {
    145145                #warning when old RenameVars goes away, replace hack below with global pass inheriting from WithForallSubstitutor
Note: See TracChangeset for help on using the changeset viewer.