OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 // because the var declaration is hoisted to the function scope where 'x' | 1362 // because the var declaration is hoisted to the function scope where 'x' |
1363 // is already bound. | 1363 // is already bound. |
1364 if ((mode != Variable::VAR) || (var->mode() != Variable::VAR)) { | 1364 if ((mode != Variable::VAR) || (var->mode() != Variable::VAR)) { |
1365 // We only have vars, consts and lets in declarations. | 1365 // We only have vars, consts and lets in declarations. |
1366 ASSERT(var->mode() == Variable::VAR || | 1366 ASSERT(var->mode() == Variable::VAR || |
1367 var->mode() == Variable::CONST || | 1367 var->mode() == Variable::CONST || |
1368 var->mode() == Variable::LET); | 1368 var->mode() == Variable::LET); |
1369 if (harmony_block_scoping_) { | 1369 if (harmony_block_scoping_) { |
1370 // In harmony mode we treat re-declarations as early errors. See | 1370 // In harmony mode we treat re-declarations as early errors. See |
1371 // ES5 16 for a definition of early errors. | 1371 // ES5 16 for a definition of early errors. |
1372 SmartPointer<char> c_string = name->ToCString(DISALLOW_NULLS); | 1372 SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS); |
1373 const char* elms[2] = { "Variable", *c_string }; | 1373 const char* elms[2] = { "Variable", *c_string }; |
1374 Vector<const char*> args(elms, 2); | 1374 Vector<const char*> args(elms, 2); |
1375 ReportMessage("redeclaration", args); | 1375 ReportMessage("redeclaration", args); |
1376 *ok = false; | 1376 *ok = false; |
1377 return NULL; | 1377 return NULL; |
1378 } | 1378 } |
1379 const char* type = (var->mode() == Variable::VAR) ? "var" : | 1379 const char* type = (var->mode() == Variable::VAR) ? "var" : |
1380 (var->mode() == Variable::CONST) ? "const" : "let"; | 1380 (var->mode() == Variable::CONST) ? "const" : "let"; |
1381 Handle<String> type_string = | 1381 Handle<String> type_string = |
1382 isolate()->factory()->NewStringFromUtf8(CStrVector(type), TENURED); | 1382 isolate()->factory()->NewStringFromUtf8(CStrVector(type), TENURED); |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1895 // Expression is a single identifier, and not, e.g., a parenthesized | 1895 // Expression is a single identifier, and not, e.g., a parenthesized |
1896 // identifier. | 1896 // identifier. |
1897 VariableProxy* var = expr->AsVariableProxy(); | 1897 VariableProxy* var = expr->AsVariableProxy(); |
1898 Handle<String> label = var->name(); | 1898 Handle<String> label = var->name(); |
1899 // TODO(1240780): We don't check for redeclaration of labels | 1899 // TODO(1240780): We don't check for redeclaration of labels |
1900 // during preparsing since keeping track of the set of active | 1900 // during preparsing since keeping track of the set of active |
1901 // labels requires nontrivial changes to the way scopes are | 1901 // labels requires nontrivial changes to the way scopes are |
1902 // structured. However, these are probably changes we want to | 1902 // structured. However, these are probably changes we want to |
1903 // make later anyway so we should go back and fix this then. | 1903 // make later anyway so we should go back and fix this then. |
1904 if (ContainsLabel(labels, label) || TargetStackContainsLabel(label)) { | 1904 if (ContainsLabel(labels, label) || TargetStackContainsLabel(label)) { |
1905 SmartPointer<char> c_string = label->ToCString(DISALLOW_NULLS); | 1905 SmartArrayPointer<char> c_string = label->ToCString(DISALLOW_NULLS); |
1906 const char* elms[2] = { "Label", *c_string }; | 1906 const char* elms[2] = { "Label", *c_string }; |
1907 Vector<const char*> args(elms, 2); | 1907 Vector<const char*> args(elms, 2); |
1908 ReportMessage("redeclaration", args); | 1908 ReportMessage("redeclaration", args); |
1909 *ok = false; | 1909 *ok = false; |
1910 return NULL; | 1910 return NULL; |
1911 } | 1911 } |
1912 if (labels == NULL) labels = new(zone()) ZoneStringList(4); | 1912 if (labels == NULL) labels = new(zone()) ZoneStringList(4); |
1913 labels->Add(label); | 1913 labels->Add(label); |
1914 // Remove the "ghost" variable that turned out to be a label | 1914 // Remove the "ghost" variable that turned out to be a label |
1915 // from the top scope. This way, we don't try to resolve it | 1915 // from the top scope. This way, we don't try to resolve it |
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2999 Vector<const char*>::empty()); | 2999 Vector<const char*>::empty()); |
3000 default: | 3000 default: |
3001 const char* name = Token::String(token); | 3001 const char* name = Token::String(token); |
3002 ASSERT(name != NULL); | 3002 ASSERT(name != NULL); |
3003 ReportMessage("unexpected_token", Vector<const char*>(&name, 1)); | 3003 ReportMessage("unexpected_token", Vector<const char*>(&name, 1)); |
3004 } | 3004 } |
3005 } | 3005 } |
3006 | 3006 |
3007 | 3007 |
3008 void Parser::ReportInvalidPreparseData(Handle<String> name, bool* ok) { | 3008 void Parser::ReportInvalidPreparseData(Handle<String> name, bool* ok) { |
3009 SmartPointer<char> name_string = name->ToCString(DISALLOW_NULLS); | 3009 SmartArrayPointer<char> name_string = name->ToCString(DISALLOW_NULLS); |
3010 const char* element[1] = { *name_string }; | 3010 const char* element[1] = { *name_string }; |
3011 ReportMessage("invalid_preparser_data", | 3011 ReportMessage("invalid_preparser_data", |
3012 Vector<const char*>(element, 1)); | 3012 Vector<const char*>(element, 1)); |
3013 *ok = false; | 3013 *ok = false; |
3014 } | 3014 } |
3015 | 3015 |
3016 | 3016 |
3017 Expression* Parser::ParsePrimaryExpression(bool* ok) { | 3017 Expression* Parser::ParsePrimaryExpression(bool* ok) { |
3018 // PrimaryExpression :: | 3018 // PrimaryExpression :: |
3019 // 'this' | 3019 // 'this' |
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4089 } | 4089 } |
4090 } | 4090 } |
4091 | 4091 |
4092 | 4092 |
4093 void Parser::CheckConflictingVarDeclarations(Scope* scope, bool* ok) { | 4093 void Parser::CheckConflictingVarDeclarations(Scope* scope, bool* ok) { |
4094 Declaration* decl = scope->CheckConflictingVarDeclarations(); | 4094 Declaration* decl = scope->CheckConflictingVarDeclarations(); |
4095 if (decl != NULL) { | 4095 if (decl != NULL) { |
4096 // In harmony mode we treat conflicting variable bindinds as early | 4096 // In harmony mode we treat conflicting variable bindinds as early |
4097 // errors. See ES5 16 for a definition of early errors. | 4097 // errors. See ES5 16 for a definition of early errors. |
4098 Handle<String> name = decl->proxy()->name(); | 4098 Handle<String> name = decl->proxy()->name(); |
4099 SmartPointer<char> c_string = name->ToCString(DISALLOW_NULLS); | 4099 SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS); |
4100 const char* elms[2] = { "Variable", *c_string }; | 4100 const char* elms[2] = { "Variable", *c_string }; |
4101 Vector<const char*> args(elms, 2); | 4101 Vector<const char*> args(elms, 2); |
4102 int position = decl->proxy()->position(); | 4102 int position = decl->proxy()->position(); |
4103 Scanner::Location location = position == RelocInfo::kNoPosition | 4103 Scanner::Location location = position == RelocInfo::kNoPosition |
4104 ? Scanner::Location::invalid() | 4104 ? Scanner::Location::invalid() |
4105 : Scanner::Location(position, position + 1); | 4105 : Scanner::Location(position, position + 1); |
4106 ReportMessageAt(location, "redeclaration", args); | 4106 ReportMessageAt(location, "redeclaration", args); |
4107 *ok = false; | 4107 *ok = false; |
4108 } | 4108 } |
4109 } | 4109 } |
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5223 result = parser.ParseProgram(source, | 5223 result = parser.ParseProgram(source, |
5224 info->is_global(), | 5224 info->is_global(), |
5225 info->StrictMode()); | 5225 info->StrictMode()); |
5226 } | 5226 } |
5227 } | 5227 } |
5228 info->SetFunction(result); | 5228 info->SetFunction(result); |
5229 return (result != NULL); | 5229 return (result != NULL); |
5230 } | 5230 } |
5231 | 5231 |
5232 } } // namespace v8::internal | 5232 } } // namespace v8::internal |
OLD | NEW |