1 /* 2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Copyright (C) 2007-2008 - DIGITEO - Bruno JOFRET 4 * 5 * Copyright (C) 2012 - 2016 - Scilab Enterprises 6 * 7 * This file is hereby licensed under the terms of the GNU GPL v2.0, 8 * pursuant to article 5.3.4 of the CeCILL v.2.1. 9 * This file was originally licensed under the terms of the CeCILL v2.1, 10 * and continues to be available under such terms. 11 * For more information, see the COPYING file which you should have received 12 * along with this program. 13 * 14 */ 15 16 #ifndef AST_TRANSPOSEEXP_HXX 17 #define AST_TRANSPOSEEXP_HXX 18 19 #include "mathexp.hxx" 20 21 namespace ast 22 { 23 /** \brief Abstract a Transpose Expression node. 24 ** 25 ** \b Example: ~a */ 26 class TransposeExp : public MathExp 27 { 28 public: 29 /* \brief Conjugate or not transposition */ 30 enum Kind 31 { 32 /** \brief Conjugate transpose */ _Conjugate_, 33 /** \brief NonConjugate transpose */ _NonConjugate_ 34 }; 35 /** \name Ctor & dtor. 36 ** \{ */ 37 public: 38 /** \brief Construct an Transpose Expression node. 39 ** \param location scanner position informations 40 ** \param exp expression of the Transpose operator 41 ** \param kind indicate if should be conjugated or not 42 ** 43 ** \b Example: a' 44 */ TransposeExp(const Location & location,Exp & exp,Kind kind)45 TransposeExp (const Location& location, 46 Exp& exp, 47 Kind kind) 48 : MathExp (location), 49 _conjugate (kind) 50 { 51 exp.setParent(this); 52 _exps.push_back(&exp); 53 } 54 55 /** \brief Destroy a Transpose Operation Expression node. 56 ** 57 ** Delete expression, see constructor. */ ~TransposeExp()58 virtual ~TransposeExp () 59 { 60 } 61 /** \} */ 62 clone()63 virtual TransposeExp* clone() 64 { 65 TransposeExp* cloned = new TransposeExp(getLocation(), *getExp().clone(), getConjugate()); 66 cloned->setVerbose(isVerbose()); 67 return cloned; 68 } 69 70 /** \name Visitors entry point. 71 ** \{ */ 72 public: 73 /** \brief Accept a const visitor \a v. */ accept(Visitor & v)74 virtual void accept (Visitor& v) 75 { 76 v.visit (*this); 77 } 78 /** \brief Accept a non-const visitor \a v. */ accept(ConstVisitor & v) const79 virtual void accept (ConstVisitor& v) const 80 { 81 v.visit (*this); 82 } 83 /** \} */ 84 85 86 /** \name Accessors. 87 ** \{ */ 88 public: 89 /** \brief Return the expression of the operation (read only) */ getExp() const90 const Exp& getExp() const 91 { 92 return *_exps[0]; 93 } 94 /** \brief Return the expression of the operation (read and write) */ getExp()95 Exp& getExp() 96 { 97 return *_exps[0]; 98 } 99 /** \brief Return the conjugate kind of the transposition */ getConjugate() const100 Kind getConjugate() const 101 { 102 return _conjugate; 103 } 104 getType() const105 virtual ExpType getType() const 106 { 107 return TRANSPOSEEXP; 108 } isTransposeExp() const109 inline bool isTransposeExp() const 110 { 111 return true; 112 } 113 protected: 114 Kind _conjugate; 115 }; 116 117 } // namespace ast 118 119 #endif // !AST_TRANSPOSEEXP_HXX 120