From 919d64adce69fa65b2d43190bbfb79ddf5afa573 Mon Sep 17 00:00:00 2001 From: "rossberg@chromium.org" Date: Thu, 6 Jun 2013 13:28:22 +0000 Subject: [PATCH] Add type field to AST expression nodes More importantly, do a bunch of renamings of incidental existing "types" to avoid actual and potential name clashes (and also to improve consistency). R=svenpanne@chromium.org BUG= Review URL: https://codereview.chromium.org/16549002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14978 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/ast.cc | 6 +- src/ast.h | 69 +++++++++++---------- src/factory.cc | 43 ++++++------- src/factory.h | 18 +++--- src/jsregexp.cc | 64 ++++++++++---------- src/jsregexp.h | 37 ++++++------ src/objects.h | 4 +- src/parser.cc | 143 +++++++++++++++++++++++--------------------- src/parser.h | 11 ++-- src/runtime.cc | 20 ++++--- src/scopeinfo.cc | 12 ++-- src/scopes.cc | 22 +++---- src/scopes.h | 20 +++---- test/cctest/test-parsing.cc | 2 +- 14 files changed, 244 insertions(+), 227 deletions(-) diff --git a/src/ast.cc b/src/ast.cc index 8c0351c..b4c0430 100644 --- a/src/ast.cc +++ b/src/ast.cc @@ -792,12 +792,12 @@ Interval RegExpQuantifier::CaptureRegisters() { bool RegExpAssertion::IsAnchoredAtStart() { - return type() == RegExpAssertion::START_OF_INPUT; + return assertion_type() == RegExpAssertion::START_OF_INPUT; } bool RegExpAssertion::IsAnchoredAtEnd() { - return type() == RegExpAssertion::END_OF_INPUT; + return assertion_type() == RegExpAssertion::END_OF_INPUT; } @@ -929,7 +929,7 @@ void* RegExpUnparser::VisitCharacterClass(RegExpCharacterClass* that, void* RegExpUnparser::VisitAssertion(RegExpAssertion* that, void* data) { - switch (that->type()) { + switch (that->assertion_type()) { case RegExpAssertion::START_OF_INPUT: stream()->Add("@^i"); break; diff --git a/src/ast.h b/src/ast.h index 41c910a..2ffa473 100644 --- a/src/ast.h +++ b/src/ast.h @@ -39,7 +39,8 @@ #include "small-pointer-list.h" #include "smart-pointers.h" #include "token.h" -#include "type-info.h" +#include "type-info.h" // TODO(rossberg): this should eventually be removed +#include "types.h" #include "utils.h" #include "variables.h" #include "interface.h" @@ -163,9 +164,9 @@ typedef ZoneList > ZoneStringList; typedef ZoneList > ZoneObjectList; -#define DECLARE_NODE_TYPE(type) \ - virtual void Accept(AstVisitor* v); \ - virtual AstNode::Type node_type() const { return AstNode::k##type; } \ +#define DECLARE_NODE_TYPE(type) \ + virtual void Accept(AstVisitor* v); \ + virtual AstNode::NodeType node_type() const { return AstNode::k##type; } \ template friend class AstNodeFactory; @@ -197,7 +198,7 @@ class AstProperties BASE_EMBEDDED { class AstNode: public ZoneObject { public: #define DECLARE_TYPE_ENUM(type) k##type, - enum Type { + enum NodeType { AST_NODE_LIST(DECLARE_TYPE_ENUM) kInvalid = -1 }; @@ -212,7 +213,7 @@ class AstNode: public ZoneObject { virtual ~AstNode() { } virtual void Accept(AstVisitor* v) = 0; - virtual Type node_type() const = 0; + virtual NodeType node_type() const = 0; // Type testing & conversion functions overridden by concrete subclasses. #define DECLARE_NODE_FUNCTIONS(type) \ @@ -354,6 +355,9 @@ class Expression: public AstNode { // True iff the expression is the undefined literal. bool IsUndefinedLiteral(); + // Expression type + Handle type() { return type_; } + // Type feedback information for assignments and properties. virtual bool IsMonomorphic() { UNREACHABLE(); @@ -383,10 +387,12 @@ class Expression: public AstNode { protected: explicit Expression(Isolate* isolate) - : id_(GetNextId(isolate)), + : type_(Type::Any(), isolate), + id_(GetNextId(isolate)), test_id_(GetNextId(isolate)) {} private: + Handle type_; byte to_boolean_types_; const BailoutId id_; @@ -396,7 +402,7 @@ class Expression: public AstNode { class BreakableStatement: public Statement { public: - enum Type { + enum BreakableType { TARGET_FOR_ANONYMOUS, TARGET_FOR_NAMED_ONLY }; @@ -412,15 +418,18 @@ class BreakableStatement: public Statement { Label* break_target() { return &break_target_; } // Testers. - bool is_target_for_anonymous() const { return type_ == TARGET_FOR_ANONYMOUS; } + bool is_target_for_anonymous() const { + return breakable_type_ == TARGET_FOR_ANONYMOUS; + } BailoutId EntryId() const { return entry_id_; } BailoutId ExitId() const { return exit_id_; } protected: - BreakableStatement(Isolate* isolate, ZoneStringList* labels, Type type) + BreakableStatement( + Isolate* isolate, ZoneStringList* labels, BreakableType breakable_type) : labels_(labels), - type_(type), + breakable_type_(breakable_type), entry_id_(GetNextId(isolate)), exit_id_(GetNextId(isolate)) { ASSERT(labels == NULL || labels->length() > 0); @@ -429,7 +438,7 @@ class BreakableStatement: public Statement { private: ZoneStringList* labels_; - Type type_; + BreakableType breakable_type_; Label break_target_; const BailoutId entry_id_; const BailoutId exit_id_; @@ -1123,7 +1132,7 @@ class TargetCollector: public AstNode { // Virtual behaviour. TargetCollectors are never part of the AST. virtual void Accept(AstVisitor* v) { UNREACHABLE(); } - virtual Type node_type() const { return kInvalid; } + virtual NodeType node_type() const { return kInvalid; } virtual TargetCollector* AsTargetCollector() { return this; } ZoneList* targets() { return &targets_; } @@ -2117,7 +2126,7 @@ class Throw: public Expression { class FunctionLiteral: public Expression { public: - enum Type { + enum FunctionType { ANONYMOUS_EXPRESSION, NAMED_EXPRESSION, DECLARATION @@ -2216,7 +2225,7 @@ class FunctionLiteral: public Expression { int expected_property_count, int handler_count, int parameter_count, - Type type, + FunctionType function_type, ParameterFlag has_duplicate_parameters, IsFunctionFlag is_function, IsParenthesizedFlag is_parenthesized, @@ -2232,8 +2241,8 @@ class FunctionLiteral: public Expression { parameter_count_(parameter_count), function_token_position_(RelocInfo::kNoPosition) { bitfield_ = - IsExpression::encode(type != DECLARATION) | - IsAnonymous::encode(type == ANONYMOUS_EXPRESSION) | + IsExpression::encode(function_type != DECLARATION) | + IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | Pretenure::encode(false) | HasDuplicateParameters::encode(has_duplicate_parameters) | IsFunction::encode(is_function) | @@ -2379,7 +2388,7 @@ class RegExpAlternative: public RegExpTree { class RegExpAssertion: public RegExpTree { public: - enum Type { + enum AssertionType { START_OF_LINE, START_OF_INPUT, END_OF_LINE, @@ -2387,7 +2396,7 @@ class RegExpAssertion: public RegExpTree { BOUNDARY, NON_BOUNDARY }; - explicit RegExpAssertion(Type type) : type_(type) { } + explicit RegExpAssertion(AssertionType type) : assertion_type_(type) { } virtual void* Accept(RegExpVisitor* visitor, void* data); virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); @@ -2397,9 +2406,9 @@ class RegExpAssertion: public RegExpTree { virtual bool IsAnchoredAtEnd(); virtual int min_match() { return 0; } virtual int max_match() { return 0; } - Type type() { return type_; } + AssertionType assertion_type() { return assertion_type_; } private: - Type type_; + AssertionType assertion_type_; }; @@ -2512,13 +2521,13 @@ class RegExpText: public RegExpTree { class RegExpQuantifier: public RegExpTree { public: - enum Type { GREEDY, NON_GREEDY, POSSESSIVE }; - RegExpQuantifier(int min, int max, Type type, RegExpTree* body) + enum QuantifierType { GREEDY, NON_GREEDY, POSSESSIVE }; + RegExpQuantifier(int min, int max, QuantifierType type, RegExpTree* body) : body_(body), min_(min), max_(max), min_match_(min * body->min_match()), - type_(type) { + quantifier_type_(type) { if (max > 0 && body->max_match() > kInfinity / max) { max_match_ = kInfinity; } else { @@ -2542,9 +2551,9 @@ class RegExpQuantifier: public RegExpTree { virtual int max_match() { return max_match_; } int min() { return min_; } int max() { return max_; } - bool is_possessive() { return type_ == POSSESSIVE; } - bool is_non_greedy() { return type_ == NON_GREEDY; } - bool is_greedy() { return type_ == GREEDY; } + bool is_possessive() { return quantifier_type_ == POSSESSIVE; } + bool is_non_greedy() { return quantifier_type_ == NON_GREEDY; } + bool is_greedy() { return quantifier_type_ == GREEDY; } RegExpTree* body() { return body_; } private: @@ -2553,7 +2562,7 @@ class RegExpQuantifier: public RegExpTree { int max_; int min_match_; int max_match_; - Type type_; + QuantifierType quantifier_type_; }; @@ -3086,14 +3095,14 @@ class AstNodeFactory BASE_EMBEDDED { int handler_count, int parameter_count, FunctionLiteral::ParameterFlag has_duplicate_parameters, - FunctionLiteral::Type type, + FunctionLiteral::FunctionType function_type, FunctionLiteral::IsFunctionFlag is_function, FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionLiteral::IsGeneratorFlag is_generator) { FunctionLiteral* lit = new(zone_) FunctionLiteral( isolate_, name, scope, body, materialized_literal_count, expected_property_count, handler_count, - parameter_count, type, has_duplicate_parameters, is_function, + parameter_count, function_type, has_duplicate_parameters, is_function, is_parenthesized, is_generator); // Top-level literal doesn't count for the AST's properties. if (is_function == FunctionLiteral::kIsFunction) { diff --git a/src/factory.cc b/src/factory.cc index ab42b19..f963334 100644 --- a/src/factory.cc +++ b/src/factory.cc @@ -676,9 +676,9 @@ Handle Factory::NewNeanderObject() { } -Handle Factory::NewTypeError(const char* type, +Handle Factory::NewTypeError(const char* message, Vector< Handle > args) { - return NewError("MakeTypeError", type, args); + return NewError("MakeTypeError", message, args); } @@ -687,9 +687,9 @@ Handle Factory::NewTypeError(Handle message) { } -Handle Factory::NewRangeError(const char* type, +Handle Factory::NewRangeError(const char* message, Vector< Handle > args) { - return NewError("MakeRangeError", type, args); + return NewError("MakeRangeError", message, args); } @@ -698,8 +698,9 @@ Handle Factory::NewRangeError(Handle message) { } -Handle Factory::NewSyntaxError(const char* type, Handle args) { - return NewError("MakeSyntaxError", type, args); +Handle Factory::NewSyntaxError(const char* message, + Handle args) { + return NewError("MakeSyntaxError", message, args); } @@ -708,9 +709,9 @@ Handle Factory::NewSyntaxError(Handle message) { } -Handle Factory::NewReferenceError(const char* type, +Handle Factory::NewReferenceError(const char* message, Vector< Handle > args) { - return NewError("MakeReferenceError", type, args); + return NewError("MakeReferenceError", message, args); } @@ -720,7 +721,7 @@ Handle Factory::NewReferenceError(Handle message) { Handle Factory::NewError(const char* maker, - const char* type, + const char* message, Vector< Handle > args) { // Instantiate a closeable HandleScope for EscapeFrom. v8::HandleScope scope(reinterpret_cast(isolate())); @@ -729,24 +730,24 @@ Handle Factory::NewError(const char* maker, array->set(i, *args[i]); } Handle object = NewJSArrayWithElements(array); - Handle result = NewError(maker, type, object); + Handle result = NewError(maker, message, object); return result.EscapeFrom(&scope); } -Handle Factory::NewEvalError(const char* type, +Handle Factory::NewEvalError(const char* message, Vector< Handle > args) { - return NewError("MakeEvalError", type, args); + return NewError("MakeEvalError", message, args); } -Handle Factory::NewError(const char* type, +Handle Factory::NewError(const char* message, Vector< Handle > args) { - return NewError("MakeError", type, args); + return NewError("MakeError", message, args); } -Handle Factory::EmergencyNewError(const char* type, +Handle Factory::EmergencyNewError(const char* message, Handle args) { const int kBufferSize = 1000; char buffer[kBufferSize]; @@ -754,8 +755,8 @@ Handle Factory::EmergencyNewError(const char* type, char* p = &buffer[0]; Vector v(buffer, kBufferSize); - OS::StrNCpy(v, type, space); - space -= Min(space, strlen(type)); + OS::StrNCpy(v, message, space); + space -= Min(space, strlen(message)); p = &buffer[kBufferSize] - space; for (unsigned i = 0; i < ARRAY_SIZE(args); i++) { @@ -784,7 +785,7 @@ Handle Factory::EmergencyNewError(const char* type, Handle Factory::NewError(const char* maker, - const char* type, + const char* message, Handle args) { Handle make_str = InternalizeUtf8String(maker); Handle fun_obj( @@ -793,11 +794,11 @@ Handle Factory::NewError(const char* maker, // If the builtins haven't been properly configured yet this error // constructor may not have been defined. Bail out. if (!fun_obj->IsJSFunction()) { - return EmergencyNewError(type, args); + return EmergencyNewError(message, args); } Handle fun = Handle::cast(fun_obj); - Handle type_obj = InternalizeUtf8String(type); - Handle argv[] = { type_obj, args }; + Handle message_obj = InternalizeUtf8String(message); + Handle argv[] = { message_obj, args }; // Invoke the JavaScript factory method. If an exception is thrown while // running the factory method, use the exception as the result. diff --git a/src/factory.h b/src/factory.h index 233b3b0..66304a9 100644 --- a/src/factory.h +++ b/src/factory.h @@ -369,33 +369,33 @@ class Factory { // Interface for creating error objects. - Handle NewError(const char* maker, const char* type, + Handle NewError(const char* maker, const char* message, Handle args); - Handle EmergencyNewError(const char* type, Handle args); - Handle NewError(const char* maker, const char* type, + Handle EmergencyNewError(const char* message, Handle args); + Handle NewError(const char* maker, const char* message, Vector< Handle > args); - Handle NewError(const char* type, + Handle NewError(const char* message, Vector< Handle > args); Handle NewError(Handle message); Handle NewError(const char* constructor, Handle message); - Handle NewTypeError(const char* type, + Handle NewTypeError(const char* message, Vector< Handle > args); Handle NewTypeError(Handle message); - Handle NewRangeError(const char* type, + Handle NewRangeError(const char* message, Vector< Handle > args); Handle NewRangeError(Handle message); - Handle NewSyntaxError(const char* type, Handle args); + Handle NewSyntaxError(const char* message, Handle args); Handle NewSyntaxError(Handle message); - Handle NewReferenceError(const char* type, + Handle NewReferenceError(const char* message, Vector< Handle > args); Handle NewReferenceError(Handle message); - Handle NewEvalError(const char* type, + Handle NewEvalError(const char* message, Vector< Handle > args); diff --git a/src/jsregexp.cc b/src/jsregexp.cc index f32ab13..7838c04 100644 --- a/src/jsregexp.cc +++ b/src/jsregexp.cc @@ -950,10 +950,10 @@ TextElement TextElement::CharClass( int TextElement::length() { - if (type == ATOM) { + if (text_type == ATOM) { return data.u_atom->length(); } else { - ASSERT(type == CHAR_CLASS); + ASSERT(text_type == CHAR_CLASS); return 1; } } @@ -1165,7 +1165,7 @@ RegExpEngine::CompilationResult RegExpCompiler::Assemble( bool Trace::DeferredAction::Mentions(int that) { - if (type() == ActionNode::CLEAR_CAPTURES) { + if (action_type() == ActionNode::CLEAR_CAPTURES) { Interval range = static_cast(this)->range(); return range.Contains(that); } else { @@ -1191,7 +1191,7 @@ bool Trace::GetStoredPosition(int reg, int* cp_offset) { action != NULL; action = action->next()) { if (action->Mentions(reg)) { - if (action->type() == ActionNode::STORE_POSITION) { + if (action->action_type() == ActionNode::STORE_POSITION) { *cp_offset = static_cast(action)->cp_offset(); return true; } else { @@ -1209,7 +1209,7 @@ int Trace::FindAffectedRegisters(OutSet* affected_registers, for (DeferredAction* action = actions_; action != NULL; action = action->next()) { - if (action->type() == ActionNode::CLEAR_CAPTURES) { + if (action->action_type() == ActionNode::CLEAR_CAPTURES) { Interval range = static_cast(action)->range(); for (int i = range.from(); i <= range.to(); i++) affected_registers->Set(i, zone); @@ -1273,7 +1273,7 @@ void Trace::PerformDeferredActions(RegExpMacroAssembler* assembler, action != NULL; action = action->next()) { if (action->Mentions(reg)) { - switch (action->type()) { + switch (action->action_type()) { case ActionNode::SET_REGISTER: { Trace::DeferredSetRegister* psr = static_cast(action); @@ -2304,7 +2304,7 @@ int ActionNode::EatsAtLeast(int still_to_find, int budget, bool not_at_start) { if (budget <= 0) return 0; - if (type_ == POSITIVE_SUBMATCH_SUCCESS) return 0; // Rewinds input! + if (action_type_ == POSITIVE_SUBMATCH_SUCCESS) return 0; // Rewinds input! return on_success()->EatsAtLeast(still_to_find, budget - 1, not_at_start); @@ -2315,9 +2315,9 @@ void ActionNode::FillInBMInfo(int offset, int budget, BoyerMooreLookahead* bm, bool not_at_start) { - if (type_ == BEGIN_SUBMATCH) { + if (action_type_ == BEGIN_SUBMATCH) { bm->SetRest(offset); - } else if (type_ != POSITIVE_SUBMATCH_SUCCESS) { + } else if (action_type_ != POSITIVE_SUBMATCH_SUCCESS) { on_success()->FillInBMInfo(offset, budget - 1, bm, not_at_start); } SaveBMInfo(bm, not_at_start, offset); @@ -2333,7 +2333,7 @@ int AssertionNode::EatsAtLeast(int still_to_find, // implies false. So lets just return the max answer (still_to_find) since // that won't prevent us from preloading a lot of characters for the other // branches in the node graph. - if (type() == AT_START && not_at_start) return still_to_find; + if (assertion_type() == AT_START && not_at_start) return still_to_find; return on_success()->EatsAtLeast(still_to_find, budget - 1, not_at_start); @@ -2345,7 +2345,7 @@ void AssertionNode::FillInBMInfo(int offset, BoyerMooreLookahead* bm, bool not_at_start) { // Match the behaviour of EatsAtLeast on this node. - if (type() == AT_START && not_at_start) return; + if (assertion_type() == AT_START && not_at_start) return; on_success()->FillInBMInfo(offset, budget - 1, bm, not_at_start); SaveBMInfo(bm, not_at_start, offset); } @@ -2562,7 +2562,7 @@ void TextNode::GetQuickCheckDetails(QuickCheckDetails* details, } for (int k = 0; k < elms_->length(); k++) { TextElement elm = elms_->at(k); - if (elm.type == TextElement::ATOM) { + if (elm.text_type == TextElement::ATOM) { Vector quarks = elm.data.u_atom->data(); for (int i = 0; i < characters && i < quarks.length(); i++) { QuickCheckDetails::Position* pos = @@ -2815,7 +2815,7 @@ RegExpNode* TextNode::FilterASCII(int depth, bool ignore_case) { int element_count = elms_->length(); for (int i = 0; i < element_count; i++) { TextElement elm = elms_->at(i); - if (elm.type == TextElement::ATOM) { + if (elm.text_type == TextElement::ATOM) { Vector quarks = elm.data.u_atom->data(); for (int j = 0; j < quarks.length(); j++) { uint16_t c = quarks[j]; @@ -2831,7 +2831,7 @@ RegExpNode* TextNode::FilterASCII(int depth, bool ignore_case) { copy[j] = converted; } } else { - ASSERT(elm.type == TextElement::CHAR_CLASS); + ASSERT(elm.text_type == TextElement::CHAR_CLASS); RegExpCharacterClass* cc = elm.data.u_char_class; ZoneList* ranges = cc->ranges(zone()); if (!CharacterRange::IsCanonical(ranges)) { @@ -3086,7 +3086,7 @@ void AssertionNode::EmitBoundaryCheck(RegExpCompiler* compiler, Trace* trace) { if (lookahead->at(0)->is_non_word()) next_is_word_character = Trace::FALSE; if (lookahead->at(0)->is_word()) next_is_word_character = Trace::TRUE; } - bool at_boundary = (type_ == AssertionNode::AT_BOUNDARY); + bool at_boundary = (assertion_type_ == AssertionNode::AT_BOUNDARY); if (next_is_word_character == Trace::UNKNOWN) { Label before_non_word; Label before_word; @@ -3149,7 +3149,7 @@ void AssertionNode::GetQuickCheckDetails(QuickCheckDetails* details, RegExpCompiler* compiler, int filled_in, bool not_at_start) { - if (type_ == AT_START && not_at_start) { + if (assertion_type_ == AT_START && not_at_start) { details->set_cannot_match(); return; } @@ -3162,7 +3162,7 @@ void AssertionNode::GetQuickCheckDetails(QuickCheckDetails* details, void AssertionNode::Emit(RegExpCompiler* compiler, Trace* trace) { RegExpMacroAssembler* assembler = compiler->macro_assembler(); - switch (type_) { + switch (assertion_type_) { case AT_END: { Label ok; assembler->CheckPosition(trace->cp_offset(), &ok); @@ -3255,7 +3255,7 @@ void TextNode::TextEmitPass(RegExpCompiler* compiler, for (int i = preloaded ? 0 : element_count - 1; i >= 0; i--) { TextElement elm = elms_->at(i); int cp_offset = trace->cp_offset() + elm.cp_offset; - if (elm.type == TextElement::ATOM) { + if (elm.text_type == TextElement::ATOM) { Vector quarks = elm.data.u_atom->data(); for (int j = preloaded ? 0 : quarks.length() - 1; j >= 0; j--) { if (first_element_checked && i == 0 && j == 0) continue; @@ -3293,7 +3293,7 @@ void TextNode::TextEmitPass(RegExpCompiler* compiler, } } } else { - ASSERT_EQ(elm.type, TextElement::CHAR_CLASS); + ASSERT_EQ(elm.text_type, TextElement::CHAR_CLASS); if (pass == CHARACTER_CLASS_MATCH) { if (first_element_checked && i == 0) continue; if (DeterminedAlready(quick_check, elm.cp_offset)) continue; @@ -3316,7 +3316,7 @@ void TextNode::TextEmitPass(RegExpCompiler* compiler, int TextNode::Length() { TextElement elm = elms_->last(); ASSERT(elm.cp_offset >= 0); - if (elm.type == TextElement::ATOM) { + if (elm.text_type == TextElement::ATOM) { return elm.cp_offset + elm.data.u_atom->data().length(); } else { return elm.cp_offset + 1; @@ -3422,7 +3422,7 @@ void TextNode::MakeCaseIndependent(bool is_ascii) { int element_count = elms_->length(); for (int i = 0; i < element_count; i++) { TextElement elm = elms_->at(i); - if (elm.type == TextElement::CHAR_CLASS) { + if (elm.text_type == TextElement::CHAR_CLASS) { RegExpCharacterClass* cc = elm.data.u_char_class; // None of the standard character classes is different in the case // independent case and it slows us down if we don't know that. @@ -3439,7 +3439,7 @@ void TextNode::MakeCaseIndependent(bool is_ascii) { int TextNode::GreedyLoopTextLength() { TextElement elm = elms_->at(elms_->length() - 1); - if (elm.type == TextElement::CHAR_CLASS) { + if (elm.text_type == TextElement::CHAR_CLASS) { return elm.cp_offset + 1; } else { return elm.cp_offset + elm.data.u_atom->data().length(); @@ -3451,7 +3451,7 @@ RegExpNode* TextNode::GetSuccessorOfOmnivorousTextNode( RegExpCompiler* compiler) { if (elms_->length() != 1) return NULL; TextElement elm = elms_->at(0); - if (elm.type != TextElement::CHAR_CLASS) return NULL; + if (elm.text_type != TextElement::CHAR_CLASS) return NULL; RegExpCharacterClass* node = elm.data.u_char_class; ZoneList* ranges = node->ranges(zone()); if (!CharacterRange::IsCanonical(ranges)) { @@ -4196,7 +4196,7 @@ void ActionNode::Emit(RegExpCompiler* compiler, Trace* trace) { RecursionCheck rc(compiler); - switch (type_) { + switch (action_type_) { case STORE_POSITION: { Trace::DeferredCapture new_capture(data_.u_position_register.reg, @@ -4526,7 +4526,7 @@ void DotPrinter::VisitText(TextNode* that) { for (int i = 0; i < that->elements()->length(); i++) { if (i > 0) stream()->Add(" "); TextElement elm = that->elements()->at(i); - switch (elm.type) { + switch (elm.text_type) { case TextElement::ATOM: { stream()->Add("'%w'", elm.data.u_atom->data()); break; @@ -4573,7 +4573,7 @@ void DotPrinter::VisitEnd(EndNode* that) { void DotPrinter::VisitAssertion(AssertionNode* that) { stream()->Add(" n%p [", that); - switch (that->type()) { + switch (that->assertion_type()) { case AssertionNode::AT_END: stream()->Add("label=\"$\", shape=septagon"); break; @@ -4600,7 +4600,7 @@ void DotPrinter::VisitAssertion(AssertionNode* that) { void DotPrinter::VisitAction(ActionNode* that) { stream()->Add(" n%p [", that); - switch (that->type_) { + switch (that->action_type_) { case ActionNode::SET_REGISTER: stream()->Add("label=\"$%i:=%i\", shape=octagon", that->data_.u_store_register.reg, @@ -5013,7 +5013,7 @@ RegExpNode* RegExpAssertion::ToNode(RegExpCompiler* compiler, NodeInfo info; Zone* zone = compiler->zone(); - switch (type()) { + switch (assertion_type()) { case START_OF_LINE: return AssertionNode::AfterNewline(on_success); case START_OF_INPUT: @@ -5715,7 +5715,7 @@ void TextNode::CalculateOffsets() { for (int i = 0; i < element_count; i++) { TextElement& elm = elements()->at(i); elm.cp_offset = cp_offset; - if (elm.type == TextElement::ATOM) { + if (elm.text_type == TextElement::ATOM) { cp_offset += elm.data.u_atom->data().length(); } else { cp_offset++; @@ -5835,7 +5835,7 @@ void TextNode::FillInBMInfo(int initial_offset, return; } TextElement text = elements()->at(i); - if (text.type == TextElement::ATOM) { + if (text.text_type == TextElement::ATOM) { RegExpAtom* atom = text.data.u_atom; for (int j = 0; j < atom->length(); j++, offset++) { if (offset >= bm->length()) { @@ -5858,7 +5858,7 @@ void TextNode::FillInBMInfo(int initial_offset, } } } else { - ASSERT(text.type == TextElement::CHAR_CLASS); + ASSERT(text.text_type == TextElement::CHAR_CLASS); RegExpCharacterClass* char_class = text.data.u_char_class; ZoneList* ranges = char_class->ranges(zone()); if (char_class->is_negated()) { @@ -5971,7 +5971,7 @@ void DispatchTableConstructor::AddInverse(ZoneList* ranges) { void DispatchTableConstructor::VisitText(TextNode* that) { TextElement elm = that->elements()->at(0); - switch (elm.type) { + switch (elm.text_type) { case TextElement::ATOM: { uc16 c = elm.data.u_atom->data()[0]; AddRange(CharacterRange(c, c)); diff --git a/src/jsregexp.h b/src/jsregexp.h index 625f192..181a1b2 100644 --- a/src/jsregexp.h +++ b/src/jsregexp.h @@ -429,13 +429,13 @@ FOR_EACH_REG_EXP_TREE_TYPE(FORWARD_DECLARE) class TextElement { public: - enum Type {UNINITIALIZED, ATOM, CHAR_CLASS}; - TextElement() : type(UNINITIALIZED) { } - explicit TextElement(Type t) : type(t), cp_offset(-1) { } + enum TextType {UNINITIALIZED, ATOM, CHAR_CLASS}; + TextElement() : text_type(UNINITIALIZED) { } + explicit TextElement(TextType t) : text_type(t), cp_offset(-1) { } static TextElement Atom(RegExpAtom* atom); static TextElement CharClass(RegExpCharacterClass* char_class); int length(); - Type type; + TextType text_type; union { RegExpAtom* u_atom; RegExpCharacterClass* u_char_class; @@ -739,7 +739,7 @@ class SeqRegExpNode: public RegExpNode { class ActionNode: public SeqRegExpNode { public: - enum Type { + enum ActionType { SET_REGISTER, INCREMENT_REGISTER, STORE_POSITION, @@ -780,7 +780,7 @@ class ActionNode: public SeqRegExpNode { int budget, BoyerMooreLookahead* bm, bool not_at_start); - Type type() { return type_; } + ActionType action_type() { return action_type_; } // TODO(erikcorry): We should allow some action nodes in greedy loops. virtual int GreedyLoopTextLength() { return kNodeIsTooComplexForGreedyLoops; } @@ -813,10 +813,10 @@ class ActionNode: public SeqRegExpNode { int range_to; } u_clear_captures; } data_; - ActionNode(Type type, RegExpNode* on_success) + ActionNode(ActionType action_type, RegExpNode* on_success) : SeqRegExpNode(on_success), - type_(type) { } - Type type_; + action_type_(action_type) { } + ActionType action_type_; friend class DotPrinter; }; @@ -876,7 +876,7 @@ class TextNode: public SeqRegExpNode { class AssertionNode: public SeqRegExpNode { public: - enum AssertionNodeType { + enum AssertionType { AT_END, AT_START, AT_BOUNDARY, @@ -909,8 +909,7 @@ class AssertionNode: public SeqRegExpNode { int budget, BoyerMooreLookahead* bm, bool not_at_start); - AssertionNodeType type() { return type_; } - void set_type(AssertionNodeType type) { type_ = type; } + AssertionType assertion_type() { return assertion_type_; } private: void EmitBoundaryCheck(RegExpCompiler* compiler, Trace* trace); @@ -918,9 +917,9 @@ class AssertionNode: public SeqRegExpNode { void BacktrackIfPrevious(RegExpCompiler* compiler, Trace* trace, IfPrevious backtrack_if_previous); - AssertionNode(AssertionNodeType t, RegExpNode* on_success) - : SeqRegExpNode(on_success), type_(t) { } - AssertionNodeType type_; + AssertionNode(AssertionType t, RegExpNode* on_success) + : SeqRegExpNode(on_success), assertion_type_(t) { } + AssertionType assertion_type_; }; @@ -1337,14 +1336,14 @@ class Trace { class DeferredAction { public: - DeferredAction(ActionNode::Type type, int reg) - : type_(type), reg_(reg), next_(NULL) { } + DeferredAction(ActionNode::ActionType action_type, int reg) + : action_type_(action_type), reg_(reg), next_(NULL) { } DeferredAction* next() { return next_; } bool Mentions(int reg); int reg() { return reg_; } - ActionNode::Type type() { return type_; } + ActionNode::ActionType action_type() { return action_type_; } private: - ActionNode::Type type_; + ActionNode::ActionType action_type_; int reg_; DeferredAction* next_; friend class Trace; diff --git a/src/objects.h b/src/objects.h index a16ebbf..b7b32f8 100644 --- a/src/objects.h +++ b/src/objects.h @@ -3677,7 +3677,7 @@ class ScopeInfo : public FixedArray { static inline ScopeInfo* cast(Object* object); // Return the type of this scope. - ScopeType Type(); + ScopeType scope_type(); // Does this scope call eval? bool CallsEval(); @@ -3860,7 +3860,7 @@ class ScopeInfo : public FixedArray { }; // Properties of scopes. - class TypeField: public BitField {}; + class ScopeTypeField: public BitField {}; class CallsEvalField: public BitField {}; class LanguageModeField: public BitField {}; class FunctionVariableField: public BitField {}; diff --git a/src/parser.cc b/src/parser.cc index f032d97..4aaa9a1 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -202,9 +202,8 @@ RegExpTree* RegExpBuilder::ToRegExp() { } -void RegExpBuilder::AddQuantifierToAtom(int min, - int max, - RegExpQuantifier::Type type) { +void RegExpBuilder::AddQuantifierToAtom( + int min, int max, RegExpQuantifier::QuantifierType quantifier_type) { if (pending_empty_) { pending_empty_ = false; return; @@ -244,7 +243,8 @@ void RegExpBuilder::AddQuantifierToAtom(int min, UNREACHABLE(); return; } - terms_.Add(new(zone()) RegExpQuantifier(min, max, type, atom), zone()); + terms_.Add( + new(zone()) RegExpQuantifier(min, max, quantifier_type, atom), zone()); LAST(ADD_TERM); } @@ -410,8 +410,8 @@ unsigned* ScriptDataImpl::ReadAddress(int position) { } -Scope* Parser::NewScope(Scope* parent, ScopeType type) { - Scope* result = new(zone()) Scope(parent, type, zone()); +Scope* Parser::NewScope(Scope* parent, ScopeType scope_type) { + Scope* result = new(zone()) Scope(parent, scope_type, zone()); result->Initialize(); return result; } @@ -758,7 +758,7 @@ FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source, info()->is_extended_mode()); ASSERT(info()->language_mode() == shared_info->language_mode()); scope->SetLanguageMode(shared_info->language_mode()); - FunctionLiteral::Type type = shared_info->is_expression() + FunctionLiteral::FunctionType function_type = shared_info->is_expression() ? (shared_info->is_anonymous() ? FunctionLiteral::ANONYMOUS_EXPRESSION : FunctionLiteral::NAMED_EXPRESSION) @@ -768,7 +768,7 @@ FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source, false, // Strict mode name already checked. shared_info->is_generator(), RelocInfo::kNoPosition, - type, + function_type, &ok); // Make sure the results agree. ASSERT(ok == (result != NULL)); @@ -799,20 +799,20 @@ Handle Parser::GetSymbol() { } -void Parser::ReportMessage(const char* type, Vector args) { +void Parser::ReportMessage(const char* message, Vector args) { Scanner::Location source_location = scanner().location(); - ReportMessageAt(source_location, type, args); + ReportMessageAt(source_location, message, args); } -void Parser::ReportMessage(const char* type, Vector > args) { +void Parser::ReportMessage(const char* message, Vector > args) { Scanner::Location source_location = scanner().location(); - ReportMessageAt(source_location, type, args); + ReportMessageAt(source_location, message, args); } void Parser::ReportMessageAt(Scanner::Location source_location, - const char* type, + const char* message, Vector args) { MessageLocation location(script_, source_location.beg_pos, @@ -824,13 +824,13 @@ void Parser::ReportMessageAt(Scanner::Location source_location, elements->set(i, *arg_string); } Handle array = factory->NewJSArrayWithElements(elements); - Handle result = factory->NewSyntaxError(type, array); + Handle result = factory->NewSyntaxError(message, array); isolate()->Throw(*result, &location); } void Parser::ReportMessageAt(Scanner::Location source_location, - const char* type, + const char* message, Vector > args) { MessageLocation location(script_, source_location.beg_pos, @@ -841,7 +841,7 @@ void Parser::ReportMessageAt(Scanner::Location source_location, elements->set(i, *args[i]); } Handle array = factory->NewJSArrayWithElements(elements); - Handle result = factory->NewSyntaxError(type, array); + Handle result = factory->NewSyntaxError(message, array); isolate()->Throw(*result, &location); } @@ -1538,12 +1538,12 @@ void Parser::Declare(Declaration* declaration, bool resolve, bool* ok) { *ok = false; return; } - Handle type_string = + Handle message_string = isolate()->factory()->NewStringFromUtf8(CStrVector("Variable"), TENURED); Expression* expression = NewThrowTypeError(isolate()->factory()->redeclaration_string(), - type_string, name); + message_string, name); declaration_scope->SetIllegalRedeclaration(expression); } } @@ -2345,8 +2345,9 @@ Statement* Parser::ParseReturnStatement(bool* ok) { Scope* declaration_scope = top_scope_->DeclarationScope(); if (declaration_scope->is_global_scope() || declaration_scope->is_eval_scope()) { - Handle type = isolate()->factory()->illegal_return_string(); - Expression* throw_error = NewThrowSyntaxError(type, Handle::null()); + Handle message = isolate()->factory()->illegal_return_string(); + Expression* throw_error = + NewThrowSyntaxError(message, Handle::null()); return factory()->NewExpressionStatement(throw_error); } return result; @@ -2737,9 +2738,9 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) { // error here but for compatibility with JSC we choose to report // the error at runtime. if (expression == NULL || !expression->IsValidLeftHandSide()) { - Handle type = + Handle message = isolate()->factory()->invalid_lhs_in_for_in_string(); - expression = NewThrowReferenceError(type); + expression = NewThrowReferenceError(message); } ForInStatement* loop = factory()->NewForInStatement(labels); Target target(&this->target_stack_, loop); @@ -2856,9 +2857,9 @@ Expression* Parser::ParseAssignmentExpression(bool accept_IN, bool* ok) { // runtime. // TODO(ES5): Should change parsing for spec conformance. if (expression == NULL || !expression->IsValidLeftHandSide()) { - Handle type = + Handle message = isolate()->factory()->invalid_lhs_in_assignment_string(); - expression = NewThrowReferenceError(type); + expression = NewThrowReferenceError(message); } if (!top_scope_->is_classic_mode()) { @@ -3126,9 +3127,9 @@ Expression* Parser::ParseUnaryExpression(bool* ok) { // error here but for compatibility with JSC we choose to report the // error at runtime. if (expression == NULL || !expression->IsValidLeftHandSide()) { - Handle type = + Handle message = isolate()->factory()->invalid_lhs_in_prefix_op_string(); - expression = NewThrowReferenceError(type); + expression = NewThrowReferenceError(message); } if (!top_scope_->is_classic_mode()) { @@ -3161,9 +3162,9 @@ Expression* Parser::ParsePostfixExpression(bool* ok) { // error here but for compatibility with JSC we choose to report the // error at runtime. if (expression == NULL || !expression->IsValidLeftHandSide()) { - Handle type = + Handle message = isolate()->factory()->invalid_lhs_in_postfix_op_string(); - expression = NewThrowReferenceError(type); + expression = NewThrowReferenceError(message); } if (!top_scope_->is_classic_mode()) { @@ -3322,14 +3323,14 @@ Expression* Parser::ParseMemberWithNewPrefixesExpression(PositionStack* stack, name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name, CHECK_OK); } - FunctionLiteral::Type type = name.is_null() + FunctionLiteral::FunctionType function_type = name.is_null() ? FunctionLiteral::ANONYMOUS_EXPRESSION : FunctionLiteral::NAMED_EXPRESSION; result = ParseFunctionLiteral(name, is_strict_reserved_name, is_generator, function_token_position, - type, + function_type, CHECK_OK); } else { result = ParsePrimaryExpression(CHECK_OK); @@ -3658,24 +3659,25 @@ Handle CompileTimeValue::GetValue(Expression* expression) { if (object_literal != NULL) { ASSERT(object_literal->is_simple()); if (object_literal->fast_elements()) { - result->set(kTypeSlot, Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS)); + result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS)); } else { - result->set(kTypeSlot, Smi::FromInt(OBJECT_LITERAL_SLOW_ELEMENTS)); + result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_SLOW_ELEMENTS)); } result->set(kElementsSlot, *object_literal->constant_properties()); } else { ArrayLiteral* array_literal = expression->AsArrayLiteral(); ASSERT(array_literal != NULL && array_literal->is_simple()); - result->set(kTypeSlot, Smi::FromInt(ARRAY_LITERAL)); + result->set(kLiteralTypeSlot, Smi::FromInt(ARRAY_LITERAL)); result->set(kElementsSlot, *array_literal->constant_elements()); } return result; } -CompileTimeValue::Type CompileTimeValue::GetType(Handle value) { - Smi* type_value = Smi::cast(value->get(kTypeSlot)); - return static_cast(type_value->value()); +CompileTimeValue::LiteralType CompileTimeValue::GetLiteralType( + Handle value) { + Smi* literal_type = Smi::cast(value->get(kLiteralTypeSlot)); + return static_cast(literal_type->value()); } @@ -4163,12 +4165,13 @@ class SingletonLogger : public ParserRecorder { }; -FunctionLiteral* Parser::ParseFunctionLiteral(Handle function_name, - bool name_is_strict_reserved, - bool is_generator, - int function_token_position, - FunctionLiteral::Type type, - bool* ok) { +FunctionLiteral* Parser::ParseFunctionLiteral( + Handle function_name, + bool name_is_strict_reserved, + bool is_generator, + int function_token_position, + FunctionLiteral::FunctionType function_type, + bool* ok) { // Function :: // '(' FormalParameterList? ')' '{' FunctionBody '}' @@ -4186,7 +4189,8 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle function_name, // Function declarations are function scoped in normal mode, so they are // hoisted. In harmony block scoping mode they are block scoped, so they // are not hoisted. - Scope* scope = (type == FunctionLiteral::DECLARATION && !is_extended_mode()) + Scope* scope = + (function_type == FunctionLiteral::DECLARATION && !is_extended_mode()) ? NewScope(top_scope_->DeclarationScope(), FUNCTION_SCOPE) : NewScope(top_scope_, FUNCTION_SCOPE); ZoneList* body = NULL; @@ -4272,7 +4276,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle function_name, // instead of Variables and Proxis as is the case now. Variable* fvar = NULL; Token::Value fvar_init_op = Token::INIT_CONST; - if (type == FunctionLiteral::NAMED_EXPRESSION) { + if (function_type == FunctionLiteral::NAMED_EXPRESSION) { if (is_extended_mode()) fvar_init_op = Token::INIT_CONST_HARMONY; VariableMode fvar_mode = is_extended_mode() ? CONST_HARMONY : CONST; fvar = new(zone()) Variable(top_scope_, @@ -4476,7 +4480,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle function_name, handler_count, num_parameters, duplicate_parameters, - type, + function_type, FunctionLiteral::kIsFunction, parenthesized, generator); @@ -4822,22 +4826,22 @@ void Parser::RegisterTargetUse(Label* target, Target* stop) { } -Expression* Parser::NewThrowReferenceError(Handle type) { +Expression* Parser::NewThrowReferenceError(Handle message) { return NewThrowError(isolate()->factory()->MakeReferenceError_string(), - type, HandleVector(NULL, 0)); + message, HandleVector(NULL, 0)); } -Expression* Parser::NewThrowSyntaxError(Handle type, +Expression* Parser::NewThrowSyntaxError(Handle message, Handle first) { int argc = first.is_null() ? 0 : 1; Vector< Handle > arguments = HandleVector(&first, argc); return NewThrowError( - isolate()->factory()->MakeSyntaxError_string(), type, arguments); + isolate()->factory()->MakeSyntaxError_string(), message, arguments); } -Expression* Parser::NewThrowTypeError(Handle type, +Expression* Parser::NewThrowTypeError(Handle message, Handle first, Handle second) { ASSERT(!first.is_null() && !second.is_null()); @@ -4845,12 +4849,12 @@ Expression* Parser::NewThrowTypeError(Handle type, Vector< Handle > arguments = HandleVector(elements, ARRAY_SIZE(elements)); return NewThrowError( - isolate()->factory()->MakeTypeError_string(), type, arguments); + isolate()->factory()->MakeTypeError_string(), message, arguments); } Expression* Parser::NewThrowError(Handle constructor, - Handle type, + Handle message, Vector< Handle > arguments) { int argc = arguments.length(); Handle elements = isolate()->factory()->NewFixedArray(argc, @@ -4865,7 +4869,7 @@ Expression* Parser::NewThrowError(Handle constructor, elements, FAST_ELEMENTS, TENURED); ZoneList* args = new(zone()) ZoneList(2, zone()); - args->Add(factory()->NewLiteral(type), zone()); + args->Add(factory()->NewLiteral(message), zone()); args->Add(factory()->NewLiteral(array), zone()); CallRuntime* call_constructor = factory()->NewCallRuntime(constructor, NULL, args); @@ -5006,20 +5010,21 @@ RegExpTree* RegExpParser::ParseDisjunction() { int end_capture_index = captures_started(); int capture_index = stored_state->capture_index(); - SubexpressionType type = stored_state->group_type(); + SubexpressionType group_type = stored_state->group_type(); // Restore previous state. stored_state = stored_state->previous_state(); builder = stored_state->builder(); // Build result of subexpression. - if (type == CAPTURE) { + if (group_type == CAPTURE) { RegExpCapture* capture = new(zone()) RegExpCapture(body, capture_index); captures_->at(capture_index - 1) = capture; body = capture; - } else if (type != GROUPING) { - ASSERT(type == POSITIVE_LOOKAHEAD || type == NEGATIVE_LOOKAHEAD); - bool is_positive = (type == POSITIVE_LOOKAHEAD); + } else if (group_type != GROUPING) { + ASSERT(group_type == POSITIVE_LOOKAHEAD || + group_type == NEGATIVE_LOOKAHEAD); + bool is_positive = (group_type == POSITIVE_LOOKAHEAD); body = new(zone()) RegExpLookahead(body, is_positive, end_capture_index - capture_index, @@ -5053,10 +5058,10 @@ RegExpTree* RegExpParser::ParseDisjunction() { } case '$': { Advance(); - RegExpAssertion::Type type = + RegExpAssertion::AssertionType assertion_type = multiline_ ? RegExpAssertion::END_OF_LINE : RegExpAssertion::END_OF_INPUT; - builder->AddAssertion(new(zone()) RegExpAssertion(type)); + builder->AddAssertion(new(zone()) RegExpAssertion(assertion_type)); continue; } case '.': { @@ -5070,18 +5075,18 @@ RegExpTree* RegExpParser::ParseDisjunction() { break; } case '(': { - SubexpressionType type = CAPTURE; + SubexpressionType subexpr_type = CAPTURE; Advance(); if (current() == '?') { switch (Next()) { case ':': - type = GROUPING; + subexpr_type = GROUPING; break; case '=': - type = POSITIVE_LOOKAHEAD; + subexpr_type = POSITIVE_LOOKAHEAD; break; case '!': - type = NEGATIVE_LOOKAHEAD; + subexpr_type = NEGATIVE_LOOKAHEAD; break; default: ReportError(CStrVector("Invalid group") CHECK_FAILED); @@ -5098,7 +5103,7 @@ RegExpTree* RegExpParser::ParseDisjunction() { captures_->Add(NULL, zone()); } // Store current state and begin new disjunction parsing. - stored_state = new(zone()) RegExpParserState(stored_state, type, + stored_state = new(zone()) RegExpParserState(stored_state, subexpr_type, captures_started(), zone()); builder = stored_state->builder(); continue; @@ -5286,16 +5291,16 @@ RegExpTree* RegExpParser::ParseDisjunction() { default: continue; } - RegExpQuantifier::Type type = RegExpQuantifier::GREEDY; + RegExpQuantifier::QuantifierType quantifier_type = RegExpQuantifier::GREEDY; if (current() == '?') { - type = RegExpQuantifier::NON_GREEDY; + quantifier_type = RegExpQuantifier::NON_GREEDY; Advance(); } else if (FLAG_regexp_possessive_quantifier && current() == '+') { // FLAG_regexp_possessive_quantifier is a debug-only flag. - type = RegExpQuantifier::POSSESSIVE; + quantifier_type = RegExpQuantifier::POSSESSIVE; Advance(); } - builder->AddQuantifierToAtom(min, max, type); + builder->AddQuantifierToAtom(min, max, quantifier_type); } } diff --git a/src/parser.h b/src/parser.h index ed9ee10..eea617f 100644 --- a/src/parser.h +++ b/src/parser.h @@ -269,7 +269,8 @@ class RegExpBuilder: public ZoneObject { void AddAtom(RegExpTree* tree); void AddAssertion(RegExpTree* tree); void NewAlternative(); // '|' - void AddQuantifierToAtom(int min, int max, RegExpQuantifier::Type type); + void AddQuantifierToAtom( + int min, int max, RegExpQuantifier::QuantifierType type); RegExpTree* ToRegExp(); private: @@ -690,7 +691,7 @@ class Parser BASE_EMBEDDED { bool name_is_reserved, bool is_generator, int function_token_position, - FunctionLiteral::Type type, + FunctionLiteral::FunctionType type, bool* ok); @@ -867,7 +868,7 @@ class Parser BASE_EMBEDDED { // can be fully handled at compile time. class CompileTimeValue: public AllStatic { public: - enum Type { + enum LiteralType { OBJECT_LITERAL_FAST_ELEMENTS, OBJECT_LITERAL_SLOW_ELEMENTS, ARRAY_LITERAL @@ -881,13 +882,13 @@ class CompileTimeValue: public AllStatic { static Handle GetValue(Expression* expression); // Get the type of a compile time value returned by GetValue(). - static Type GetType(Handle value); + static LiteralType GetLiteralType(Handle value); // Get the elements array of a compile time value returned by GetValue(). static Handle GetElements(Handle value); private: - static const int kTypeSlot = 0; + static const int kLiteralTypeSlot = 0; static const int kElementsSlot = 1; DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); diff --git a/src/runtime.cc b/src/runtime.cc index cabd22b..0516c9c 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -425,7 +425,7 @@ static Handle CreateLiteralBoilerplate( Handle array) { Handle elements = CompileTimeValue::GetElements(array); const bool kHasNoFunctionLiteral = false; - switch (CompileTimeValue::GetType(array)) { + switch (CompileTimeValue::GetLiteralType(array)) { case CompileTimeValue::OBJECT_LITERAL_FAST_ELEMENTS: return CreateObjectLiteralBoilerplate(isolate, literals, @@ -11234,7 +11234,9 @@ class ScopeIterator { context_ = Handle(context_->previous(), isolate_); } } - if (scope_info->Type() != EVAL_SCOPE) nested_scope_chain_.Add(scope_info); + if (scope_info->scope_type() != EVAL_SCOPE) { + nested_scope_chain_.Add(scope_info); + } } else { // Reparse the code and analyze the scopes. Handle