Revision: 20200
Author:   [email protected]
Date:     Mon Mar 24 14:41:55 2014 UTC
Log: Parser fix: check allow_harmony_scoping() instead of FLAG_harmony_scoping.

Without this fix, ParserBase::set_allow_harmony_scoping() and the
kAllowHarmonyScoping in test-parsing.cc don't have any effect, and we end up not
running the tests with harmony scoping allowed.

[email protected]
BUG=

Review URL: https://codereview.chromium.org/209993002
http://code.google.com/p/v8/source/detail?r=20200

Modified:
 /branches/bleeding_edge/src/parser.cc
 /branches/bleeding_edge/src/preparser.cc

=======================================
--- /branches/bleeding_edge/src/parser.cc       Fri Mar 21 10:34:51 2014 UTC
+++ /branches/bleeding_edge/src/parser.cc       Mon Mar 24 14:41:55 2014 UTC
@@ -893,7 +893,7 @@
       CheckOctalLiteral(beg_pos, scanner()->location().end_pos, &ok);
     }

-    if (ok && FLAG_harmony_scoping && strict_mode() == STRICT) {
+    if (ok && allow_harmony_scoping() && strict_mode() == STRICT) {
       CheckConflictingVarDeclarations(scope_, &ok);
     }

@@ -1698,7 +1698,7 @@
// because the var declaration is hoisted to the function scope where 'x'
       // is already bound.
       ASSERT(IsDeclaredVariableMode(var->mode()));
-      if (FLAG_harmony_scoping && strict_mode() == STRICT) {
+      if (allow_harmony_scoping() && strict_mode() == STRICT) {
         // In harmony we treat re-declarations as early errors. See
         // ES5 16 for a definition of early errors.
         SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS);
@@ -1876,7 +1876,7 @@
// In extended mode, a function behaves as a lexical binding, except in the
   // global scope.
   VariableMode mode =
-      FLAG_harmony_scoping &&
+      allow_harmony_scoping() &&
       strict_mode() == STRICT && !scope_->is_global_scope() ? LET : VAR;
   VariableProxy* proxy = NewUnresolved(name, mode, Interface::NewValue());
   Declaration* declaration =
@@ -1888,7 +1888,7 @@


 Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) {
-  if (FLAG_harmony_scoping && strict_mode() == STRICT) {
+  if (allow_harmony_scoping() && strict_mode() == STRICT) {
     return ParseScopedBlock(labels, ok);
   }

@@ -2016,7 +2016,7 @@
         init_op = Token::INIT_CONST_LEGACY;
         break;
       case STRICT:
-        if (FLAG_harmony_scoping) {
+        if (allow_harmony_scoping()) {
           if (var_context == kStatement) {
// In strict mode 'const' declarations are only allowed in source
             // element positions.
@@ -2043,7 +2043,7 @@
     //   contained in extended code.
     //
     // TODO(rossberg): make 'let' a legal identifier in sloppy mode.
-    if (!FLAG_harmony_scoping || strict_mode() == SLOPPY) {
+    if (!allow_harmony_scoping() || strict_mode() == SLOPPY) {
       ReportMessage("illegal_let", Vector<const char*>::empty());
       *ok = false;
       return NULL;
@@ -2670,7 +2670,7 @@

     Target target(&this->target_stack_, &catch_collector);
     VariableMode mode =
-        FLAG_harmony_scoping && strict_mode() == STRICT ? LET : VAR;
+        allow_harmony_scoping() && strict_mode() == STRICT ? LET : VAR;
     catch_variable =
         catch_scope->DeclareLocal(name, mode, kCreatedInitialized);

@@ -3181,7 +3181,7 @@
   Scope* original_declaration_scope = original_scope_->DeclarationScope();
   Scope* scope =
       function_type == FunctionLiteral::DECLARATION &&
-      (!FLAG_harmony_scoping || strict_mode() == SLOPPY) &&
+      (!allow_harmony_scoping() || strict_mode() == SLOPPY) &&
       (original_scope_ == original_declaration_scope ||
        declaration_scope != original_declaration_scope)
           ? NewScope(declaration_scope, FUNCTION_SCOPE)
@@ -3272,11 +3272,12 @@
     Variable* fvar = NULL;
     Token::Value fvar_init_op = Token::INIT_CONST_LEGACY;
     if (function_type == FunctionLiteral::NAMED_EXPRESSION) {
-      if (FLAG_harmony_scoping && strict_mode() == STRICT) {
+      if (allow_harmony_scoping() && strict_mode() == STRICT) {
         fvar_init_op = Token::INIT_CONST;
       }
- VariableMode fvar_mode = FLAG_harmony_scoping && strict_mode() == STRICT
-          ? CONST : CONST_LEGACY;
+      VariableMode fvar_mode =
+          allow_harmony_scoping() && strict_mode() == STRICT ? CONST
+ : CONST_LEGACY;
       fvar = new(zone()) Variable(scope_,
          function_name, fvar_mode, true /* is valid LHS */,
          Variable::NORMAL, kCreatedInitialized, Interface::NewConst());
@@ -3498,7 +3499,7 @@
     dont_optimize_reason = factory()->visitor()->dont_optimize_reason();
   }

-  if (FLAG_harmony_scoping && strict_mode() == STRICT) {
+  if (allow_harmony_scoping() && strict_mode() == STRICT) {
     CheckConflictingVarDeclarations(scope, CHECK_OK);
   }

=======================================
--- /branches/bleeding_edge/src/preparser.cc    Mon Mar 24 12:16:09 2014 UTC
+++ /branches/bleeding_edge/src/preparser.cc    Mon Mar 24 14:41:55 2014 UTC
@@ -379,7 +379,7 @@
   //
   Expect(Token::LBRACE, CHECK_OK);
   while (peek() != Token::RBRACE) {
-    if (FLAG_harmony_scoping && strict_mode() == STRICT) {
+    if (allow_harmony_scoping() && strict_mode() == STRICT) {
       ParseSourceElement(CHECK_OK);
     } else {
       ParseStatement(CHECK_OK);
@@ -444,7 +444,7 @@
     // non-harmony semantics in sloppy mode.
     Consume(Token::CONST);
     if (strict_mode() == STRICT) {
-      if (FLAG_harmony_scoping) {
+      if (allow_harmony_scoping()) {
if (var_context != kSourceElement && var_context != kForStatement) {
           ReportMessageAt(scanner()->peek_location(), "unprotected_const");
           *ok = false;
@@ -467,7 +467,7 @@
     //   contained in extended code.
     //
     // TODO(rossberg): make 'let' a legal identifier in sloppy mode.
-    if (!FLAG_harmony_scoping || strict_mode() == SLOPPY) {
+    if (!allow_harmony_scoping() || strict_mode() == SLOPPY) {
       ReportMessageAt(scanner()->peek_location(), "illegal_let");
       *ok = false;
       return Statement::Default();

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to