Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Side by Side Diff: src/parser.cc

Issue 10698167: Incorporate constness into inferred interfaces (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/parser.h ('k') | src/rewriter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 Module* Parser::ParseModuleVariable(bool* ok) { 1401 Module* Parser::ParseModuleVariable(bool* ok) {
1402 // ModulePath: 1402 // ModulePath:
1403 // Identifier 1403 // Identifier
1404 1404
1405 Handle<String> name = ParseIdentifier(CHECK_OK); 1405 Handle<String> name = ParseIdentifier(CHECK_OK);
1406 #ifdef DEBUG 1406 #ifdef DEBUG
1407 if (FLAG_print_interface_details) 1407 if (FLAG_print_interface_details)
1408 PrintF("# Module variable %s ", name->ToAsciiArray()); 1408 PrintF("# Module variable %s ", name->ToAsciiArray());
1409 #endif 1409 #endif
1410 VariableProxy* proxy = top_scope_->NewUnresolved( 1410 VariableProxy* proxy = top_scope_->NewUnresolved(
1411 factory(), name, scanner().location().beg_pos, 1411 factory(), name, Interface::NewModule(zone()),
1412 Interface::NewModule(zone())); 1412 scanner().location().beg_pos);
1413 1413
1414 return factory()->NewModuleVariable(proxy); 1414 return factory()->NewModuleVariable(proxy);
1415 } 1415 }
1416 1416
1417 1417
1418 Module* Parser::ParseModuleUrl(bool* ok) { 1418 Module* Parser::ParseModuleUrl(bool* ok) {
1419 // Module: 1419 // Module:
1420 // String 1420 // String
1421 1421
1422 Expect(Token::STRING, CHECK_OK); 1422 Expect(Token::STRING, CHECK_OK);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 module->interface()->Print(); 1492 module->interface()->Print();
1493 } 1493 }
1494 #endif 1494 #endif
1495 ReportMessage("invalid_module_path", Vector<Handle<String> >(&name, 1)); 1495 ReportMessage("invalid_module_path", Vector<Handle<String> >(&name, 1));
1496 return NULL; 1496 return NULL;
1497 } 1497 }
1498 VariableProxy* proxy = NewUnresolved(names[i], LET, interface); 1498 VariableProxy* proxy = NewUnresolved(names[i], LET, interface);
1499 Declaration* declaration = 1499 Declaration* declaration =
1500 factory()->NewImportDeclaration(proxy, module, top_scope_); 1500 factory()->NewImportDeclaration(proxy, module, top_scope_);
1501 Declare(declaration, true, CHECK_OK); 1501 Declare(declaration, true, CHECK_OK);
1502 // TODO(rossberg): Add initialization statement to block.
1503 } 1502 }
1504 1503
1505 return block; 1504 return block;
1506 } 1505 }
1507 1506
1508 1507
1509 Statement* Parser::ParseExportDeclaration(bool* ok) { 1508 Statement* Parser::ParseExportDeclaration(bool* ok) {
1510 // ExportDeclaration: 1509 // ExportDeclaration:
1511 // 'export' Identifier (',' Identifier)* ';' 1510 // 'export' Identifier (',' Identifier)* ';'
1512 // 'export' VariableDeclaration 1511 // 'export' VariableDeclaration
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 1732
1734 1733
1735 VariableProxy* Parser::NewUnresolved( 1734 VariableProxy* Parser::NewUnresolved(
1736 Handle<String> name, VariableMode mode, Interface* interface) { 1735 Handle<String> name, VariableMode mode, Interface* interface) {
1737 // If we are inside a function, a declaration of a var/const variable is a 1736 // If we are inside a function, a declaration of a var/const variable is a
1738 // truly local variable, and the scope of the variable is always the function 1737 // truly local variable, and the scope of the variable is always the function
1739 // scope. 1738 // scope.
1740 // Let/const variables in harmony mode are always added to the immediately 1739 // Let/const variables in harmony mode are always added to the immediately
1741 // enclosing scope. 1740 // enclosing scope.
1742 return DeclarationScope(mode)->NewUnresolved( 1741 return DeclarationScope(mode)->NewUnresolved(
1743 factory(), name, scanner().location().beg_pos, interface); 1742 factory(), name, interface, scanner().location().beg_pos);
1744 } 1743 }
1745 1744
1746 1745
1747 void Parser::Declare(Declaration* declaration, bool resolve, bool* ok) { 1746 void Parser::Declare(Declaration* declaration, bool resolve, bool* ok) {
1748 VariableProxy* proxy = declaration->proxy(); 1747 VariableProxy* proxy = declaration->proxy();
1749 Handle<String> name = proxy->name(); 1748 Handle<String> name = proxy->name();
1750 VariableMode mode = declaration->mode(); 1749 VariableMode mode = declaration->mode();
1751 Scope* declaration_scope = DeclarationScope(mode); 1750 Scope* declaration_scope = DeclarationScope(mode);
1752 Variable* var = NULL; 1751 Variable* var = NULL;
1753 1752
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 shared->set_construct_stub(*construct_stub); 1946 shared->set_construct_stub(*construct_stub);
1948 1947
1949 // Copy the function data to the shared function info. 1948 // Copy the function data to the shared function info.
1950 shared->set_function_data(fun->shared()->function_data()); 1949 shared->set_function_data(fun->shared()->function_data());
1951 int parameters = fun->shared()->formal_parameter_count(); 1950 int parameters = fun->shared()->formal_parameter_count();
1952 shared->set_formal_parameter_count(parameters); 1951 shared->set_formal_parameter_count(parameters);
1953 1952
1954 // TODO(1240846): It's weird that native function declarations are 1953 // TODO(1240846): It's weird that native function declarations are
1955 // introduced dynamically when we meet their declarations, whereas 1954 // introduced dynamically when we meet their declarations, whereas
1956 // other functions are set up when entering the surrounding scope. 1955 // other functions are set up when entering the surrounding scope.
1957 VariableProxy* proxy = NewUnresolved(name, VAR); 1956 VariableProxy* proxy = NewUnresolved(name, VAR, Interface::NewValue());
1958 Declaration* declaration = 1957 Declaration* declaration =
1959 factory()->NewVariableDeclaration(proxy, VAR, top_scope_); 1958 factory()->NewVariableDeclaration(proxy, VAR, top_scope_);
1960 Declare(declaration, true, CHECK_OK); 1959 Declare(declaration, true, CHECK_OK);
1961 SharedFunctionInfoLiteral* lit = 1960 SharedFunctionInfoLiteral* lit =
1962 factory()->NewSharedFunctionInfoLiteral(shared); 1961 factory()->NewSharedFunctionInfoLiteral(shared);
1963 return factory()->NewExpressionStatement( 1962 return factory()->NewExpressionStatement(
1964 factory()->NewAssignment( 1963 factory()->NewAssignment(
1965 Token::INIT_VAR, proxy, lit, RelocInfo::kNoPosition)); 1964 Token::INIT_VAR, proxy, lit, RelocInfo::kNoPosition));
1966 } 1965 }
1967 1966
1968 1967
1969 Statement* Parser::ParseFunctionDeclaration(ZoneStringList* names, bool* ok) { 1968 Statement* Parser::ParseFunctionDeclaration(ZoneStringList* names, bool* ok) {
1970 // FunctionDeclaration :: 1969 // FunctionDeclaration ::
1971 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' 1970 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}'
1972 Expect(Token::FUNCTION, CHECK_OK); 1971 Expect(Token::FUNCTION, CHECK_OK);
1973 int function_token_position = scanner().location().beg_pos; 1972 int function_token_position = scanner().location().beg_pos;
1974 bool is_strict_reserved = false; 1973 bool is_strict_reserved = false;
1975 Handle<String> name = ParseIdentifierOrStrictReservedWord( 1974 Handle<String> name = ParseIdentifierOrStrictReservedWord(
1976 &is_strict_reserved, CHECK_OK); 1975 &is_strict_reserved, CHECK_OK);
1977 FunctionLiteral* fun = ParseFunctionLiteral(name, 1976 FunctionLiteral* fun = ParseFunctionLiteral(name,
1978 is_strict_reserved, 1977 is_strict_reserved,
1979 function_token_position, 1978 function_token_position,
1980 FunctionLiteral::DECLARATION, 1979 FunctionLiteral::DECLARATION,
1981 CHECK_OK); 1980 CHECK_OK);
1982 // Even if we're not at the top-level of the global or a function 1981 // Even if we're not at the top-level of the global or a function
1983 // scope, we treat is as such and introduce the function with it's 1982 // scope, we treat is as such and introduce the function with it's
1984 // initial value upon entering the corresponding scope. 1983 // initial value upon entering the corresponding scope.
1985 VariableMode mode = is_extended_mode() ? LET : VAR; 1984 VariableMode mode = is_extended_mode() ? LET : VAR;
1986 VariableProxy* proxy = NewUnresolved(name, mode); 1985 VariableProxy* proxy = NewUnresolved(name, mode, Interface::NewValue());
1987 Declaration* declaration = 1986 Declaration* declaration =
1988 factory()->NewFunctionDeclaration(proxy, mode, fun, top_scope_); 1987 factory()->NewFunctionDeclaration(proxy, mode, fun, top_scope_);
1989 Declare(declaration, true, CHECK_OK); 1988 Declare(declaration, true, CHECK_OK);
1990 if (names) names->Add(name, zone()); 1989 if (names) names->Add(name, zone());
1991 return factory()->NewEmptyStatement(); 1990 return factory()->NewEmptyStatement();
1992 } 1991 }
1993 1992
1994 1993
1995 Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) { 1994 Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) {
1996 if (top_scope_->is_extended_mode()) return ParseScopedBlock(labels, ok); 1995 if (top_scope_->is_extended_mode()) return ParseScopedBlock(labels, ok);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
2208 // which the variable or constant is declared. Only function variables have 2207 // which the variable or constant is declared. Only function variables have
2209 // an initial value in the declaration (because they are initialized upon 2208 // an initial value in the declaration (because they are initialized upon
2210 // entering the function). 2209 // entering the function).
2211 // 2210 //
2212 // If we have a const declaration, in an inner scope, the proxy is always 2211 // If we have a const declaration, in an inner scope, the proxy is always
2213 // bound to the declared variable (independent of possibly surrounding with 2212 // bound to the declared variable (independent of possibly surrounding with
2214 // statements). 2213 // statements).
2215 // For let/const declarations in harmony mode, we can also immediately 2214 // For let/const declarations in harmony mode, we can also immediately
2216 // pre-resolve the proxy because it resides in the same scope as the 2215 // pre-resolve the proxy because it resides in the same scope as the
2217 // declaration. 2216 // declaration.
2218 VariableProxy* proxy = NewUnresolved(name, mode); 2217 Interface* interface =
2218 is_const ? Interface::NewConst() : Interface::NewValue();
2219 VariableProxy* proxy = NewUnresolved(name, mode, interface);
2219 Declaration* declaration = 2220 Declaration* declaration =
2220 factory()->NewVariableDeclaration(proxy, mode, top_scope_); 2221 factory()->NewVariableDeclaration(proxy, mode, top_scope_);
2221 Declare(declaration, mode != VAR, CHECK_OK); 2222 Declare(declaration, mode != VAR, CHECK_OK);
2222 nvars++; 2223 nvars++;
2223 if (declaration_scope->num_var_or_const() > kMaxNumFunctionLocals) { 2224 if (declaration_scope->num_var_or_const() > kMaxNumFunctionLocals) {
2224 ReportMessageAt(scanner().location(), "too_many_variables", 2225 ReportMessageAt(scanner().location(), "too_many_variables",
2225 Vector<const char*>::empty()); 2226 Vector<const char*>::empty());
2226 *ok = false; 2227 *ok = false;
2227 return NULL; 2228 return NULL;
2228 } 2229 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2369 } 2370 }
2370 2371
2371 // Add an assignment node to the initialization statement block if we still 2372 // Add an assignment node to the initialization statement block if we still
2372 // have a pending initialization value. 2373 // have a pending initialization value.
2373 if (value != NULL) { 2374 if (value != NULL) {
2374 ASSERT(mode == VAR); 2375 ASSERT(mode == VAR);
2375 // 'var' initializations are simply assignments (with all the consequences 2376 // 'var' initializations are simply assignments (with all the consequences
2376 // if they are inside a 'with' statement - they may change a 'with' object 2377 // if they are inside a 'with' statement - they may change a 'with' object
2377 // property). 2378 // property).
2378 VariableProxy* proxy = 2379 VariableProxy* proxy =
2379 initialization_scope->NewUnresolved(factory(), name); 2380 initialization_scope->NewUnresolved(factory(), name, interface);
2380 Assignment* assignment = 2381 Assignment* assignment =
2381 factory()->NewAssignment(init_op, proxy, value, position); 2382 factory()->NewAssignment(init_op, proxy, value, position);
2382 block->AddStatement(factory()->NewExpressionStatement(assignment), 2383 block->AddStatement(factory()->NewExpressionStatement(assignment),
2383 zone()); 2384 zone());
2384 } 2385 }
2385 2386
2386 if (fni_ != NULL) fni_->Leave(); 2387 if (fni_ != NULL) fni_->Leave();
2387 } while (peek() == Token::COMMA); 2388 } while (peek() == Token::COMMA);
2388 2389
2389 // If there was a single non-const declaration, return it in the output 2390 // If there was a single non-const declaration, return it in the output
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
2877 // Create an in-between scope for let-bound iteration variables. 2878 // Create an in-between scope for let-bound iteration variables.
2878 Scope* saved_scope = top_scope_; 2879 Scope* saved_scope = top_scope_;
2879 Scope* for_scope = NewScope(top_scope_, BLOCK_SCOPE); 2880 Scope* for_scope = NewScope(top_scope_, BLOCK_SCOPE);
2880 top_scope_ = for_scope; 2881 top_scope_ = for_scope;
2881 2882
2882 Expect(Token::FOR, CHECK_OK); 2883 Expect(Token::FOR, CHECK_OK);
2883 Expect(Token::LPAREN, CHECK_OK); 2884 Expect(Token::LPAREN, CHECK_OK);
2884 for_scope->set_start_position(scanner().location().beg_pos); 2885 for_scope->set_start_position(scanner().location().beg_pos);
2885 if (peek() != Token::SEMICOLON) { 2886 if (peek() != Token::SEMICOLON) {
2886 if (peek() == Token::VAR || peek() == Token::CONST) { 2887 if (peek() == Token::VAR || peek() == Token::CONST) {
2888 bool is_const = peek() == Token::CONST;
2887 Handle<String> name; 2889 Handle<String> name;
2888 Block* variable_statement = 2890 Block* variable_statement =
2889 ParseVariableDeclarations(kForStatement, NULL, NULL, &name, CHECK_OK); 2891 ParseVariableDeclarations(kForStatement, NULL, NULL, &name, CHECK_OK);
2890 2892
2891 if (peek() == Token::IN && !name.is_null()) { 2893 if (peek() == Token::IN && !name.is_null()) {
2892 VariableProxy* each = top_scope_->NewUnresolved(factory(), name); 2894 Interface* interface =
2895 is_const ? Interface::NewConst() : Interface::NewValue();
2896 VariableProxy* each =
2897 top_scope_->NewUnresolved(factory(), name, interface);
2893 ForInStatement* loop = factory()->NewForInStatement(labels); 2898 ForInStatement* loop = factory()->NewForInStatement(labels);
2894 Target target(&this->target_stack_, loop); 2899 Target target(&this->target_stack_, loop);
2895 2900
2896 Expect(Token::IN, CHECK_OK); 2901 Expect(Token::IN, CHECK_OK);
2897 Expression* enumerable = ParseExpression(true, CHECK_OK); 2902 Expression* enumerable = ParseExpression(true, CHECK_OK);
2898 Expect(Token::RPAREN, CHECK_OK); 2903 Expect(Token::RPAREN, CHECK_OK);
2899 2904
2900 Statement* body = ParseStatement(NULL, CHECK_OK); 2905 Statement* body = ParseStatement(NULL, CHECK_OK);
2901 loop->Initialize(each, enumerable, body); 2906 loop->Initialize(each, enumerable, body);
2902 Block* result = factory()->NewBlock(NULL, 2, false); 2907 Block* result = factory()->NewBlock(NULL, 2, false);
(...skipping 26 matching lines...) Expand all
2929 // for (x' in e) { 2934 // for (x' in e) {
2930 // let x; 2935 // let x;
2931 // x = x'; 2936 // x = x';
2932 // b; 2937 // b;
2933 // } 2938 // }
2934 2939
2935 // TODO(keuchel): Move the temporary variable to the block scope, after 2940 // TODO(keuchel): Move the temporary variable to the block scope, after
2936 // implementing stack allocated block scoped variables. 2941 // implementing stack allocated block scoped variables.
2937 Variable* temp = top_scope_->DeclarationScope()->NewTemporary(name); 2942 Variable* temp = top_scope_->DeclarationScope()->NewTemporary(name);
2938 VariableProxy* temp_proxy = factory()->NewVariableProxy(temp); 2943 VariableProxy* temp_proxy = factory()->NewVariableProxy(temp);
2939 VariableProxy* each = top_scope_->NewUnresolved(factory(), name); 2944 Interface* interface = Interface::NewValue();
2945 VariableProxy* each =
2946 top_scope_->NewUnresolved(factory(), name, interface);
2940 ForInStatement* loop = factory()->NewForInStatement(labels); 2947 ForInStatement* loop = factory()->NewForInStatement(labels);
2941 Target target(&this->target_stack_, loop); 2948 Target target(&this->target_stack_, loop);
2942 2949
2943 Expect(Token::IN, CHECK_OK); 2950 Expect(Token::IN, CHECK_OK);
2944 Expression* enumerable = ParseExpression(true, CHECK_OK); 2951 Expression* enumerable = ParseExpression(true, CHECK_OK);
2945 Expect(Token::RPAREN, CHECK_OK); 2952 Expect(Token::RPAREN, CHECK_OK);
2946 2953
2947 Statement* body = ParseStatement(NULL, CHECK_OK); 2954 Statement* body = ParseStatement(NULL, CHECK_OK);
2948 Block* body_block = factory()->NewBlock(NULL, 3, false); 2955 Block* body_block = factory()->NewBlock(NULL, 3, false);
2949 Assignment* assignment = factory()->NewAssignment( 2956 Assignment* assignment = factory()->NewAssignment(
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
3664 case Token::FUTURE_STRICT_RESERVED_WORD: { 3671 case Token::FUTURE_STRICT_RESERVED_WORD: {
3665 Handle<String> name = ParseIdentifier(CHECK_OK); 3672 Handle<String> name = ParseIdentifier(CHECK_OK);
3666 if (fni_ != NULL) fni_->PushVariableName(name); 3673 if (fni_ != NULL) fni_->PushVariableName(name);
3667 // The name may refer to a module instance object, so its type is unknown. 3674 // The name may refer to a module instance object, so its type is unknown.
3668 #ifdef DEBUG 3675 #ifdef DEBUG
3669 if (FLAG_print_interface_details) 3676 if (FLAG_print_interface_details)
3670 PrintF("# Variable %s ", name->ToAsciiArray()); 3677 PrintF("# Variable %s ", name->ToAsciiArray());
3671 #endif 3678 #endif
3672 Interface* interface = Interface::NewUnknown(zone()); 3679 Interface* interface = Interface::NewUnknown(zone());
3673 result = top_scope_->NewUnresolved( 3680 result = top_scope_->NewUnresolved(
3674 factory(), name, scanner().location().beg_pos, interface); 3681 factory(), name, interface, scanner().location().beg_pos);
3675 break; 3682 break;
3676 } 3683 }
3677 3684
3678 case Token::NUMBER: { 3685 case Token::NUMBER: {
3679 Consume(Token::NUMBER); 3686 Consume(Token::NUMBER);
3680 ASSERT(scanner().is_literal_ascii()); 3687 ASSERT(scanner().is_literal_ascii());
3681 double value = StringToDouble(isolate()->unicode_cache(), 3688 double value = StringToDouble(isolate()->unicode_cache(),
3682 scanner().literal_ascii_string(), 3689 scanner().literal_ascii_string(),
3683 ALLOW_HEX | ALLOW_OCTALS); 3690 ALLOW_HEX | ALLOW_OCTALS);
3684 result = factory()->NewNumberLiteral(value); 3691 result = factory()->NewNumberLiteral(value);
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
4510 // NOTE: We create a proxy and resolve it here so that in the 4517 // NOTE: We create a proxy and resolve it here so that in the
4511 // future we can change the AST to only refer to VariableProxies 4518 // future we can change the AST to only refer to VariableProxies
4512 // instead of Variables and Proxis as is the case now. 4519 // instead of Variables and Proxis as is the case now.
4513 Variable* fvar = NULL; 4520 Variable* fvar = NULL;
4514 Token::Value fvar_init_op = Token::INIT_CONST; 4521 Token::Value fvar_init_op = Token::INIT_CONST;
4515 if (type == FunctionLiteral::NAMED_EXPRESSION) { 4522 if (type == FunctionLiteral::NAMED_EXPRESSION) {
4516 if (is_extended_mode()) fvar_init_op = Token::INIT_CONST_HARMONY; 4523 if (is_extended_mode()) fvar_init_op = Token::INIT_CONST_HARMONY;
4517 VariableMode fvar_mode = is_extended_mode() ? CONST_HARMONY : CONST; 4524 VariableMode fvar_mode = is_extended_mode() ? CONST_HARMONY : CONST;
4518 fvar = new(zone()) Variable(top_scope_, 4525 fvar = new(zone()) Variable(top_scope_,
4519 function_name, fvar_mode, true /* is valid LHS */, 4526 function_name, fvar_mode, true /* is valid LHS */,
4520 Variable::NORMAL, kCreatedInitialized); 4527 Variable::NORMAL, kCreatedInitialized, Interface::NewConst());
4521 VariableProxy* proxy = factory()->NewVariableProxy(fvar); 4528 VariableProxy* proxy = factory()->NewVariableProxy(fvar);
4522 VariableDeclaration* fvar_declaration = 4529 VariableDeclaration* fvar_declaration =
4523 factory()->NewVariableDeclaration(proxy, fvar_mode, top_scope_); 4530 factory()->NewVariableDeclaration(proxy, fvar_mode, top_scope_);
4524 top_scope_->DeclareFunctionVar(fvar_declaration); 4531 top_scope_->DeclareFunctionVar(fvar_declaration);
4525 } 4532 }
4526 4533
4527 // Determine whether the function will be lazily compiled. 4534 // Determine whether the function will be lazily compiled.
4528 // The heuristics are: 4535 // The heuristics are:
4529 // - It must not have been prohibited by the caller to Parse (some callers 4536 // - It must not have been prohibited by the caller to Parse (some callers
4530 // need a full AST). 4537 // need a full AST).
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
4600 expected_property_count = logger.properties(); 4607 expected_property_count = logger.properties();
4601 top_scope_->SetLanguageMode(logger.language_mode()); 4608 top_scope_->SetLanguageMode(logger.language_mode());
4602 only_simple_this_property_assignments = false; 4609 only_simple_this_property_assignments = false;
4603 this_property_assignments = isolate()->factory()->empty_fixed_array(); 4610 this_property_assignments = isolate()->factory()->empty_fixed_array();
4604 } 4611 }
4605 } 4612 }
4606 4613
4607 if (!is_lazily_compiled) { 4614 if (!is_lazily_compiled) {
4608 body = new(zone()) ZoneList<Statement*>(8, zone()); 4615 body = new(zone()) ZoneList<Statement*>(8, zone());
4609 if (fvar != NULL) { 4616 if (fvar != NULL) {
4610 VariableProxy* fproxy = 4617 VariableProxy* fproxy = top_scope_->NewUnresolved(
4611 top_scope_->NewUnresolved(factory(), function_name); 4618 factory(), function_name, Interface::NewConst());
4612 fproxy->BindTo(fvar); 4619 fproxy->BindTo(fvar);
4613 body->Add(factory()->NewExpressionStatement( 4620 body->Add(factory()->NewExpressionStatement(
4614 factory()->NewAssignment(fvar_init_op, 4621 factory()->NewAssignment(fvar_init_op,
4615 fproxy, 4622 fproxy,
4616 factory()->NewThisFunction(), 4623 factory()->NewThisFunction(),
4617 RelocInfo::kNoPosition)), 4624 RelocInfo::kNoPosition)),
4618 zone()); 4625 zone());
4619 } 4626 }
4620 ParseSourceElements(body, Token::RBRACE, false, CHECK_OK); 4627 ParseSourceElements(body, Token::RBRACE, false, CHECK_OK);
4621 4628
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
6071 ASSERT(info->isolate()->has_pending_exception()); 6078 ASSERT(info->isolate()->has_pending_exception());
6072 } else { 6079 } else {
6073 result = parser.ParseProgram(); 6080 result = parser.ParseProgram();
6074 } 6081 }
6075 } 6082 }
6076 info->SetFunction(result); 6083 info->SetFunction(result);
6077 return (result != NULL); 6084 return (result != NULL);
6078 } 6085 }
6079 6086
6080 } } // namespace v8::internal 6087 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698