Changeset 7f5566b for src/SynTree
- Timestamp:
- Jul 30, 2015, 3:56:18 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 093f1a0
- Parents:
- 51b986f
- Location:
- src/SynTree
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Constant.cc
r51b986f r7f5566b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Jun 10 14:41:03201513 // Update Count : 811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 30 15:18:38 2015 13 // Update Count : 12 14 14 // 15 15 … … 22 22 Constant::Constant( Type *type_, std::string value_ ) : type( type_ ), value( value_ ) {} 23 23 24 Constant::~Constant() {} 24 Constant::Constant( const Constant &other ) { 25 type = other.type->clone(); 26 value = other.value; 27 } 25 28 26 Constant *Constant::clone() const { return 0; } 29 Constant::~Constant() { delete type; } 30 31 Constant *Constant::clone() const { assert( false ); return 0; } 27 32 28 33 void Constant::print( std::ostream &os ) const { -
src/SynTree/Constant.h
r51b986f r7f5566b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 18 08:46:37201513 // Update Count : 212 // Last Modified On : Thu Jul 30 15:19:16 2015 13 // Update Count : 5 14 14 // 15 15 … … 24 24 public: 25 25 Constant( Type *type, std::string value ); 26 Constant( const Constant &other ); 26 27 virtual ~Constant(); 27 28 -
src/SynTree/Expression.cc
r51b986f r7f5566b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jun 7 08:40:46201513 // Update Count : 1612 // Last Modified On : Tue Jul 28 16:27:17 2015 13 // Update Count : 22 14 14 // 15 15 … … 38 38 Expression::~Expression() { 39 39 delete env; 40 //delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix40 delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix 41 41 deleteAll( results ); 42 42 } … … 332 332 } 333 333 334 void AsmExpr::print( std::ostream &os, int indent ) const { 335 os << "Asm Expression: " << std::endl; 336 if ( inout ) inout->print( os, indent + 2 ); 337 if ( constraint ) constraint->print( os, indent + 2 ); 338 if ( operand ) operand->print( os, indent + 2 ); 339 } 340 334 341 void UntypedValofExpr::print( std::ostream &os, int indent ) const { 335 342 os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl; -
src/SynTree/Expression.h
r51b986f r7f5566b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jun 7 22:03:44201513 // Update Count : 412 // Last Modified On : Fri Jul 24 13:49:28 2015 13 // Update Count : 18 14 14 // 15 15 … … 30 30 31 31 std::list<Type *>& get_results() { return results; } 32 void add_result( Type *t);32 void add_result( Type *t ); 33 33 34 34 TypeSubstitution *get_env() const { return env; } … … 446 446 }; 447 447 448 // AsmExpr represents a GCC 'asm constraint operand' used in an asm statement: [output] "=f" (result) 449 class AsmExpr : public Expression { 450 public: 451 AsmExpr( Expression *inout, ConstantExpr *constraint, Expression *operand ) : inout( inout ), constraint( constraint ), operand( operand ) {} 452 virtual ~AsmExpr() { delete inout; delete constraint; delete operand; }; 453 454 Expression *get_inout() const { return inout; } 455 void set_inout( Expression *newValue ) { inout = newValue; } 456 457 ConstantExpr *get_constraint() const { return constraint; } 458 void set_constraint( ConstantExpr *newValue ) { constraint = newValue; } 459 460 Expression *get_operand() const { return operand; } 461 void set_operand( Expression *newValue ) { operand = newValue; } 462 463 virtual AsmExpr *clone() const { return new AsmExpr( *this ); } 464 virtual void accept( Visitor &v ) { v.visit( this ); } 465 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 466 virtual void print( std::ostream &os, int indent = 0 ) const; 467 private: 468 // https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Machine-Constraints.html#Machine-Constraints 469 Expression *inout; 470 ConstantExpr *constraint; 471 Expression *operand; 472 }; 473 448 474 // ValofExpr represents a GCC 'lambda expression' 449 475 class UntypedValofExpr : public Expression { -
src/SynTree/Mutator.cc
r51b986f r7f5566b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 16 16:10:54201513 // Update Count : 312 // Last Modified On : Sat Jul 25 19:21:33 2015 13 // Update Count : 11 14 14 // 15 15 … … 95 95 } 96 96 97 Statement *Mutator::mutate( AsmStmt *asmStmt ) { 98 asmStmt->set_instruction( maybeMutate( asmStmt->get_instruction(), *this ) ); 99 mutateAll( asmStmt->get_output(), *this ); 100 mutateAll( asmStmt->get_input(), *this ); 101 mutateAll( asmStmt->get_clobber(), *this ); 102 return asmStmt; 103 } 104 97 105 Statement *Mutator::mutate( IfStmt *ifStmt ) { 98 106 ifStmt->set_condition( maybeMutate( ifStmt->get_condition(), *this ) ); … … 291 299 typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) ); 292 300 return typeExpr; 301 } 302 303 Expression *Mutator::mutate( AsmExpr *asmExpr ) { 304 asmExpr->set_inout( maybeMutate( asmExpr->get_inout(), *this ) ); 305 asmExpr->set_constraint( maybeMutate( asmExpr->get_constraint(), *this ) ); 306 asmExpr->set_operand( maybeMutate( asmExpr->get_operand(), *this ) ); 307 return asmExpr; 293 308 } 294 309 -
src/SynTree/Mutator.h
r51b986f r7f5566b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 13 18:14:47201513 // Update Count : 512 // Last Modified On : Thu Jul 23 23:24:18 2015 13 // Update Count : 7 14 14 // 15 15 #include <cassert> … … 37 37 virtual CompoundStmt* mutate( CompoundStmt *compoundStmt ); 38 38 virtual Statement* mutate( ExprStmt *exprStmt ); 39 virtual Statement* mutate( AsmStmt *asmStmt ); 39 40 virtual Statement* mutate( IfStmt *ifStmt ); 40 41 virtual Statement* mutate( WhileStmt *whileStmt ); … … 70 71 virtual Expression* mutate( SolvedTupleExpr *tupleExpr ); 71 72 virtual Expression* mutate( TypeExpr *typeExpr ); 73 virtual Expression* mutate( AsmExpr *asmExpr ); 72 74 virtual Expression* mutate( UntypedValofExpr *valofExpr ); 73 75 -
src/SynTree/Statement.cc
r51b986f r7f5566b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Jul 15 14:57:40 201513 // Update Count : 2711 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 25 12:19:50 2015 13 // Update Count : 53 14 14 // 15 15 … … 42 42 expr->print( os, indent + 2 ); 43 43 } 44 45 46 AsmStmt::AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement( labels ), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {} 47 48 AsmStmt::~AsmStmt() { 49 delete instruction; 50 deleteAll( output ); 51 deleteAll( input ); 52 deleteAll( clobber ); 53 } 54 55 void AsmStmt::print( std::ostream &os, int indent ) const { 56 os << "Assembler Statement:" << endl; 57 os << std::string( indent, ' ' ) << "instruction: " << endl << std::string( indent, ' ' ); 58 instruction->print( os, indent + 2 ); 59 if ( ! output.empty() ) { 60 os << endl << std::string( indent, ' ' ) << "output: " << endl; 61 printAll( output, os, indent + 2 ); 62 } // if 63 if ( ! input.empty() ) { 64 os << std::string( indent, ' ' ) << "input: " << endl << std::string( indent, ' ' ); 65 printAll( input, os, indent + 2 ); 66 } // if 67 if ( ! clobber.empty() ) { 68 os << std::string( indent, ' ' ) << "clobber: " << endl; 69 printAll( clobber, os, indent + 2 ); 70 } // if 71 } 72 44 73 45 74 const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" }; -
src/SynTree/Statement.h
r51b986f r7f5566b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Tue Jul 14 12:14:54201513 // Update Count : 2411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 25 18:25:37 2015 13 // Update Count : 44 14 14 // 15 15 … … 70 70 }; 71 71 72 class AsmStmt : public Statement { 73 public: 74 AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *instruction, std::list<Expression *> input, std::list<Expression *> output, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ); 75 virtual ~AsmStmt(); 76 77 bool get_voltile() { return voltile; } 78 void set_voltile( bool newValue ) { voltile = newValue; } 79 ConstantExpr *get_instruction() { return instruction; } 80 void set_instruction( ConstantExpr *newValue ) { instruction = newValue; } 81 std::list<Expression *> &get_output() { return output; } 82 void set_output( const std::list<Expression *> &newValue ) { output = newValue; } 83 std::list<Expression *> &get_input() { return input; } 84 void set_input( const std::list<Expression *> &newValue ) { input = newValue; } 85 std::list<ConstantExpr *> &get_clobber() { return clobber; } 86 void set_clobber( const std::list<ConstantExpr *> &newValue ) { clobber = newValue; } 87 std::list<Label> &get_gotolabels() { return gotolabels; } 88 void set_gotolabels( const std::list<Label> &newValue ) { gotolabels = newValue; } 89 90 virtual AsmStmt *clone() const { return new AsmStmt( *this ); } 91 virtual void accept( Visitor &v ) { v.visit( this ); } 92 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 93 virtual void print( std::ostream &os, int indent = 0 ) const; 94 private: 95 bool voltile; 96 ConstantExpr *instruction; 97 std::list<Expression *> output, input; 98 std::list<ConstantExpr *> clobber; 99 std::list<Label> gotolabels; 100 }; 101 72 102 class IfStmt : public Statement { 73 103 public: … … 100 130 void set_condition( Expression *newValue ) { condition = newValue; } 101 131 102 std::list<Statement *> & get_branches() { return branches; }132 std::list<Statement *> & get_branches() { return branches; } 103 133 void add_case( CaseStmt * ); 104 134 -
src/SynTree/SynTree.h
r51b986f r7f5566b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 18 10:58:22201513 // Update Count : 112 // Last Modified On : Thu Jul 23 23:25:04 2015 13 // Update Count : 3 14 14 // 15 15 … … 40 40 class CompoundStmt; 41 41 class ExprStmt; 42 class AsmStmt; 42 43 class IfStmt; 43 44 class WhileStmt; … … 75 76 class SolvedTupleExpr; 76 77 class TypeExpr; 78 class AsmExpr; 77 79 class UntypedValofExpr; 78 80 -
src/SynTree/Visitor.cc
r51b986f r7f5566b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Tue Jul 14 12:31:03201513 // Update Count : 311 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 24 16:11:05 2015 13 // Update Count : 15 14 14 // 15 15 … … 82 82 } 83 83 84 void Visitor::visit( AsmStmt *asmStmt ) { 85 maybeAccept( asmStmt->get_instruction(), *this ); 86 acceptAll( asmStmt->get_output(), *this ); 87 acceptAll( asmStmt->get_input(), *this ); 88 acceptAll( asmStmt->get_clobber(), *this ); 89 } 90 84 91 void Visitor::visit( IfStmt *ifStmt ) { 85 92 maybeAccept( ifStmt->get_condition(), *this ); … … 246 253 } 247 254 255 void Visitor::visit( AsmExpr *asmExpr ) { 256 maybeAccept( asmExpr->get_inout(), *this ); 257 maybeAccept( asmExpr->get_constraint(), *this ); 258 maybeAccept( asmExpr->get_operand(), *this ); 259 } 260 248 261 void Visitor::visit( UntypedValofExpr *valofExpr ) { 249 262 acceptAll( valofExpr->get_results(), *this ); … … 282 295 283 296 void Visitor::visit( StructInstType *aggregateUseType ) { 284 visit( static_cast< ReferenceToType * >( aggregateUseType ) );297 visit( static_cast< ReferenceToType * >( aggregateUseType ) ); 285 298 } 286 299 287 300 void Visitor::visit( UnionInstType *aggregateUseType ) { 288 visit( static_cast< ReferenceToType * >( aggregateUseType ) );301 visit( static_cast< ReferenceToType * >( aggregateUseType ) ); 289 302 } 290 303 291 304 void Visitor::visit( EnumInstType *aggregateUseType ) { 292 visit( static_cast< ReferenceToType * >( aggregateUseType ) );305 visit( static_cast< ReferenceToType * >( aggregateUseType ) ); 293 306 } 294 307 295 308 void Visitor::visit( ContextInstType *aggregateUseType ) { 296 visit( static_cast< ReferenceToType * >( aggregateUseType ) );309 visit( static_cast< ReferenceToType * >( aggregateUseType ) ); 297 310 acceptAll( aggregateUseType->get_members(), *this ); 298 311 } 299 312 300 313 void Visitor::visit( TypeInstType *aggregateUseType ) { 301 visit( static_cast< ReferenceToType * >( aggregateUseType ) );314 visit( static_cast< ReferenceToType * >( aggregateUseType ) ); 302 315 } 303 316 -
src/SynTree/Visitor.h
r51b986f r7f5566b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 18 11:15:55201513 // Update Count : 212 // Last Modified On : Thu Jul 23 23:22:23 2015 13 // Update Count : 4 14 14 // 15 15 … … 37 37 virtual void visit( CompoundStmt *compoundStmt ); 38 38 virtual void visit( ExprStmt *exprStmt ); 39 virtual void visit( AsmStmt *asmStmt ); 39 40 virtual void visit( IfStmt *ifStmt ); 40 41 virtual void visit( WhileStmt *whileStmt ); … … 70 71 virtual void visit( SolvedTupleExpr *tupleExpr ); 71 72 virtual void visit( TypeExpr *typeExpr ); 73 virtual void visit( AsmExpr *asmExpr ); 72 74 virtual void visit( UntypedValofExpr *valofExpr ); 73 75
Note: See TracChangeset
for help on using the changeset viewer.