Author: olehougaard
Date: Mon Dec 15 00:55:35 2008
New Revision: 976
Modified:
branches/bleeding_edge/src/codegen-ia32.cc
branches/bleeding_edge/src/utils.h
Log:
Introduced a TempAssign utility because I just couldn't watch this anymore.
YMMV.
Review URL: http://codereview.chromium.org/14422
Modified: branches/bleeding_edge/src/codegen-ia32.cc
==============================================================================
--- branches/bleeding_edge/src/codegen-ia32.cc (original)
+++ branches/bleeding_edge/src/codegen-ia32.cc Mon Dec 15 00:55:35 2008
@@ -2057,10 +2057,9 @@
}
// Generate code for the statements in the try block.
- bool was_inside_try = is_inside_try_;
- is_inside_try_ = true;
- VisitStatements(node->try_block()->statements());
- is_inside_try_ = was_inside_try;
+ { TempAssign<bool> temp(&is_inside_try_, true);
+ VisitStatements(node->try_block()->statements());
+ }
// Stop the introduced shadowing and count the number of required
unlinks.
// After shadowing stops, the original labels are unshadowed and the
@@ -2155,10 +2154,9 @@
}
// Generate code for the statements in the try block.
- bool was_inside_try = is_inside_try_;
- is_inside_try_ = true;
- VisitStatements(node->try_block()->statements());
- is_inside_try_ = was_inside_try;
+ { TempAssign<bool> temp(&is_inside_try_, true);
+ VisitStatements(node->try_block()->statements());
+ }
// Stop the introduced shadowing and count the number of required
unlinks.
// After shadowing stops, the original labels are unshadowed and the
Modified: branches/bleeding_edge/src/utils.h
==============================================================================
--- branches/bleeding_edge/src/utils.h (original)
+++ branches/bleeding_edge/src/utils.h Mon Dec 15 00:55:35 2008
@@ -372,6 +372,23 @@
};
+// A temporary assignment sets a (non-local) variable to a value on
+// construction and resets it the value on destruction.
+template <typename T>
+class TempAssign {
+ public:
+ TempAssign(T* var, T value): var_(var), old_value_(*var) {
+ *var = value;
+ }
+
+ ~TempAssign() { *var_ = old_value_; }
+
+ private:
+ T* var_;
+ T old_value_;
+};
+
+
template <typename T, int kSize>
class EmbeddedVector : public Vector<T> {
public:
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---