Changeset d8938622 for src/AST


Ignore:
Timestamp:
May 22, 2019, 3:38:47 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
6380f78
Parents:
37eef7a
Message:

Broken GenericSubstitution? version

Location:
src/AST
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.cpp

    r37eef7a rd8938622  
    2020#include <vector>
    2121
     22#include "GenericSubstitution.hpp"
    2223#include "Stmt.hpp"
    2324#include "Type.hpp"
     25#include "TypeSubstitution.hpp"
    2426#include "Common/utility.h"
    2527#include "Common/SemanticError.h"
     
    157159        assert( aggregate->result );
    158160
    159         assert(!"unimplemented; need TypeSubstitution, genericSubstitution");
     161        // take ownership of member type
     162        Type * res = result.set_and_mutate( mem->get_type() );
     163        // substitute aggregate generic parameters into member type
     164        genericSubsitution( aggregate->result ).apply( res );
     165        // ensure lvalue and appropriate restrictions from aggregate type
     166        res->set_lvalue( true );
     167        res->qualifiers |= aggregate->result->qualifiers;
     168        // ensure changes propegated back into result
     169        result = res;
    160170}
    161171
  • src/AST/Node.hpp

    r37eef7a rd8938622  
    9494std::ostream& operator<< ( std::ostream& out, const Node * node );
    9595
     96/// Call a visitor on a possibly-null node
     97template<typename node_t>
     98auto maybe_accept( const node_t * n, Visitor & v ) -> decltype( n->accept(v) ) {
     99        return n ? n->accept( v ) : nullptr;
     100}
     101
    96102/// Base class for the smart pointer types
    97103/// should never really be used.
  • src/AST/Pass.hpp

    r37eef7a rd8938622  
    223223};
    224224
     225/// Apply a pass to an entire translation unit
    225226template<typename pass_t>
    226227void accept_all( std::list< ast::ptr<ast::Decl> > &, ast::Pass<pass_t> & visitor );
  • src/AST/Stmt.cpp

    r37eef7a rd8938622  
    2222// --- CompoundStmt
    2323CompoundStmt::CompoundStmt( const CompoundStmt& o ) : Stmt(o), kids(o.kids) {
     24#   warning unimplemented
    2425        assert(!"implemented");
    2526}
  • src/AST/TypeSubstitution.hpp

    r37eef7a rd8938622  
    2525#include "Fwd.hpp"        // for UniqueId
    2626#include "ParseNode.hpp"
    27 #include "Type.hpp"       // for ptr<Type>
     27#include "Type.hpp"       
    2828#include "Common/SemanticError.h"  // for SemanticError
    2929#include "Visitor.hpp"
     
    165165        assert( input );
    166166        Pass<Substituter> sub( *this, false );
    167         input = dynamic_cast< SynTreeClass * >( input->acceptMutator( sub ) );
    168         assert( input );
     167        input = strict_dynamic_cast< SynTreeClass * >( input->accept( sub ) );
    169168///     std::cerr << "substitution result is: ";
    170169///     newType->print( std::cerr );
     
    177176        assert( input );
    178177        Pass<Substituter> sub( *this, true );
    179         input = dynamic_cast< SynTreeClass * >( input->acceptMutator( sub ) );
    180         assert( input );
     178        input = strict_dynamic_cast< SynTreeClass * >( input->accept( sub ) );
    181179///     std::cerr << "substitution result is: ";
    182180///     newType->print( std::cerr );
  • src/AST/module.mk

    r37eef7a rd8938622  
    2121        AST/DeclReplacer.cpp \
    2222        AST/Expr.cpp \
     23        AST/GenericSubstitution.cpp \
    2324        AST/Init.cpp \
    2425        AST/LinkageSpec.cpp \
  • src/AST/porting.md

    r37eef7a rd8938622  
    3838
    3939`N->print(std::ostream&)` is a visitor now, port these methods to `ast::Print` class
    40 * **TODO** write this visitor
    41 * **TODO** write `std::ostream& operator<< ( std::ostream& out, const Node* node )` in `Node.hpp` in terms of `ast::Print`
    42 * `Declaration::printShort` should also be integrated
     40* **TODO** `Declaration::printShort` should also be integrated
    4341
    4442`clone` is private to `Node` now
     
    208206
    209207`CompoundStmt`
    210 * **TODO** port copy operator
    211   * Needs to be an almost-shallow clone, where the declarations are cloned only if needed
    212   * **TODO** port `DeclReplacer`
    213208* Still a `std::list` for children, rather than `std::vector`
    214209  * allows more-efficient splicing for purposes of later code generation
     
    229224  * `getAggr()` => `aggr()`
    230225    * also now returns `const AggregateDecl *`
    231 * `genericSubstitution()` moved to own visitor in `AST/GenericSubstitution.hpp` **TODO** write
     226* `genericSubstitution()` moved to own visitor in `AST/GenericSubstitution.hpp`
    232227
    233228`BasicType`
Note: See TracChangeset for help on using the changeset viewer.