OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 250 |
251 | 251 |
252 Handle<String> Parser::LookupSymbol(int symbol_id) { | 252 Handle<String> Parser::LookupSymbol(int symbol_id) { |
253 // Length of symbol cache is the number of identified symbols. | 253 // Length of symbol cache is the number of identified symbols. |
254 // If we are larger than that, or negative, it's not a cached symbol. | 254 // If we are larger than that, or negative, it's not a cached symbol. |
255 // This might also happen if there is no preparser symbol data, even | 255 // This might also happen if there is no preparser symbol data, even |
256 // if there is some preparser data. | 256 // if there is some preparser data. |
257 if (static_cast<unsigned>(symbol_id) | 257 if (static_cast<unsigned>(symbol_id) |
258 >= static_cast<unsigned>(symbol_cache_.length())) { | 258 >= static_cast<unsigned>(symbol_cache_.length())) { |
259 if (scanner().is_literal_ascii()) { | 259 if (scanner().is_literal_ascii()) { |
260 return isolate()->factory()->LookupOneByteSymbol( | 260 return isolate()->factory()->InternalizeOneByteString( |
261 Vector<const uint8_t>::cast(scanner().literal_ascii_string())); | 261 Vector<const uint8_t>::cast(scanner().literal_ascii_string())); |
262 } else { | 262 } else { |
263 return isolate()->factory()->LookupTwoByteSymbol( | 263 return isolate()->factory()->InternalizeTwoByteString( |
264 scanner().literal_utf16_string()); | 264 scanner().literal_utf16_string()); |
265 } | 265 } |
266 } | 266 } |
267 return LookupCachedSymbol(symbol_id); | 267 return LookupCachedSymbol(symbol_id); |
268 } | 268 } |
269 | 269 |
270 | 270 |
271 Handle<String> Parser::LookupCachedSymbol(int symbol_id) { | 271 Handle<String> Parser::LookupCachedSymbol(int symbol_id) { |
272 // Make sure the cache is large enough to hold the symbol identifier. | 272 // Make sure the cache is large enough to hold the symbol identifier. |
273 if (symbol_cache_.length() <= symbol_id) { | 273 if (symbol_cache_.length() <= symbol_id) { |
274 // Increase length to index + 1. | 274 // Increase length to index + 1. |
275 symbol_cache_.AddBlock(Handle<String>::null(), | 275 symbol_cache_.AddBlock(Handle<String>::null(), |
276 symbol_id + 1 - symbol_cache_.length(), zone()); | 276 symbol_id + 1 - symbol_cache_.length(), zone()); |
277 } | 277 } |
278 Handle<String> result = symbol_cache_.at(symbol_id); | 278 Handle<String> result = symbol_cache_.at(symbol_id); |
279 if (result.is_null()) { | 279 if (result.is_null()) { |
280 if (scanner().is_literal_ascii()) { | 280 if (scanner().is_literal_ascii()) { |
281 result = isolate()->factory()->LookupOneByteSymbol( | 281 result = isolate()->factory()->InternalizeOneByteString( |
282 Vector<const uint8_t>::cast(scanner().literal_ascii_string())); | 282 Vector<const uint8_t>::cast(scanner().literal_ascii_string())); |
283 } else { | 283 } else { |
284 result = isolate()->factory()->LookupTwoByteSymbol( | 284 result = isolate()->factory()->InternalizeTwoByteString( |
285 scanner().literal_utf16_string()); | 285 scanner().literal_utf16_string()); |
286 } | 286 } |
287 symbol_cache_.at(symbol_id) = result; | 287 symbol_cache_.at(symbol_id) = result; |
288 return result; | 288 return result; |
289 } | 289 } |
290 isolate()->counters()->total_preparse_symbols_skipped()->Increment(); | 290 isolate()->counters()->total_preparse_symbols_skipped()->Increment(); |
291 return result; | 291 return result; |
292 } | 292 } |
293 | 293 |
294 | 294 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 } | 610 } |
611 | 611 |
612 | 612 |
613 FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, | 613 FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, |
614 Handle<String> source, | 614 Handle<String> source, |
615 ZoneScope* zone_scope) { | 615 ZoneScope* zone_scope) { |
616 ASSERT(top_scope_ == NULL); | 616 ASSERT(top_scope_ == NULL); |
617 ASSERT(target_stack_ == NULL); | 617 ASSERT(target_stack_ == NULL); |
618 if (pre_data_ != NULL) pre_data_->Initialize(); | 618 if (pre_data_ != NULL) pre_data_->Initialize(); |
619 | 619 |
620 Handle<String> no_name = isolate()->factory()->empty_symbol(); | 620 Handle<String> no_name = isolate()->factory()->empty_string(); |
621 | 621 |
622 FunctionLiteral* result = NULL; | 622 FunctionLiteral* result = NULL; |
623 { Scope* scope = NewScope(top_scope_, GLOBAL_SCOPE); | 623 { Scope* scope = NewScope(top_scope_, GLOBAL_SCOPE); |
624 info->SetGlobalScope(scope); | 624 info->SetGlobalScope(scope); |
625 if (!info->context().is_null()) { | 625 if (!info->context().is_null()) { |
626 scope = Scope::DeserializeScopeChain(*info->context(), scope, zone()); | 626 scope = Scope::DeserializeScopeChain(*info->context(), scope, zone()); |
627 } | 627 } |
628 if (info->is_eval()) { | 628 if (info->is_eval()) { |
629 if (!scope->is_global_scope() || info->language_mode() != CLASSIC_MODE) { | 629 if (!scope->is_global_scope() || info->language_mode() != CLASSIC_MODE) { |
630 scope = NewScope(scope, EVAL_SCOPE); | 630 scope = NewScope(scope, EVAL_SCOPE); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 void HandleThisPropertyAssignment(Scope* scope, Assignment* assignment) { | 913 void HandleThisPropertyAssignment(Scope* scope, Assignment* assignment) { |
914 // Check that the property assigned to is a named property, which is not | 914 // Check that the property assigned to is a named property, which is not |
915 // __proto__. | 915 // __proto__. |
916 Property* property = assignment->target()->AsProperty(); | 916 Property* property = assignment->target()->AsProperty(); |
917 ASSERT(property != NULL); | 917 ASSERT(property != NULL); |
918 Literal* literal = property->key()->AsLiteral(); | 918 Literal* literal = property->key()->AsLiteral(); |
919 uint32_t dummy; | 919 uint32_t dummy; |
920 if (literal != NULL && | 920 if (literal != NULL && |
921 literal->handle()->IsString() && | 921 literal->handle()->IsString() && |
922 !String::cast(*(literal->handle()))->Equals( | 922 !String::cast(*(literal->handle()))->Equals( |
923 isolate_->heap()->Proto_symbol()) && | 923 isolate_->heap()->proto_string()) && |
924 !String::cast(*(literal->handle()))->AsArrayIndex(&dummy)) { | 924 !String::cast(*(literal->handle()))->AsArrayIndex(&dummy)) { |
925 Handle<String> key = Handle<String>::cast(literal->handle()); | 925 Handle<String> key = Handle<String>::cast(literal->handle()); |
926 | 926 |
927 // Check whether the value assigned is either a constant or matches the | 927 // Check whether the value assigned is either a constant or matches the |
928 // name of one of the arguments to the function. | 928 // name of one of the arguments to the function. |
929 if (assignment->value()->AsLiteral() != NULL) { | 929 if (assignment->value()->AsLiteral() != NULL) { |
930 // Constant assigned. | 930 // Constant assigned. |
931 Literal* literal = assignment->value()->AsLiteral(); | 931 Literal* literal = assignment->value()->AsLiteral(); |
932 AssignmentFromConstant(key, literal->handle()); | 932 AssignmentFromConstant(key, literal->handle()); |
933 return; | 933 return; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 ExpressionStatement* e_stat; | 1050 ExpressionStatement* e_stat; |
1051 Literal* literal; | 1051 Literal* literal; |
1052 // Still processing directive prologue? | 1052 // Still processing directive prologue? |
1053 if ((e_stat = stat->AsExpressionStatement()) != NULL && | 1053 if ((e_stat = stat->AsExpressionStatement()) != NULL && |
1054 (literal = e_stat->expression()->AsLiteral()) != NULL && | 1054 (literal = e_stat->expression()->AsLiteral()) != NULL && |
1055 literal->handle()->IsString()) { | 1055 literal->handle()->IsString()) { |
1056 Handle<String> directive = Handle<String>::cast(literal->handle()); | 1056 Handle<String> directive = Handle<String>::cast(literal->handle()); |
1057 | 1057 |
1058 // Check "use strict" directive (ES5 14.1). | 1058 // Check "use strict" directive (ES5 14.1). |
1059 if (top_scope_->is_classic_mode() && | 1059 if (top_scope_->is_classic_mode() && |
1060 directive->Equals(isolate()->heap()->use_strict()) && | 1060 directive->Equals(isolate()->heap()->use_strict_string()) && |
1061 token_loc.end_pos - token_loc.beg_pos == | 1061 token_loc.end_pos - token_loc.beg_pos == |
1062 isolate()->heap()->use_strict()->length() + 2) { | 1062 isolate()->heap()->use_strict_string()->length() + 2) { |
1063 // TODO(mstarzinger): Global strict eval calls, need their own scope | 1063 // TODO(mstarzinger): Global strict eval calls, need their own scope |
1064 // as specified in ES5 10.4.2(3). The correct fix would be to always | 1064 // as specified in ES5 10.4.2(3). The correct fix would be to always |
1065 // add this scope in DoParseProgram(), but that requires adaptations | 1065 // add this scope in DoParseProgram(), but that requires adaptations |
1066 // all over the code base, so we go with a quick-fix for now. | 1066 // all over the code base, so we go with a quick-fix for now. |
1067 // In the same manner, we have to patch the parsing mode. | 1067 // In the same manner, we have to patch the parsing mode. |
1068 if (is_eval && !top_scope_->is_eval_scope()) { | 1068 if (is_eval && !top_scope_->is_eval_scope()) { |
1069 ASSERT(top_scope_->is_global_scope()); | 1069 ASSERT(top_scope_->is_global_scope()); |
1070 Scope* scope = NewScope(top_scope_, EVAL_SCOPE); | 1070 Scope* scope = NewScope(top_scope_, EVAL_SCOPE); |
1071 scope->set_start_position(top_scope_->start_position()); | 1071 scope->set_start_position(top_scope_->start_position()); |
1072 scope->set_end_position(top_scope_->end_position()); | 1072 scope->set_end_position(top_scope_->end_position()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 Statement* stmt = ParseStatement(labels, CHECK_OK); | 1137 Statement* stmt = ParseStatement(labels, CHECK_OK); |
1138 // Handle 'module' as a context-sensitive keyword. | 1138 // Handle 'module' as a context-sensitive keyword. |
1139 if (FLAG_harmony_modules && | 1139 if (FLAG_harmony_modules && |
1140 peek() == Token::IDENTIFIER && | 1140 peek() == Token::IDENTIFIER && |
1141 !scanner().HasAnyLineTerminatorBeforeNext() && | 1141 !scanner().HasAnyLineTerminatorBeforeNext() && |
1142 stmt != NULL) { | 1142 stmt != NULL) { |
1143 ExpressionStatement* estmt = stmt->AsExpressionStatement(); | 1143 ExpressionStatement* estmt = stmt->AsExpressionStatement(); |
1144 if (estmt != NULL && | 1144 if (estmt != NULL && |
1145 estmt->expression()->AsVariableProxy() != NULL && | 1145 estmt->expression()->AsVariableProxy() != NULL && |
1146 estmt->expression()->AsVariableProxy()->name()->Equals( | 1146 estmt->expression()->AsVariableProxy()->name()->Equals( |
1147 isolate()->heap()->module_symbol()) && | 1147 isolate()->heap()->module_string()) && |
1148 !scanner().literal_contains_escapes()) { | 1148 !scanner().literal_contains_escapes()) { |
1149 return ParseModuleDeclaration(NULL, ok); | 1149 return ParseModuleDeclaration(NULL, ok); |
1150 } | 1150 } |
1151 } | 1151 } |
1152 return stmt; | 1152 return stmt; |
1153 } | 1153 } |
1154 } | 1154 } |
1155 } | 1155 } |
1156 | 1156 |
1157 | 1157 |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 const char* elms[2] = { "Variable", *c_string }; | 1709 const char* elms[2] = { "Variable", *c_string }; |
1710 Vector<const char*> args(elms, 2); | 1710 Vector<const char*> args(elms, 2); |
1711 ReportMessage("redeclaration", args); | 1711 ReportMessage("redeclaration", args); |
1712 *ok = false; | 1712 *ok = false; |
1713 return; | 1713 return; |
1714 } | 1714 } |
1715 Handle<String> type_string = | 1715 Handle<String> type_string = |
1716 isolate()->factory()->NewStringFromUtf8(CStrVector("Variable"), | 1716 isolate()->factory()->NewStringFromUtf8(CStrVector("Variable"), |
1717 TENURED); | 1717 TENURED); |
1718 Expression* expression = | 1718 Expression* expression = |
1719 NewThrowTypeError(isolate()->factory()->redeclaration_symbol(), | 1719 NewThrowTypeError(isolate()->factory()->redeclaration_string(), |
1720 type_string, name); | 1720 type_string, name); |
1721 declaration_scope->SetIllegalRedeclaration(expression); | 1721 declaration_scope->SetIllegalRedeclaration(expression); |
1722 } | 1722 } |
1723 } | 1723 } |
1724 | 1724 |
1725 // We add a declaration node for every declaration. The compiler | 1725 // We add a declaration node for every declaration. The compiler |
1726 // will only generate code if necessary. In particular, declarations | 1726 // will only generate code if necessary. In particular, declarations |
1727 // for inner local variables that do not represent functions won't | 1727 // for inner local variables that do not represent functions won't |
1728 // result in any generated code. | 1728 // result in any generated code. |
1729 // | 1729 // |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1971 | 1971 |
1972 Handle<String> ignore; | 1972 Handle<String> ignore; |
1973 Block* result = | 1973 Block* result = |
1974 ParseVariableDeclarations(var_context, NULL, names, &ignore, CHECK_OK); | 1974 ParseVariableDeclarations(var_context, NULL, names, &ignore, CHECK_OK); |
1975 ExpectSemicolon(CHECK_OK); | 1975 ExpectSemicolon(CHECK_OK); |
1976 return result; | 1976 return result; |
1977 } | 1977 } |
1978 | 1978 |
1979 | 1979 |
1980 bool Parser::IsEvalOrArguments(Handle<String> string) { | 1980 bool Parser::IsEvalOrArguments(Handle<String> string) { |
1981 return string.is_identical_to(isolate()->factory()->eval_symbol()) || | 1981 return string.is_identical_to(isolate()->factory()->eval_string()) || |
1982 string.is_identical_to(isolate()->factory()->arguments_symbol()); | 1982 string.is_identical_to(isolate()->factory()->arguments_string()); |
1983 } | 1983 } |
1984 | 1984 |
1985 | 1985 |
1986 // If the variable declaration declares exactly one non-const | 1986 // If the variable declaration declares exactly one non-const |
1987 // variable, then *out is set to that variable. In all other cases, | 1987 // variable, then *out is set to that variable. In all other cases, |
1988 // *out is untouched; in particular, it is the caller's responsibility | 1988 // *out is untouched; in particular, it is the caller's responsibility |
1989 // to initialize it properly. This mechanism is used for the parsing | 1989 // to initialize it properly. This mechanism is used for the parsing |
1990 // of 'for-in' loops. | 1990 // of 'for-in' loops. |
1991 Block* Parser::ParseVariableDeclarations( | 1991 Block* Parser::ParseVariableDeclarations( |
1992 VariableDeclarationContext var_context, | 1992 VariableDeclarationContext var_context, |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2226 | 2226 |
2227 if (is_const) { | 2227 if (is_const) { |
2228 arguments->Add(value, zone()); | 2228 arguments->Add(value, zone()); |
2229 value = NULL; // zap the value to avoid the unnecessary assignment | 2229 value = NULL; // zap the value to avoid the unnecessary assignment |
2230 | 2230 |
2231 // Construct the call to Runtime_InitializeConstGlobal | 2231 // Construct the call to Runtime_InitializeConstGlobal |
2232 // and add it to the initialization statement block. | 2232 // and add it to the initialization statement block. |
2233 // Note that the function does different things depending on | 2233 // Note that the function does different things depending on |
2234 // the number of arguments (1 or 2). | 2234 // the number of arguments (1 or 2). |
2235 initialize = factory()->NewCallRuntime( | 2235 initialize = factory()->NewCallRuntime( |
2236 isolate()->factory()->InitializeConstGlobal_symbol(), | 2236 isolate()->factory()->InitializeConstGlobal_string(), |
2237 Runtime::FunctionForId(Runtime::kInitializeConstGlobal), | 2237 Runtime::FunctionForId(Runtime::kInitializeConstGlobal), |
2238 arguments); | 2238 arguments); |
2239 } else { | 2239 } else { |
2240 // Add strict mode. | 2240 // Add strict mode. |
2241 // We may want to pass singleton to avoid Literal allocations. | 2241 // We may want to pass singleton to avoid Literal allocations. |
2242 LanguageMode language_mode = initialization_scope->language_mode(); | 2242 LanguageMode language_mode = initialization_scope->language_mode(); |
2243 arguments->Add(factory()->NewNumberLiteral(language_mode), zone()); | 2243 arguments->Add(factory()->NewNumberLiteral(language_mode), zone()); |
2244 | 2244 |
2245 // Be careful not to assign a value to the global variable if | 2245 // Be careful not to assign a value to the global variable if |
2246 // we're in a with. The initialization value should not | 2246 // we're in a with. The initialization value should not |
2247 // necessarily be stored in the global object in that case, | 2247 // necessarily be stored in the global object in that case, |
2248 // which is why we need to generate a separate assignment node. | 2248 // which is why we need to generate a separate assignment node. |
2249 if (value != NULL && !inside_with()) { | 2249 if (value != NULL && !inside_with()) { |
2250 arguments->Add(value, zone()); | 2250 arguments->Add(value, zone()); |
2251 value = NULL; // zap the value to avoid the unnecessary assignment | 2251 value = NULL; // zap the value to avoid the unnecessary assignment |
2252 } | 2252 } |
2253 | 2253 |
2254 // Construct the call to Runtime_InitializeVarGlobal | 2254 // Construct the call to Runtime_InitializeVarGlobal |
2255 // and add it to the initialization statement block. | 2255 // and add it to the initialization statement block. |
2256 // Note that the function does different things depending on | 2256 // Note that the function does different things depending on |
2257 // the number of arguments (2 or 3). | 2257 // the number of arguments (2 or 3). |
2258 initialize = factory()->NewCallRuntime( | 2258 initialize = factory()->NewCallRuntime( |
2259 isolate()->factory()->InitializeVarGlobal_symbol(), | 2259 isolate()->factory()->InitializeVarGlobal_string(), |
2260 Runtime::FunctionForId(Runtime::kInitializeVarGlobal), | 2260 Runtime::FunctionForId(Runtime::kInitializeVarGlobal), |
2261 arguments); | 2261 arguments); |
2262 } | 2262 } |
2263 | 2263 |
2264 block->AddStatement(factory()->NewExpressionStatement(initialize), | 2264 block->AddStatement(factory()->NewExpressionStatement(initialize), |
2265 zone()); | 2265 zone()); |
2266 } else if (needs_init) { | 2266 } else if (needs_init) { |
2267 // Constant initializations always assign to the declared constant which | 2267 // Constant initializations always assign to the declared constant which |
2268 // is always at the function scope level. This is only relevant for | 2268 // is always at the function scope level. This is only relevant for |
2269 // dynamically looked-up variables and constants (the start context for | 2269 // dynamically looked-up variables and constants (the start context for |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2361 | 2361 |
2362 // If we have an extension, we allow a native function declaration. | 2362 // If we have an extension, we allow a native function declaration. |
2363 // A native function declaration starts with "native function" with | 2363 // A native function declaration starts with "native function" with |
2364 // no line-terminator between the two words. | 2364 // no line-terminator between the two words. |
2365 if (extension_ != NULL && | 2365 if (extension_ != NULL && |
2366 peek() == Token::FUNCTION && | 2366 peek() == Token::FUNCTION && |
2367 !scanner().HasAnyLineTerminatorBeforeNext() && | 2367 !scanner().HasAnyLineTerminatorBeforeNext() && |
2368 expr != NULL && | 2368 expr != NULL && |
2369 expr->AsVariableProxy() != NULL && | 2369 expr->AsVariableProxy() != NULL && |
2370 expr->AsVariableProxy()->name()->Equals( | 2370 expr->AsVariableProxy()->name()->Equals( |
2371 isolate()->heap()->native_symbol()) && | 2371 isolate()->heap()->native_string()) && |
2372 !scanner().literal_contains_escapes()) { | 2372 !scanner().literal_contains_escapes()) { |
2373 return ParseNativeDeclaration(ok); | 2373 return ParseNativeDeclaration(ok); |
2374 } | 2374 } |
2375 | 2375 |
2376 // Parsed expression statement, or the context-sensitive 'module' keyword. | 2376 // Parsed expression statement, or the context-sensitive 'module' keyword. |
2377 // Only expect semicolon in the former case. | 2377 // Only expect semicolon in the former case. |
2378 if (!FLAG_harmony_modules || | 2378 if (!FLAG_harmony_modules || |
2379 peek() != Token::IDENTIFIER || | 2379 peek() != Token::IDENTIFIER || |
2380 scanner().HasAnyLineTerminatorBeforeNext() || | 2380 scanner().HasAnyLineTerminatorBeforeNext() || |
2381 expr->AsVariableProxy() == NULL || | 2381 expr->AsVariableProxy() == NULL || |
2382 !expr->AsVariableProxy()->name()->Equals( | 2382 !expr->AsVariableProxy()->name()->Equals( |
2383 isolate()->heap()->module_symbol()) || | 2383 isolate()->heap()->module_string()) || |
2384 scanner().literal_contains_escapes()) { | 2384 scanner().literal_contains_escapes()) { |
2385 ExpectSemicolon(CHECK_OK); | 2385 ExpectSemicolon(CHECK_OK); |
2386 } | 2386 } |
2387 return factory()->NewExpressionStatement(expr); | 2387 return factory()->NewExpressionStatement(expr); |
2388 } | 2388 } |
2389 | 2389 |
2390 | 2390 |
2391 IfStatement* Parser::ParseIfStatement(ZoneStringList* labels, bool* ok) { | 2391 IfStatement* Parser::ParseIfStatement(ZoneStringList* labels, bool* ok) { |
2392 // IfStatement :: | 2392 // IfStatement :: |
2393 // 'if' '(' Expression ')' Statement ('else' Statement)? | 2393 // 'if' '(' Expression ')' Statement ('else' Statement)? |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2498 } | 2498 } |
2499 | 2499 |
2500 // An ECMAScript program is considered syntactically incorrect if it | 2500 // An ECMAScript program is considered syntactically incorrect if it |
2501 // contains a return statement that is not within the body of a | 2501 // contains a return statement that is not within the body of a |
2502 // function. See ECMA-262, section 12.9, page 67. | 2502 // function. See ECMA-262, section 12.9, page 67. |
2503 // | 2503 // |
2504 // To be consistent with KJS we report the syntax error at runtime. | 2504 // To be consistent with KJS we report the syntax error at runtime. |
2505 Scope* declaration_scope = top_scope_->DeclarationScope(); | 2505 Scope* declaration_scope = top_scope_->DeclarationScope(); |
2506 if (declaration_scope->is_global_scope() || | 2506 if (declaration_scope->is_global_scope() || |
2507 declaration_scope->is_eval_scope()) { | 2507 declaration_scope->is_eval_scope()) { |
2508 Handle<String> type = isolate()->factory()->illegal_return_symbol(); | 2508 Handle<String> type = isolate()->factory()->illegal_return_string(); |
2509 Expression* throw_error = NewThrowSyntaxError(type, Handle<Object>::null()); | 2509 Expression* throw_error = NewThrowSyntaxError(type, Handle<Object>::null()); |
2510 return factory()->NewExpressionStatement(throw_error); | 2510 return factory()->NewExpressionStatement(throw_error); |
2511 } | 2511 } |
2512 return result; | 2512 return result; |
2513 } | 2513 } |
2514 | 2514 |
2515 | 2515 |
2516 Statement* Parser::ParseWithStatement(ZoneStringList* labels, bool* ok) { | 2516 Statement* Parser::ParseWithStatement(ZoneStringList* labels, bool* ok) { |
2517 // WithStatement :: | 2517 // WithStatement :: |
2518 // 'with' '(' Expression ')' Statement | 2518 // 'with' '(' Expression ')' Statement |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2846 // for (x' in e) { | 2846 // for (x' in e) { |
2847 // let x; | 2847 // let x; |
2848 // x = x'; | 2848 // x = x'; |
2849 // b; | 2849 // b; |
2850 // } | 2850 // } |
2851 | 2851 |
2852 // TODO(keuchel): Move the temporary variable to the block scope, after | 2852 // TODO(keuchel): Move the temporary variable to the block scope, after |
2853 // implementing stack allocated block scoped variables. | 2853 // implementing stack allocated block scoped variables. |
2854 Factory* heap_factory = isolate()->factory(); | 2854 Factory* heap_factory = isolate()->factory(); |
2855 Handle<String> tempstr = | 2855 Handle<String> tempstr = |
2856 heap_factory->NewConsString(heap_factory->dot_for_symbol(), name); | 2856 heap_factory->NewConsString(heap_factory->dot_for_string(), name); |
2857 Handle<String> tempname = heap_factory->LookupSymbol(tempstr); | 2857 Handle<String> tempname = heap_factory->InternalizeString(tempstr); |
2858 Variable* temp = top_scope_->DeclarationScope()->NewTemporary(tempname); | 2858 Variable* temp = top_scope_->DeclarationScope()->NewTemporary(tempname); |
2859 VariableProxy* temp_proxy = factory()->NewVariableProxy(temp); | 2859 VariableProxy* temp_proxy = factory()->NewVariableProxy(temp); |
2860 ForInStatement* loop = factory()->NewForInStatement(labels); | 2860 ForInStatement* loop = factory()->NewForInStatement(labels); |
2861 Target target(&this->target_stack_, loop); | 2861 Target target(&this->target_stack_, loop); |
2862 | 2862 |
2863 // The expression does not see the loop variable. | 2863 // The expression does not see the loop variable. |
2864 Expect(Token::IN, CHECK_OK); | 2864 Expect(Token::IN, CHECK_OK); |
2865 top_scope_ = saved_scope; | 2865 top_scope_ = saved_scope; |
2866 Expression* enumerable = ParseExpression(true, CHECK_OK); | 2866 Expression* enumerable = ParseExpression(true, CHECK_OK); |
2867 top_scope_ = for_scope; | 2867 top_scope_ = for_scope; |
(...skipping 23 matching lines...) Expand all Loading... |
2891 } | 2891 } |
2892 } else { | 2892 } else { |
2893 Expression* expression = ParseExpression(false, CHECK_OK); | 2893 Expression* expression = ParseExpression(false, CHECK_OK); |
2894 if (peek() == Token::IN) { | 2894 if (peek() == Token::IN) { |
2895 // Signal a reference error if the expression is an invalid | 2895 // Signal a reference error if the expression is an invalid |
2896 // left-hand side expression. We could report this as a syntax | 2896 // left-hand side expression. We could report this as a syntax |
2897 // error here but for compatibility with JSC we choose to report | 2897 // error here but for compatibility with JSC we choose to report |
2898 // the error at runtime. | 2898 // the error at runtime. |
2899 if (expression == NULL || !expression->IsValidLeftHandSide()) { | 2899 if (expression == NULL || !expression->IsValidLeftHandSide()) { |
2900 Handle<String> type = | 2900 Handle<String> type = |
2901 isolate()->factory()->invalid_lhs_in_for_in_symbol(); | 2901 isolate()->factory()->invalid_lhs_in_for_in_string(); |
2902 expression = NewThrowReferenceError(type); | 2902 expression = NewThrowReferenceError(type); |
2903 } | 2903 } |
2904 ForInStatement* loop = factory()->NewForInStatement(labels); | 2904 ForInStatement* loop = factory()->NewForInStatement(labels); |
2905 Target target(&this->target_stack_, loop); | 2905 Target target(&this->target_stack_, loop); |
2906 | 2906 |
2907 Expect(Token::IN, CHECK_OK); | 2907 Expect(Token::IN, CHECK_OK); |
2908 Expression* enumerable = ParseExpression(true, CHECK_OK); | 2908 Expression* enumerable = ParseExpression(true, CHECK_OK); |
2909 Expect(Token::RPAREN, CHECK_OK); | 2909 Expect(Token::RPAREN, CHECK_OK); |
2910 | 2910 |
2911 Statement* body = ParseStatement(NULL, CHECK_OK); | 2911 Statement* body = ParseStatement(NULL, CHECK_OK); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3005 return expression; | 3005 return expression; |
3006 } | 3006 } |
3007 | 3007 |
3008 // Signal a reference error if the expression is an invalid left-hand | 3008 // Signal a reference error if the expression is an invalid left-hand |
3009 // side expression. We could report this as a syntax error here but | 3009 // side expression. We could report this as a syntax error here but |
3010 // for compatibility with JSC we choose to report the error at | 3010 // for compatibility with JSC we choose to report the error at |
3011 // runtime. | 3011 // runtime. |
3012 // TODO(ES5): Should change parsing for spec conformance. | 3012 // TODO(ES5): Should change parsing for spec conformance. |
3013 if (expression == NULL || !expression->IsValidLeftHandSide()) { | 3013 if (expression == NULL || !expression->IsValidLeftHandSide()) { |
3014 Handle<String> type = | 3014 Handle<String> type = |
3015 isolate()->factory()->invalid_lhs_in_assignment_symbol(); | 3015 isolate()->factory()->invalid_lhs_in_assignment_string(); |
3016 expression = NewThrowReferenceError(type); | 3016 expression = NewThrowReferenceError(type); |
3017 } | 3017 } |
3018 | 3018 |
3019 if (!top_scope_->is_classic_mode()) { | 3019 if (!top_scope_->is_classic_mode()) { |
3020 // Assignment to eval or arguments is disallowed in strict mode. | 3020 // Assignment to eval or arguments is disallowed in strict mode. |
3021 CheckStrictModeLValue(expression, "strict_lhs_assignment", CHECK_OK); | 3021 CheckStrictModeLValue(expression, "strict_lhs_assignment", CHECK_OK); |
3022 } | 3022 } |
3023 MarkAsLValue(expression); | 3023 MarkAsLValue(expression); |
3024 | 3024 |
3025 Token::Value op = Next(); // Get assignment operator. | 3025 Token::Value op = Next(); // Get assignment operator. |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3246 | 3246 |
3247 } else if (Token::IsCountOp(op)) { | 3247 } else if (Token::IsCountOp(op)) { |
3248 op = Next(); | 3248 op = Next(); |
3249 Expression* expression = ParseUnaryExpression(CHECK_OK); | 3249 Expression* expression = ParseUnaryExpression(CHECK_OK); |
3250 // Signal a reference error if the expression is an invalid | 3250 // Signal a reference error if the expression is an invalid |
3251 // left-hand side expression. We could report this as a syntax | 3251 // left-hand side expression. We could report this as a syntax |
3252 // error here but for compatibility with JSC we choose to report the | 3252 // error here but for compatibility with JSC we choose to report the |
3253 // error at runtime. | 3253 // error at runtime. |
3254 if (expression == NULL || !expression->IsValidLeftHandSide()) { | 3254 if (expression == NULL || !expression->IsValidLeftHandSide()) { |
3255 Handle<String> type = | 3255 Handle<String> type = |
3256 isolate()->factory()->invalid_lhs_in_prefix_op_symbol(); | 3256 isolate()->factory()->invalid_lhs_in_prefix_op_string(); |
3257 expression = NewThrowReferenceError(type); | 3257 expression = NewThrowReferenceError(type); |
3258 } | 3258 } |
3259 | 3259 |
3260 if (!top_scope_->is_classic_mode()) { | 3260 if (!top_scope_->is_classic_mode()) { |
3261 // Prefix expression operand in strict mode may not be eval or arguments. | 3261 // Prefix expression operand in strict mode may not be eval or arguments. |
3262 CheckStrictModeLValue(expression, "strict_lhs_prefix", CHECK_OK); | 3262 CheckStrictModeLValue(expression, "strict_lhs_prefix", CHECK_OK); |
3263 } | 3263 } |
3264 MarkAsLValue(expression); | 3264 MarkAsLValue(expression); |
3265 | 3265 |
3266 int position = scanner().location().beg_pos; | 3266 int position = scanner().location().beg_pos; |
(...skipping 14 matching lines...) Expand all Loading... |
3281 | 3281 |
3282 Expression* expression = ParseLeftHandSideExpression(CHECK_OK); | 3282 Expression* expression = ParseLeftHandSideExpression(CHECK_OK); |
3283 if (!scanner().HasAnyLineTerminatorBeforeNext() && | 3283 if (!scanner().HasAnyLineTerminatorBeforeNext() && |
3284 Token::IsCountOp(peek())) { | 3284 Token::IsCountOp(peek())) { |
3285 // Signal a reference error if the expression is an invalid | 3285 // Signal a reference error if the expression is an invalid |
3286 // left-hand side expression. We could report this as a syntax | 3286 // left-hand side expression. We could report this as a syntax |
3287 // error here but for compatibility with JSC we choose to report the | 3287 // error here but for compatibility with JSC we choose to report the |
3288 // error at runtime. | 3288 // error at runtime. |
3289 if (expression == NULL || !expression->IsValidLeftHandSide()) { | 3289 if (expression == NULL || !expression->IsValidLeftHandSide()) { |
3290 Handle<String> type = | 3290 Handle<String> type = |
3291 isolate()->factory()->invalid_lhs_in_postfix_op_symbol(); | 3291 isolate()->factory()->invalid_lhs_in_postfix_op_string(); |
3292 expression = NewThrowReferenceError(type); | 3292 expression = NewThrowReferenceError(type); |
3293 } | 3293 } |
3294 | 3294 |
3295 if (!top_scope_->is_classic_mode()) { | 3295 if (!top_scope_->is_classic_mode()) { |
3296 // Postfix expression operand in strict mode may not be eval or arguments. | 3296 // Postfix expression operand in strict mode may not be eval or arguments. |
3297 CheckStrictModeLValue(expression, "strict_lhs_prefix", CHECK_OK); | 3297 CheckStrictModeLValue(expression, "strict_lhs_prefix", CHECK_OK); |
3298 } | 3298 } |
3299 MarkAsLValue(expression); | 3299 MarkAsLValue(expression); |
3300 | 3300 |
3301 Token::Value next = Next(); | 3301 Token::Value next = Next(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3356 | 3356 |
3357 // Keep track of eval() calls since they disable all local variable | 3357 // Keep track of eval() calls since they disable all local variable |
3358 // optimizations. | 3358 // optimizations. |
3359 // The calls that need special treatment are the | 3359 // The calls that need special treatment are the |
3360 // direct eval calls. These calls are all of the form eval(...), with | 3360 // direct eval calls. These calls are all of the form eval(...), with |
3361 // no explicit receiver. | 3361 // no explicit receiver. |
3362 // These calls are marked as potentially direct eval calls. Whether | 3362 // These calls are marked as potentially direct eval calls. Whether |
3363 // they are actually direct calls to eval is determined at run time. | 3363 // they are actually direct calls to eval is determined at run time. |
3364 VariableProxy* callee = result->AsVariableProxy(); | 3364 VariableProxy* callee = result->AsVariableProxy(); |
3365 if (callee != NULL && | 3365 if (callee != NULL && |
3366 callee->IsVariable(isolate()->factory()->eval_symbol())) { | 3366 callee->IsVariable(isolate()->factory()->eval_string())) { |
3367 top_scope_->DeclarationScope()->RecordEvalCall(); | 3367 top_scope_->DeclarationScope()->RecordEvalCall(); |
3368 } | 3368 } |
3369 result = factory()->NewCall(result, args, pos); | 3369 result = factory()->NewCall(result, args, pos); |
3370 break; | 3370 break; |
3371 } | 3371 } |
3372 | 3372 |
3373 case Token::PERIOD: { | 3373 case Token::PERIOD: { |
3374 Consume(Token::PERIOD); | 3374 Consume(Token::PERIOD); |
3375 int pos = scanner().location().beg_pos; | 3375 int pos = scanner().location().beg_pos; |
3376 Handle<String> name = ParseIdentifierName(CHECK_OK); | 3376 Handle<String> name = ParseIdentifierName(CHECK_OK); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3463 case Token::LBRACK: { | 3463 case Token::LBRACK: { |
3464 Consume(Token::LBRACK); | 3464 Consume(Token::LBRACK); |
3465 int pos = scanner().location().beg_pos; | 3465 int pos = scanner().location().beg_pos; |
3466 Expression* index = ParseExpression(true, CHECK_OK); | 3466 Expression* index = ParseExpression(true, CHECK_OK); |
3467 result = factory()->NewProperty(result, index, pos); | 3467 result = factory()->NewProperty(result, index, pos); |
3468 if (fni_ != NULL) { | 3468 if (fni_ != NULL) { |
3469 if (index->IsPropertyName()) { | 3469 if (index->IsPropertyName()) { |
3470 fni_->PushLiteralName(index->AsLiteral()->AsPropertyName()); | 3470 fni_->PushLiteralName(index->AsLiteral()->AsPropertyName()); |
3471 } else { | 3471 } else { |
3472 fni_->PushLiteralName( | 3472 fni_->PushLiteralName( |
3473 isolate()->factory()->anonymous_function_symbol()); | 3473 isolate()->factory()->anonymous_function_string()); |
3474 } | 3474 } |
3475 } | 3475 } |
3476 Expect(Token::RBRACK, CHECK_OK); | 3476 Expect(Token::RBRACK, CHECK_OK); |
3477 break; | 3477 break; |
3478 } | 3478 } |
3479 case Token::PERIOD: { | 3479 case Token::PERIOD: { |
3480 Consume(Token::PERIOD); | 3480 Consume(Token::PERIOD); |
3481 int pos = scanner().location().beg_pos; | 3481 int pos = scanner().location().beg_pos; |
3482 Handle<String> name = ParseIdentifierName(CHECK_OK); | 3482 Handle<String> name = ParseIdentifierName(CHECK_OK); |
3483 result = | 3483 result = |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3985 // { ... , get foo() { ... }, ... , set foo(v) { ... v ... } , ... } | 3985 // { ... , get foo() { ... }, ... , set foo(v) { ... v ... } , ... } |
3986 // We have already read the "get" or "set" keyword. | 3986 // We have already read the "get" or "set" keyword. |
3987 Token::Value next = Next(); | 3987 Token::Value next = Next(); |
3988 bool is_keyword = Token::IsKeyword(next); | 3988 bool is_keyword = Token::IsKeyword(next); |
3989 if (next == Token::IDENTIFIER || next == Token::NUMBER || | 3989 if (next == Token::IDENTIFIER || next == Token::NUMBER || |
3990 next == Token::FUTURE_RESERVED_WORD || | 3990 next == Token::FUTURE_RESERVED_WORD || |
3991 next == Token::FUTURE_STRICT_RESERVED_WORD || | 3991 next == Token::FUTURE_STRICT_RESERVED_WORD || |
3992 next == Token::STRING || is_keyword) { | 3992 next == Token::STRING || is_keyword) { |
3993 Handle<String> name; | 3993 Handle<String> name; |
3994 if (is_keyword) { | 3994 if (is_keyword) { |
3995 name = isolate_->factory()->LookupUtf8Symbol(Token::String(next)); | 3995 name = isolate_->factory()->InternalizeUtf8String(Token::String(next)); |
3996 } else { | 3996 } else { |
3997 name = GetSymbol(CHECK_OK); | 3997 name = GetSymbol(CHECK_OK); |
3998 } | 3998 } |
3999 FunctionLiteral* value = | 3999 FunctionLiteral* value = |
4000 ParseFunctionLiteral(name, | 4000 ParseFunctionLiteral(name, |
4001 false, // reserved words are allowed here | 4001 false, // reserved words are allowed here |
4002 RelocInfo::kNoPosition, | 4002 RelocInfo::kNoPosition, |
4003 FunctionLiteral::ANONYMOUS_EXPRESSION, | 4003 FunctionLiteral::ANONYMOUS_EXPRESSION, |
4004 CHECK_OK); | 4004 CHECK_OK); |
4005 // Allow any number of parameters for compatibilty with JSC. | 4005 // Allow any number of parameters for compatibilty with JSC. |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4306 // Function :: | 4306 // Function :: |
4307 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 4307 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
4308 | 4308 |
4309 // Anonymous functions were passed either the empty symbol or a null | 4309 // Anonymous functions were passed either the empty symbol or a null |
4310 // handle as the function name. Remember if we were passed a non-empty | 4310 // handle as the function name. Remember if we were passed a non-empty |
4311 // handle to decide whether to invoke function name inference. | 4311 // handle to decide whether to invoke function name inference. |
4312 bool should_infer_name = function_name.is_null(); | 4312 bool should_infer_name = function_name.is_null(); |
4313 | 4313 |
4314 // We want a non-null handle as the function name. | 4314 // We want a non-null handle as the function name. |
4315 if (should_infer_name) { | 4315 if (should_infer_name) { |
4316 function_name = isolate()->factory()->empty_symbol(); | 4316 function_name = isolate()->factory()->empty_string(); |
4317 } | 4317 } |
4318 | 4318 |
4319 int num_parameters = 0; | 4319 int num_parameters = 0; |
4320 // Function declarations are function scoped in normal mode, so they are | 4320 // Function declarations are function scoped in normal mode, so they are |
4321 // hoisted. In harmony block scoping mode they are block scoped, so they | 4321 // hoisted. In harmony block scoping mode they are block scoped, so they |
4322 // are not hoisted. | 4322 // are not hoisted. |
4323 Scope* scope = (type == FunctionLiteral::DECLARATION && !is_extended_mode()) | 4323 Scope* scope = (type == FunctionLiteral::DECLARATION && !is_extended_mode()) |
4324 ? NewScope(top_scope_->DeclarationScope(), FUNCTION_SCOPE) | 4324 ? NewScope(top_scope_->DeclarationScope(), FUNCTION_SCOPE) |
4325 : NewScope(top_scope_, FUNCTION_SCOPE); | 4325 : NewScope(top_scope_, FUNCTION_SCOPE); |
4326 ZoneList<Statement*>* body = NULL; | 4326 ZoneList<Statement*>* body = NULL; |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4612 Expect(Token::MOD, CHECK_OK); | 4612 Expect(Token::MOD, CHECK_OK); |
4613 Handle<String> name = ParseIdentifier(CHECK_OK); | 4613 Handle<String> name = ParseIdentifier(CHECK_OK); |
4614 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); | 4614 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); |
4615 | 4615 |
4616 if (extension_ != NULL) { | 4616 if (extension_ != NULL) { |
4617 // The extension structures are only accessible while parsing the | 4617 // The extension structures are only accessible while parsing the |
4618 // very first time not when reparsing because of lazy compilation. | 4618 // very first time not when reparsing because of lazy compilation. |
4619 top_scope_->DeclarationScope()->ForceEagerCompilation(); | 4619 top_scope_->DeclarationScope()->ForceEagerCompilation(); |
4620 } | 4620 } |
4621 | 4621 |
4622 const Runtime::Function* function = Runtime::FunctionForSymbol(name); | 4622 const Runtime::Function* function = Runtime::FunctionForName(name); |
4623 | 4623 |
4624 // Check for built-in IS_VAR macro. | 4624 // Check for built-in IS_VAR macro. |
4625 if (function != NULL && | 4625 if (function != NULL && |
4626 function->intrinsic_type == Runtime::RUNTIME && | 4626 function->intrinsic_type == Runtime::RUNTIME && |
4627 function->function_id == Runtime::kIS_VAR) { | 4627 function->function_id == Runtime::kIS_VAR) { |
4628 // %IS_VAR(x) evaluates to x if x is a variable, | 4628 // %IS_VAR(x) evaluates to x if x is a variable, |
4629 // leads to a parse error otherwise. Could be implemented as an | 4629 // leads to a parse error otherwise. Could be implemented as an |
4630 // inline function %_IS_VAR(x) to eliminate this special case. | 4630 // inline function %_IS_VAR(x) to eliminate this special case. |
4631 if (args->length() == 1 && args->at(0)->AsVariableProxy() != NULL) { | 4631 if (args->length() == 1 && args->at(0)->AsVariableProxy() != NULL) { |
4632 return args->at(0); | 4632 return args->at(0); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4899 // target stack has been used from the top of the target stack. Add | 4899 // target stack has been used from the top of the target stack. Add |
4900 // the break target to any TargetCollectors passed on the stack. | 4900 // the break target to any TargetCollectors passed on the stack. |
4901 for (Target* t = target_stack_; t != stop; t = t->previous()) { | 4901 for (Target* t = target_stack_; t != stop; t = t->previous()) { |
4902 TargetCollector* collector = t->node()->AsTargetCollector(); | 4902 TargetCollector* collector = t->node()->AsTargetCollector(); |
4903 if (collector != NULL) collector->AddTarget(target, zone()); | 4903 if (collector != NULL) collector->AddTarget(target, zone()); |
4904 } | 4904 } |
4905 } | 4905 } |
4906 | 4906 |
4907 | 4907 |
4908 Expression* Parser::NewThrowReferenceError(Handle<String> type) { | 4908 Expression* Parser::NewThrowReferenceError(Handle<String> type) { |
4909 return NewThrowError(isolate()->factory()->MakeReferenceError_symbol(), | 4909 return NewThrowError(isolate()->factory()->MakeReferenceError_string(), |
4910 type, HandleVector<Object>(NULL, 0)); | 4910 type, HandleVector<Object>(NULL, 0)); |
4911 } | 4911 } |
4912 | 4912 |
4913 | 4913 |
4914 Expression* Parser::NewThrowSyntaxError(Handle<String> type, | 4914 Expression* Parser::NewThrowSyntaxError(Handle<String> type, |
4915 Handle<Object> first) { | 4915 Handle<Object> first) { |
4916 int argc = first.is_null() ? 0 : 1; | 4916 int argc = first.is_null() ? 0 : 1; |
4917 Vector< Handle<Object> > arguments = HandleVector<Object>(&first, argc); | 4917 Vector< Handle<Object> > arguments = HandleVector<Object>(&first, argc); |
4918 return NewThrowError( | 4918 return NewThrowError( |
4919 isolate()->factory()->MakeSyntaxError_symbol(), type, arguments); | 4919 isolate()->factory()->MakeSyntaxError_string(), type, arguments); |
4920 } | 4920 } |
4921 | 4921 |
4922 | 4922 |
4923 Expression* Parser::NewThrowTypeError(Handle<String> type, | 4923 Expression* Parser::NewThrowTypeError(Handle<String> type, |
4924 Handle<Object> first, | 4924 Handle<Object> first, |
4925 Handle<Object> second) { | 4925 Handle<Object> second) { |
4926 ASSERT(!first.is_null() && !second.is_null()); | 4926 ASSERT(!first.is_null() && !second.is_null()); |
4927 Handle<Object> elements[] = { first, second }; | 4927 Handle<Object> elements[] = { first, second }; |
4928 Vector< Handle<Object> > arguments = | 4928 Vector< Handle<Object> > arguments = |
4929 HandleVector<Object>(elements, ARRAY_SIZE(elements)); | 4929 HandleVector<Object>(elements, ARRAY_SIZE(elements)); |
4930 return NewThrowError( | 4930 return NewThrowError( |
4931 isolate()->factory()->MakeTypeError_symbol(), type, arguments); | 4931 isolate()->factory()->MakeTypeError_string(), type, arguments); |
4932 } | 4932 } |
4933 | 4933 |
4934 | 4934 |
4935 Expression* Parser::NewThrowError(Handle<String> constructor, | 4935 Expression* Parser::NewThrowError(Handle<String> constructor, |
4936 Handle<String> type, | 4936 Handle<String> type, |
4937 Vector< Handle<Object> > arguments) { | 4937 Vector< Handle<Object> > arguments) { |
4938 int argc = arguments.length(); | 4938 int argc = arguments.length(); |
4939 Handle<FixedArray> elements = isolate()->factory()->NewFixedArray(argc, | 4939 Handle<FixedArray> elements = isolate()->factory()->NewFixedArray(argc, |
4940 TENURED); | 4940 TENURED); |
4941 for (int i = 0; i < argc; i++) { | 4941 for (int i = 0; i < argc; i++) { |
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5932 ASSERT(info->isolate()->has_pending_exception()); | 5932 ASSERT(info->isolate()->has_pending_exception()); |
5933 } else { | 5933 } else { |
5934 result = parser.ParseProgram(); | 5934 result = parser.ParseProgram(); |
5935 } | 5935 } |
5936 } | 5936 } |
5937 info->SetFunction(result); | 5937 info->SetFunction(result); |
5938 return (result != NULL); | 5938 return (result != NULL); |
5939 } | 5939 } |
5940 | 5940 |
5941 } } // namespace v8::internal | 5941 } } // namespace v8::internal |
OLD | NEW |