Changes in / [f4c2f1a:6380f78]


Ignore:
Location:
src
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.cpp

    rf4c2f1a r6380f78  
    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

    rf4c2f1a r6380f78  
    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

    rf4c2f1a r6380f78  
    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/TypeSubstitution.hpp

    rf4c2f1a r6380f78  
    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

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

    rf4c2f1a r6380f78  
    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`
  • src/Makefile.in

    rf4c2f1a r6380f78  
    167167am__objects_1 = AST/Attribute.$(OBJEXT) AST/Convert.$(OBJEXT) \
    168168        AST/Decl.$(OBJEXT) AST/DeclReplacer.$(OBJEXT) \
    169         AST/Expr.$(OBJEXT) AST/Init.$(OBJEXT) \
    170         AST/LinkageSpec.$(OBJEXT) AST/Node.$(OBJEXT) \
    171         AST/Pass.$(OBJEXT) AST/Print.$(OBJEXT) AST/Stmt.$(OBJEXT) \
    172         AST/Type.$(OBJEXT) AST/TypeSubstitution.$(OBJEXT)
     169        AST/Expr.$(OBJEXT) AST/GenericSubstitution.$(OBJEXT) \
     170        AST/Init.$(OBJEXT) AST/LinkageSpec.$(OBJEXT) \
     171        AST/Node.$(OBJEXT) AST/Pass.$(OBJEXT) AST/Print.$(OBJEXT) \
     172        AST/Stmt.$(OBJEXT) AST/Type.$(OBJEXT) \
     173        AST/TypeSubstitution.$(OBJEXT)
    173174am__objects_2 = CodeGen/CodeGenerator.$(OBJEXT) \
    174175        CodeGen/FixMain.$(OBJEXT) CodeGen/GenType.$(OBJEXT) \
     
    574575        AST/DeclReplacer.cpp \
    575576        AST/Expr.cpp \
     577        AST/GenericSubstitution.cpp \
    576578        AST/Init.cpp \
    577579        AST/LinkageSpec.cpp \
     
    739741        AST/$(DEPDIR)/$(am__dirstamp)
    740742AST/Expr.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp)
     743AST/GenericSubstitution.$(OBJEXT): AST/$(am__dirstamp) \
     744        AST/$(DEPDIR)/$(am__dirstamp)
    741745AST/Init.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp)
    742746AST/LinkageSpec.$(OBJEXT): AST/$(am__dirstamp) \
     
    11731177@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/DeclReplacer.Po@am__quote@
    11741178@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Expr.Po@am__quote@
     1179@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/GenericSubstitution.Po@am__quote@
    11751180@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Init.Po@am__quote@
    11761181@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/LinkageSpec.Po@am__quote@
Note: See TracChangeset for help on using the changeset viewer.