Changeset d8938622


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

Broken GenericSubstitution? version

Location:
src
Files:
2 added
8 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`
  • src/Makefile.in

    r37eef7a rd8938622  
    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/Print.$(OBJEXT) AST/Stmt.$(OBJEXT) AST/Type.$(OBJEXT) \
    172         AST/TypeSubstitution.$(OBJEXT)
     169        AST/Expr.$(OBJEXT) AST/GenericSubstitution.$(OBJEXT) \
     170        AST/Init.$(OBJEXT) AST/LinkageSpec.$(OBJEXT) \
     171        AST/Node.$(OBJEXT) AST/Print.$(OBJEXT) AST/Stmt.$(OBJEXT) \
     172        AST/Type.$(OBJEXT) AST/TypeSubstitution.$(OBJEXT)
    173173am__objects_2 = CodeGen/CodeGenerator.$(OBJEXT) \
    174174        CodeGen/FixMain.$(OBJEXT) CodeGen/GenType.$(OBJEXT) \
     
    574574        AST/DeclReplacer.cpp \
    575575        AST/Expr.cpp \
     576        AST/GenericSubstitution.cpp \
    576577        AST/Init.cpp \
    577578        AST/LinkageSpec.cpp \
     
    738739        AST/$(DEPDIR)/$(am__dirstamp)
    739740AST/Expr.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp)
     741AST/GenericSubstitution.$(OBJEXT): AST/$(am__dirstamp) \
     742        AST/$(DEPDIR)/$(am__dirstamp)
    740743AST/Init.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp)
    741744AST/LinkageSpec.$(OBJEXT): AST/$(am__dirstamp) \
     
    11711174@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/DeclReplacer.Po@am__quote@
    11721175@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Expr.Po@am__quote@
     1176@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/GenericSubstitution.Po@am__quote@
    11731177@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Init.Po@am__quote@
    11741178@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/LinkageSpec.Po@am__quote@
Note: See TracChangeset for help on using the changeset viewer.