Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Unified Diff: vm/intermediate_language.h

Issue 10537051: Add type testers to all IL Computation classes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_; }
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698