Changeset 461046f


Ignore:
Timestamp:
May 22, 2019, 1:00:28 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
3f840e3
Parents:
ca8704f
Message:

Started implementing the print visitor

Location:
src
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Bitfield.hpp

    rca8704f r461046f  
    5757};
    5858
    59 /// Adds default printing operator to a bitfield type.
    60 /// Include in definition to add print function, requires other bitfield operators.
    61 /// @param N  Number of bits in bitfield
    62 #define MakeBitfieldPrint( N ) \
    63         static const char* Names[]; \
    64  \
    65         void print( std::ostream & os ) const { \
    66                 if ( (*this).any() ) { \
    67                         for ( unsigned int i = 0; i < N; i += 1 ) { \
    68                                 if ( (*this)[i] ) { \
    69                                         os << Names[i] << ' '; \
    70                                 } \
    71                         } \
    72                 } \
    73         }
     59template<typename T>
     60inline bool operator== ( const bitfield<T> & a, const bitfield<T> & b ) {
     61        return a.val == b.val;
     62}
     63
     64template<typename T>
     65inline bool operator!= ( const bitfield<T> & a, const bitfield<T> & b ) {
     66        return !(a == b);
     67}
    7468
    7569// Local Variables: //
  • src/AST/Node.cpp

    rca8704f r461046f  
    2626#include "Type.hpp"
    2727#include "TypeSubstitution.hpp"
     28
     29#include "Print.hpp"
    2830
    2931template< typename node_t, enum ast::Node::ref_type ref_t >
     
    4749
    4850std::ostream & ast::operator<< ( std::ostream & out, const ast::Node * node ) {
    49         (void)node;
    50         #warning unimplemented
    51         assertf(false, "Unimplemented");
     51        print(out, node);
    5252        return out;
    5353}
  • src/AST/module.mk

    rca8704f r461046f  
    2424        AST/LinkageSpec.cpp \
    2525        AST/Node.cpp \
     26        AST/Print.cpp \
    2627        AST/Stmt.cpp \
    2728        AST/Type.cpp \
  • src/Makefile.in

    rca8704f r461046f  
    169169        AST/Expr.$(OBJEXT) AST/Init.$(OBJEXT) \
    170170        AST/LinkageSpec.$(OBJEXT) AST/Node.$(OBJEXT) \
    171         AST/Stmt.$(OBJEXT) AST/Type.$(OBJEXT) \
     171        AST/Print.$(OBJEXT) AST/Stmt.$(OBJEXT) AST/Type.$(OBJEXT) \
    172172        AST/TypeSubstitution.$(OBJEXT)
    173173am__objects_2 = CodeGen/CodeGenerator.$(OBJEXT) \
     
    577577        AST/LinkageSpec.cpp \
    578578        AST/Node.cpp \
     579        AST/Print.cpp \
    579580        AST/Stmt.cpp \
    580581        AST/Type.cpp \
     
    741742        AST/$(DEPDIR)/$(am__dirstamp)
    742743AST/Node.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp)
     744AST/Print.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp)
    743745AST/Stmt.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp)
    744746AST/Type.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp)
     
    11721174@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/LinkageSpec.Po@am__quote@
    11731175@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Node.Po@am__quote@
     1176@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Print.Po@am__quote@
    11741177@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Stmt.Po@am__quote@
    11751178@AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Type.Po@am__quote@
Note: See TracChangeset for help on using the changeset viewer.