Added a new expression, OCUVectorComponent.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40577 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/Expr.cpp b/AST/Expr.cpp
index 542d4ca..11aca82 100644
--- a/AST/Expr.cpp
+++ b/AST/Expr.cpp
@@ -571,3 +571,13 @@
llvm::APSInt Val(32);
return isIntegerConstantExpr(Val, Ctx, 0, true) && Val == 0;
}
+
+OCUVectorComponent::ComponentType OCUVectorComponent::getComponentType() const {
+ // derive the component type, no need to waste space.
+ const char *compStr = Accessor.getName();
+ const OCUVectorType *VT = getType()->isOCUVectorType();
+ if (VT->isPointAccessor(*compStr)) return Point;
+ if (VT->isColorAccessor(*compStr)) return Color;
+ if (VT->isTextureAccessor(*compStr)) return Texture;
+ assert(0 && "getComponentType(): Illegal accessor");
+}