00001 /* 00002 Copyright (c) 2009, National Institute of Advanced Industrial Science 00003 and Technology. All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without 00006 modification, are permitted provided that the following conditions are 00007 met: 00008 00009 * Redistributions of source code must retain the above copyright 00010 notice, this list of conditions and the following disclaimer. 00011 00012 * Redistributions in binary form must reproduce the above copyright 00013 notice, this list of conditions and the following disclaimer in 00014 the documentation and/or other materials provided with the 00015 distribution. 00016 00017 * Neither the name of Fixstars Corporation nor the names of its 00018 contributors may be used to endorse or promote products derived 00019 from this software without specific prior written permission. 00020 00021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00024 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00025 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00026 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00027 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00028 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00029 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00030 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00031 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 */ 00033 00034 #ifndef CFRONT_VECTOR_TYPE_HPP 00035 #define CFRONT_VECTOR_TYPE_HPP 00036 00037 #include "BasicType.hpp" 00038 00039 namespace cfront { 00040 00048 class VectorType : public Type { 00049 public: 00050 VectorType(BasicType::PrimitiveTag primitiveTag, QualFlags qualFlags) 00051 : primitiveTag_(primitiveTag), qualFlags_(qualFlags) {} 00052 VectorType(BasicType::PrimitiveTag primitiveTag) 00053 : primitiveTag_(primitiveTag), qualFlags_(0) {} 00054 VectorType(const VectorType& other) 00055 : Type(other), primitiveTag_(other.primitiveTag_), 00056 qualFlags_(other.qualFlags_) {} 00057 00058 virtual ~VectorType() {} 00059 00060 virtual VectorType* clone() const 00061 { 00062 return new VectorType(*this); 00063 } 00064 00065 virtual bool isCompatibleType(const Type* other) const 00066 { 00067 const VectorType* vo = dynamic_cast<const VectorType*>(other); 00068 if (vo == NULL) return false; 00069 return this->primitiveTag_ == vo->primitiveTag_; 00070 } 00071 00072 virtual size_t getSize(const TargetInfo& targetInfo) const 00073 { 00074 return targetInfo.getSize(TargetInfo::VECTOR); 00075 } 00076 00077 virtual size_t getAlign(const TargetInfo& targetInfo) const 00078 { 00079 return targetInfo.getAlign(TargetInfo::VECTOR); 00080 } 00081 00082 BasicType::PrimitiveTag getPrimitiveTag() const 00083 { 00084 return primitiveTag_; 00085 } 00086 00087 QualFlags getQualFlags() const 00088 { 00089 return qualFlags_; 00090 } 00091 00092 void setQualFlags(QualFlags qf) 00093 { 00094 qualFlags_ = qf; 00095 } 00096 00097 #ifdef PARSER_DEBUG 00098 virtual std::string toString() const 00099 { 00100 std::stringstream ss; 00101 ss << "VectorType[ " << primitiveTag_ << " (" << 00102 toStringQualFlags(qualFlags_) << ")]"; 00103 return ss.str(); 00104 } 00105 #endif 00106 00107 protected: 00108 BasicType::PrimitiveTag primitiveTag_; 00109 QualFlags qualFlags_; 00110 }; 00111 00112 } // namespace cfront 00113 00114 #endif 00115 00116 00117 /* 00118 * Local Variables: 00119 * mode: C++ 00120 * c-basic-offset: 4 00121 * indent-tabs-mode: nil 00122 * End: 00123 */