From cadd98f860e0c9110b6d38717599a4fdfb489654 Mon Sep 17 00:00:00 2001 From: "bak@chromium.org" Date: Fri, 15 May 2009 14:58:02 +0000 Subject: [PATCH] M src/jump-target.cc M src/parser.cc git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1975 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/jump-target.cc | 2 +- src/parser.cc | 135 +++++++++++++++++++++++++++++++-------------- 2 files changed, 95 insertions(+), 42 deletions(-) diff --git a/src/jump-target.cc b/src/jump-target.cc index 643de9325..54ce57a83 100644 --- a/src/jump-target.cc +++ b/src/jump-target.cc @@ -104,7 +104,7 @@ void JumpTarget::ComputeEntryFrame(int mergable_elements) { // A list of pointers to frame elements in the entry frame. NULL // indicates that the element has not yet been determined. int length = initial_frame->elements_.length(); - List elements(length); + ZoneList elements(length); // Convert the number of mergable elements (counted from the top // down) to a frame high-water mark (counted from the bottom up). diff --git a/src/parser.cc b/src/parser.cc index 2ad1109dc..ca7a28406 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -42,9 +42,51 @@ namespace v8 { namespace internal { class ParserFactory; class ParserLog; class TemporaryScope; +class Target; + template class ZoneListWrapper; +// PositionStack is used for on-stack allocation of token positions for +// new expressions. Please look at ParseNewExpression. + +class PositionStack { + public: + explicit PositionStack(bool* ok) : top_(NULL), ok_(ok) {} + ~PositionStack() { ASSERT(!*ok_ || is_empty()); } + + class Element { + public: + Element(PositionStack* stack, int value) { + previous_ = stack->top(); + value_ = value; + stack->set_top(this); + } + + private: + Element* previous() { return previous_; } + int value() { return value_; } + friend class PositionStack; + Element* previous_; + int value_; + }; + + bool is_empty() { return top_ == NULL; } + int pop() { + ASSERT(!is_empty()); + int result = top_->value(); + top_ = top_->previous(); + return result; + } + + private: + Element* top() { return top_; } + void set_top(Element* value) { top_ = value; } + Element* top_; + bool* ok_; +}; + + class Parser { public: Parser(Handle