projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Kerning.
[oota-llvm.git]
/
docs
/
HowToSetUpLLVMStyleRTTI.rst
diff --git
a/docs/HowToSetUpLLVMStyleRTTI.rst
b/docs/HowToSetUpLLVMStyleRTTI.rst
index a3403c2fc1d047563a84406cbd2bf9c720ef0a6f..aa1ad84afee352fb890feff58f34321b9eeadfd3 100644
(file)
--- a/
docs/HowToSetUpLLVMStyleRTTI.rst
+++ b/
docs/HowToSetUpLLVMStyleRTTI.rst
@@
-77,8
+77,8
@@
steps:
public:
+ /// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
+ enum ShapeKind {
public:
+ /// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
+ enum ShapeKind {
- + S
quareKind
,
- +
CircleKind
+ + S
K_Square
,
+ +
SK_Circle
+ };
+private:
+ const ShapeKind Kind;
+ };
+private:
+ const ShapeKind Kind;
@@
-121,8
+121,8
@@
steps:
public:
/// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
enum ShapeKind {
public:
/// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
enum ShapeKind {
- S
quareKind
,
- CircleKind
+ S
K_Square
,
+ SK_Circle
};
private:
const ShapeKind Kind;
};
private:
const ShapeKind Kind;
@@
-138,7
+138,7
@@
steps:
double SideLength;
public:
- Square(double S) : SideLength(S) {}
double SideLength;
public:
- Square(double S) : SideLength(S) {}
- + Square(double S) : Shape(S
quareKind
), SideLength(S) {}
+ + Square(double S) : Shape(S
K_Square
), SideLength(S) {}
double computeArea() /* override */;
};
double computeArea() /* override */;
};
@@
-146,7
+146,7
@@
steps:
double Radius;
public:
- Circle(double R) : Radius(R) {}
double Radius;
public:
- Circle(double R) : Radius(R) {}
- + Circle(double R) : Shape(
CircleKind
), Radius(R) {}
+ + Circle(double R) : Shape(
SK_Circle
), Radius(R) {}
double computeArea() /* override */;
};
double computeArea() /* override */;
};
@@
-163,8
+163,8
@@
steps:
public:
/// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
enum ShapeKind {
public:
/// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
enum ShapeKind {
- S
quareKind
,
- CircleKind
+ S
K_Square
,
+ SK_Circle
};
private:
const ShapeKind Kind;
};
private:
const ShapeKind Kind;
@@
-178,22
+178,22
@@
steps:
class Square : public Shape {
double SideLength;
public:
class Square : public Shape {
double SideLength;
public:
- Square(double S) : Shape(S
quareKind
), SideLength(S) {}
+ Square(double S) : Shape(S
K_Square
), SideLength(S) {}
double computeArea() /* override */;
+
+ static bool classof(const Shape *S) {
double computeArea() /* override */;
+
+ static bool classof(const Shape *S) {
- + return S->getKind() == S
quareKind
;
+ + return S->getKind() == S
K_Square
;
+ }
};
class Circle : public Shape {
double Radius;
public:
+ }
};
class Circle : public Shape {
double Radius;
public:
- Circle(double R) : Shape(
CircleKind
), Radius(R) {}
+ Circle(double R) : Shape(
SK_Circle
), Radius(R) {}
double computeArea() /* override */;
+
+ static bool classof(const Shape *S) {
double computeArea() /* override */;
+
+ static bool classof(const Shape *S) {
- + return S->getKind() ==
CircleKind
;
+ + return S->getKind() ==
SK_Circle
;
+ }
};
+ }
};
@@
-264,10
+264,10
@@
from ``Square``, and so ``ShapeKind`` becomes:
.. code-block:: c++
enum ShapeKind {
.. code-block:: c++
enum ShapeKind {
- S
quareKind
,
- + S
pecialSquareKind
,
- +
OtherSpecialSquareKind
,
- CircleKind
+ S
K_Square
,
+ + S
K_SpecialSquare
,
+ +
SK_OtherSpecialSquare
,
+ SK_Circle
}
Then in ``Square``, we would need to modify the ``classof`` like so:
}
Then in ``Square``, we would need to modify the ``classof`` like so:
@@
-275,11
+275,11
@@
Then in ``Square``, we would need to modify the ``classof`` like so:
.. code-block:: c++
- static bool classof(const Shape *S) {
.. code-block:: c++
- static bool classof(const Shape *S) {
- - return S->getKind() == S
quareKind
;
+ - return S->getKind() == S
K_Square
;
- }
+ static bool classof(const Shape *S) {
- }
+ static bool classof(const Shape *S) {
- + return S->getKind() >= S
quareKind
&&
- + S->getKind() <=
OtherSpecialSquareKind
;
+ + return S->getKind() >= S
K_Square
&&
+ + S->getKind() <=
SK_OtherSpecialSquare
;
+ }
The reason that we need to test a range like this instead of just equality
+ }
The reason that we need to test a range like this instead of just equality