Chromium Code Reviews| Index: vm/intermediate_language.h |
| =================================================================== |
| --- vm/intermediate_language.h (revision 8386) |
| +++ vm/intermediate_language.h (working copy) |
| @@ -139,6 +139,29 @@ |
| static LocationSummary* MakeCallSummary(); |
| + // Declare an enum value used to define type-test predicates. |
| + enum ComputationType { |
| +#define DECLARE_COMPUTATION_TYPE(ShortName, ClassName) k##ShortName, |
| + |
| + FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_TYPE) |
| + |
| +#undef DECLARE_COMPUTATION_TYPE |
| + }; |
| + |
| + virtual ComputationType computation_type() const = 0; |
| + |
| + // Declare predicate for each computation. |
| +#define DECLARE_PREDICATE(ShortName, ClassName) \ |
| + bool Is##ShortName() const { return computation_type() == k##ShortName; } \ |
| + ClassName* As##ShortName() { \ |
| + if (!Is##ShortName()) return NULL; \ |
| + return reinterpret_cast<ClassName*>(this); \ |
|
Vyacheslav Egorov (Google)
2012/06/07 12:07:16
this should be static_cast.
Florian Schneider
2012/06/07 12:31:47
Done.
|
| + } |
| + |
| + FOR_EACH_COMPUTATION(DECLARE_PREDICATE) |
| + |
| +#undef DECLARE_PREDICATE |
| + |
| private: |
| friend class Instruction; |
| static intptr_t GetNextCid(Isolate* isolate) { |
| @@ -236,13 +259,6 @@ |
| public: |
| Value() { } |
| -#define DEFINE_TESTERS(ShortName, ClassName) \ |
| - virtual ClassName* As##ShortName() { return NULL; } \ |
| - bool Is##ShortName() { return As##ShortName() != NULL; } |
| - |
| - FOR_EACH_VALUE(DEFINE_TESTERS) |
| -#undef DEFINE_TESTERS |
| - |
| private: |
| DISALLOW_COPY_AND_ASSIGN(Value); |
| }; |
| @@ -251,6 +267,9 @@ |
| // Functions defined in all concrete computation classes. |
| #define DECLARE_COMPUTATION(ShortName) \ |
| virtual void Accept(FlowGraphVisitor* visitor); \ |
| + virtual ComputationType computation_type() const { \ |
| + return Computation::k##ShortName; \ |
| + } \ |
| virtual const char* DebugName() const { return #ShortName; } \ |
| virtual RawAbstractType* StaticType() const; \ |
| virtual LocationSummary* MakeLocationSummary() const; \ |
| @@ -259,7 +278,6 @@ |
| // Functions defined in all concrete value classes. |
| #define DECLARE_VALUE(ShortName) \ |
| DECLARE_COMPUTATION(ShortName) \ |
| - virtual ShortName##Val* As##ShortName() { return this; } \ |
| virtual void PrintTo(BufferFormatter* f) const; |
| @@ -516,7 +534,7 @@ |
| inputs_[1] = right; |
| } |
| - DECLARE_COMPUTATION(EqualityCompareComp) |
| + DECLARE_COMPUTATION(EqualityCompare) |
| intptr_t token_index() const { return token_index_; } |
| intptr_t try_index() const { return try_index_; } |