当前位置: 首页>>代码示例>>C++>>正文


C++ ASTType::isArray方法代码示例

本文整理汇总了C++中ASTType::isArray方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTType::isArray方法的具体用法?C++ ASTType::isArray怎么用?C++ ASTType::isArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ASTType的用法示例。


在下文中一共展示了ASTType::isArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getLongTy

//TODO XXX
ASTType *DotExpression::getType() {
    if(rhs == "sizeof" || rhs == "offsetof") {
        return ASTType::getLongTy();
    }

    ASTType *lhstype = lhs->getType();

    if(rhs == "ptr" && lhstype->isArray()) {
        return lhstype->asArray()->arrayOf->getPointerTy();
    }

    if(rhs == "size" && lhstype->isArray()) {
        return ASTType::getLongTy();
    }


    //if type is pointer, implicit dereference on dot expression
    if(lhstype->asPointer()) {
        lhstype = lhstype->asPointer()->ptrTo;
    }

    if(ASTUserType *uty = lhstype->asUserType()) {
        Identifier *dotid = uty->getDeclaration()->lookup(rhs);
        if(dotid) return dotid->getType();
    }

    return NULL;
}
开发者ID:bsurmanski,项目名称:wlc,代码行数:29,代码来源:ast.cpp

示例2:

    virtual ASTType *getType() {
        if(type->isArray()) return type; //XXX bit silly?
        if(alloc == STACK) return type;

        //else heap alloc
        return type->getReferenceTy();
    }
开发者ID:bsurmanski,项目名称:wlc,代码行数:7,代码来源:ast.hpp

示例3: determineArrayDimension

void ASTType::determineArrayDimension()
{
   mArrayDimension = 1;
   ASTType* ptype = mpArrayType;
   while ( ptype->isArray() )
   {
      ptype = ptype->mpArrayType;
      mArrayDimension++;
   }
}
开发者ID:crafter2d,项目名称:crafter2d,代码行数:10,代码来源:asttype.cpp

示例4: validateNullConcatenate

void OOCheckVisitor::validateNullConcatenate(ASTConcatenate& concatenate, const ASTType& left, const ASTType& right)
{
   bool haserror = false;

   if ( left.isNull() )
   {
      haserror = ( !right.isObject() && !right.isArray() );

      if ( concatenate.getMode() == ASTConcatenate::eEquals || concatenate.getMode() == ASTConcatenate::eUnequals )
      {
         // swap left/right side so null is always on righthand side (easier for code generation)
         concatenate.swapSides();
      }
   }
   else if ( right.isNull() )
   {
      haserror = ( !left.isObject() && !left.isArray() );
   }

   if ( haserror )
   {
      error(E0058, UTEXT("Invalid concatenation with null operator! Only == and != are supported."), concatenate);
   }
}
开发者ID:crafter2d,项目名称:crafter2d,代码行数:24,代码来源:oocheckvisitor.cpp

示例5: greater

/// \brief Test whether that is greater than this type
bool ASTType::greater(const ASTType& that) const
{
   if ( isNull() && (that.isObject() || that.isArray() || that.isString() || that.isGeneric()) )
   {
      return true;
   }
   else if ( isObject() && that.isObject() )
   {
      // check if 'that' is a extending or implemented this

      if ( !(mTypeArguments == that.mTypeArguments) )
      {
         return false;
      }

      return getObjectClass().isBase(that.getObjectClass()) 
          || getObjectClass().isImplementing(that.getObjectClass());
   }
   else if ( isArray() && that.isArray() )
   {
      return mpArrayType->equals(*that.mpArrayType) && mArrayDimension == that.mArrayDimension;
   }
   else if ( isGeneric() )
   {
      if ( that.isObject() )
      {
          return that.getObjectName() == UTEXT("system.Object"); // object is greater than a generic (its da uber type)
      }
      else if ( that.isGeneric() )
      {
         return mObjectName == that.mObjectName;
      }
   }
   else if ( !isObject() && !that.isObject() )
   {
      switch ( that.mKind )
      {
         case eBoolean:
            return mKind == eBoolean;

         case eInt:
            return mKind == eInt;

         case eReal:
            return mKind == eInt || mKind == eReal;

         case eChar:
            return mKind == eChar;

         case eString:
            return mKind == eString || mKind == eInt || mKind == eReal || mKind == eBoolean || mKind == eChar;
            
         default:
            break;
      }
   }

   // no implicit primitive to basic or vs yet

   return false;
}
开发者ID:crafter2d,项目名称:crafter2d,代码行数:62,代码来源:asttype.cpp

示例6: visit

void SymbolCheckVisitor::visit(ASTConcatenate& ast)
{
   ast.getLeft().accept(*this);

   ASTType lefttype = mCurrentType;

   mCurrentType.clear();

   ast.getRight().accept(*this);

   switch ( ast.getMode() )
   {
      case ASTConcatenate::eMul:
      case ASTConcatenate::eDiv:
      case ASTConcatenate::eRem:
      case ASTConcatenate::ePlus:
      case ASTConcatenate::eMinus:
         {
            ASTType righttype = mCurrentType;

            mCurrentType = ASTType::greaterType(lefttype, righttype);
            if ( mCurrentType.isValid() )
            {
               // optionally add casts if necessary

               if ( mCurrentType.isChar() && lefttype.isString() )
               {
                  // add char is now allowed directly:
                  //  str = str + char  <- no casts
                  //  str = char + str  <- casts char to string
                  break;
               }

               if ( !lefttype.equals(mCurrentType) )
               {
                  ASTCast* pcast = new ASTCast();
                  pcast->setType(mCurrentType.clone());
                  pcast->setNode(ast.useLeft());

                  ast.setLeft(pcast);
               }
               if ( !righttype.equals(mCurrentType) )
               {
                  ASTCast* pcast = new ASTCast();
                  pcast->setType(mCurrentType.clone());
                  pcast->setNode(ast.useRight());

                  ast.setRight(pcast);
               }
            }
            else
            {
               String op = UTEXT("+");
               error(E0022, UTEXT("Can not execute operator ") + op + UTEXT(" on types ") + lefttype.toString() + UTEXT(" and ") + righttype.toString(), ast);
            }
         }
         break;

      case ASTConcatenate::eBitwiseOr:
      case ASTConcatenate::eBitwiseXor:
      case ASTConcatenate::eBitwiseAnd:
      case ASTConcatenate::eShiftLeft:
      case ASTConcatenate::eShiftRight:
         {
            ASTType righttype = mCurrentType;

            if ( !lefttype.isInt() || !righttype.isInt() )
            {
               error(E0023, UTEXT("Bitwise operators only operate on int values."), ast);
            }
         }
         break;

      case ASTConcatenate::eAnd:
      case ASTConcatenate::eOr:
         {
            if ( !lefttype.isBoolean() || !mCurrentType.isBoolean() )
            {
               String op = UTEXT("&&"); // add toString to Mode
               error(E0024, UTEXT("Operator ") + op + UTEXT(" requires boolean expressions."), ast);
            }
         }
         break;

      case ASTConcatenate::eEquals:
      case ASTConcatenate::eUnequals:
      case ASTConcatenate::eSmallerEqual:
      case ASTConcatenate::eSmaller:
      case ASTConcatenate::eGreater:
      case ASTConcatenate::eGreaterEqual:
         {
            ASTType comp = ASTType::greaterType(lefttype, mCurrentType);
            if ( !comp.isValid() )
            {
               error(E0025, UTEXT("Can not compare ") + lefttype.toString() + UTEXT(" with ") + mCurrentType.toString(), ast);
            }
            else if ( ast.getMode() >= ASTConcatenate::eSmallerEqual )
            {
               if ( comp.isObject() || comp.isArray() || comp.isBoolean() )
               {
//.........这里部分代码省略.........
开发者ID:crafter2d,项目名称:crafter2d,代码行数:101,代码来源:symbolcheckstep.cpp


注:本文中的ASTType::isArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。