Changeset 033ff37 for src/SynTree
- Timestamp:
- Jul 26, 2019, 6:39:42 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- be53b87
- Parents:
- f673c13c
- Location:
- src/SynTree
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
rf673c13c r033ff37 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Feb 19 18:10:55201913 // Update Count : 6 012 // Last Modified On : Thu Jul 25 22:21:48 2019 13 // Update Count : 61 14 14 // 15 15 … … 249 249 os << "Offset pack expression on "; 250 250 type->print(os, indent+1); 251 Expression::print( os, indent );252 }253 254 AttrExpr::AttrExpr( Expression * attr, Expression * expr_ ) :255 Expression(), attr( attr ), expr(expr_), type(0), isType(false) {256 }257 258 AttrExpr::AttrExpr( Expression * attr, Type * type_ ) :259 Expression(), attr( attr ), expr(0), type(type_), isType(true) {260 }261 262 AttrExpr::AttrExpr( const AttrExpr & other ) :263 Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {264 }265 266 AttrExpr::~AttrExpr() {267 delete attr;268 delete expr;269 delete type;270 }271 272 void AttrExpr::print( std::ostream & os, Indenter indent) const {273 os << "Attr ";274 attr->print( os, indent+1);275 if ( isType || expr ) {276 os << "applied to: ";277 if (isType) type->print(os, indent+1);278 else expr->print(os, indent+1);279 } // if280 251 Expression::print( os, indent ); 281 252 } -
src/SynTree/Expression.h
rf673c13c r033ff37 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Feb 18 18:29:51201913 // Update Count : 4912 // Last Modified On : Thu Jul 25 22:21:44 2019 13 // Update Count : 50 14 14 // 15 15 … … 463 463 }; 464 464 465 /// AttrExpr represents an @attribute expression (like sizeof, but user-defined)466 class AttrExpr : public Expression {467 public:468 Expression * attr;469 Expression * expr;470 Type * type;471 bool isType;472 473 AttrExpr(Expression * attr, Expression * expr );474 AttrExpr( const AttrExpr & other );475 AttrExpr( Expression * attr, Type * type );476 virtual ~AttrExpr();477 478 Expression * get_attr() const { return attr; }479 void set_attr( Expression * newValue ) { attr = newValue; }480 Expression * get_expr() const { return expr; }481 void set_expr( Expression * newValue ) { expr = newValue; }482 Type * get_type() const { return type; }483 void set_type( Type * newValue ) { type = newValue; }484 bool get_isType() const { return isType; }485 void set_isType( bool newValue ) { isType = newValue; }486 487 virtual AttrExpr * clone() const override { return new AttrExpr( * this ); }488 virtual void accept( Visitor & v ) override { v.visit( this ); }489 virtual void accept( Visitor & v ) const override { v.visit( this ); }490 virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); }491 virtual void print( std::ostream & os, Indenter indent = {} ) const override;492 };493 494 465 /// LogicalExpr represents a short-circuit boolean expression (&& or ||) 495 466 class LogicalExpr : public Expression { -
src/SynTree/Mutator.h
rf673c13c r033ff37 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Jul 24 16:31:00 201713 // Update Count : 1 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:37:46 2019 13 // Update Count : 17 14 14 // 15 15 #pragma once … … 74 74 virtual Expression * mutate( OffsetofExpr * offsetofExpr ) = 0; 75 75 virtual Expression * mutate( OffsetPackExpr * offsetPackExpr ) = 0; 76 virtual Expression * mutate( AttrExpr * attrExpr ) = 0;77 76 virtual Expression * mutate( LogicalExpr * logicalExpr ) = 0; 78 77 virtual Expression * mutate( ConditionalExpr * conditionalExpr ) = 0; -
src/SynTree/SynTree.h
rf673c13c r033ff37 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Jul 24 16:54:00 201713 // Update Count : 1 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:37:45 2019 13 // Update Count : 12 14 14 // 15 15 … … 79 79 class OffsetofExpr; 80 80 class OffsetPackExpr; 81 class AttrExpr;82 81 class LogicalExpr; 83 82 class ConditionalExpr; -
src/SynTree/Visitor.h
rf673c13c r033ff37 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Jul 24 16:28:00 201713 // Update Count : 1 311 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:21:49 2019 13 // Update Count : 14 14 14 // 15 15 … … 123 123 virtual void visit( OffsetPackExpr * node ) { visit( const_cast<const OffsetPackExpr *>(node) ); } 124 124 virtual void visit( const OffsetPackExpr * offsetPackExpr ) = 0; 125 virtual void visit( AttrExpr * node ) { visit( const_cast<const AttrExpr *>(node) ); }126 virtual void visit( const AttrExpr * attrExpr ) = 0;127 125 virtual void visit( LogicalExpr * node ) { visit( const_cast<const LogicalExpr *>(node) ); } 128 126 virtual void visit( const LogicalExpr * logicalExpr ) = 0;
Note: See TracChangeset
for help on using the changeset viewer.