Changeset 6e50a6b for src/SynTree


Ignore:
Timestamp:
Jun 18, 2021, 12:20:59 PM (4 years ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
c7d8696a
Parents:
dcbfcbc
Message:

Implementing language-provided syntax for (array) dimensions.

Former z(i) and Z(N) macros are eliminated.

Location:
src/SynTree
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Declaration.h

    rdcbfcbc r6e50a6b  
    201201        typedef NamedTypeDecl Parent;
    202202  public:
    203         enum Kind { Dtype, DStype, Otype, Ftype, Ttype, ALtype, NUMBER_OF_KINDS };
     203        enum Kind { Dtype, DStype, Otype, Ftype, Ttype, Dimension, NUMBER_OF_KINDS };
    204204
    205205        Kind kind;
  • src/SynTree/Expression.h

    rdcbfcbc r6e50a6b  
    587587};
    588588
     589/// DimensionExpr represents a type-system provided value used in an expression ( forrall([N]) ... N + 1 )
     590class DimensionExpr : public Expression {
     591  public:
     592        std::string name;
     593
     594        DimensionExpr( std::string name );
     595        DimensionExpr( const DimensionExpr & other );
     596        virtual ~DimensionExpr();
     597
     598        const std::string & get_name() const { return name; }
     599        void set_name( std::string newValue ) { name = newValue; }
     600
     601        virtual DimensionExpr * clone() const override { return new DimensionExpr( * this ); }
     602        virtual void accept( Visitor & v ) override { v.visit( this ); }
     603        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     604        virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     605        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     606};
     607
    589608/// AsmExpr represents a GCC 'asm constraint operand' used in an asm statement: [output] "=f" (result)
    590609class AsmExpr : public Expression {
  • src/SynTree/Mutator.h

    rdcbfcbc r6e50a6b  
    8080        virtual Expression * mutate( CommaExpr * commaExpr ) = 0;
    8181        virtual Expression * mutate( TypeExpr * typeExpr ) = 0;
     82        virtual Expression * mutate( DimensionExpr * dimensionExpr ) = 0;
    8283        virtual Expression * mutate( AsmExpr * asmExpr ) = 0;
    8384        virtual Expression * mutate( ImplicitCopyCtorExpr * impCpCtorExpr ) = 0;
  • src/SynTree/SynTree.h

    rdcbfcbc r6e50a6b  
    8585class CommaExpr;
    8686class TypeExpr;
     87class DimensionExpr;
    8788class AsmExpr;
    8889class ImplicitCopyCtorExpr;
  • src/SynTree/TypeDecl.cc

    rdcbfcbc r6e50a6b  
    3333
    3434const char * TypeDecl::typeString() const {
    35         static const char * kindNames[] = { "sized data type", "sized data type", "sized object type", "sized function type", "sized tuple type", "sized array length type" };
     35        static const char * kindNames[] = { "sized data type", "sized data type", "sized object type", "sized function type", "sized tuple type", "sized length value" };
    3636        static_assert( sizeof(kindNames) / sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "typeString: kindNames is out of sync." );
    3737        assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." );
  • src/SynTree/TypeExpr.cc

    rdcbfcbc r6e50a6b  
    3535}
    3636
     37DimensionExpr::DimensionExpr( std::string name ) : Expression(), name(name) {
     38        assertf(name != "0", "Zero is not a valid name");
     39        assertf(name != "1", "One is not a valid name");
     40}
     41
     42DimensionExpr::DimensionExpr( const DimensionExpr & other ) : Expression( other ), name( other.name ) {
     43}
     44
     45DimensionExpr::~DimensionExpr() {}
     46
     47void DimensionExpr::print( std::ostream & os, Indenter indent ) const {
     48        os << "Type-Sys Value: " << get_name();
     49        Expression::print( os, indent );
     50}
    3751// Local Variables: //
    3852// tab-width: 4 //
  • src/SynTree/Visitor.h

    rdcbfcbc r6e50a6b  
    135135        virtual void visit( TypeExpr * node ) { visit( const_cast<const TypeExpr *>(node) ); }
    136136        virtual void visit( const TypeExpr * typeExpr ) = 0;
     137        virtual void visit( DimensionExpr * node ) { visit( const_cast<const DimensionExpr *>(node) ); }
     138        virtual void visit( const DimensionExpr * typeExpr ) = 0;
    137139        virtual void visit( AsmExpr * node ) { visit( const_cast<const AsmExpr *>(node) ); }
    138140        virtual void visit( const AsmExpr * asmExpr ) = 0;
Note: See TracChangeset for help on using the changeset viewer.