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

Side by Side Diff: src/parser.cc

Issue 3186: Refactor the enum RelocMode changing the naming scheme from lower case to... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 3 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/objects-debug.cc ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 { 804 {
805 // Parse the function literal. 805 // Parse the function literal.
806 Handle<String> no_name = factory()->EmptySymbol(); 806 Handle<String> no_name = factory()->EmptySymbol();
807 Scope* scope = 807 Scope* scope =
808 factory()->NewScope(top_scope_, Scope::GLOBAL_SCOPE, inside_with()); 808 factory()->NewScope(top_scope_, Scope::GLOBAL_SCOPE, inside_with());
809 LexicalScope lexical_scope(this, scope); 809 LexicalScope lexical_scope(this, scope);
810 TemporaryScope temp_scope(this); 810 TemporaryScope temp_scope(this);
811 811
812 FunctionLiteralType type = is_expression ? EXPRESSION : DECLARATION; 812 FunctionLiteralType type = is_expression ? EXPRESSION : DECLARATION;
813 bool ok = true; 813 bool ok = true;
814 result = ParseFunctionLiteral(name, kNoPosition, type, &ok); 814 result = ParseFunctionLiteral(name, RelocInfo::kNoPosition, type, &ok);
815 // Make sure the results agree. 815 // Make sure the results agree.
816 ASSERT(ok == (result != NULL)); 816 ASSERT(ok == (result != NULL));
817 // The only errors should be stack overflows. 817 // The only errors should be stack overflows.
818 ASSERT(ok || scanner_.stack_overflow()); 818 ASSERT(ok || scanner_.stack_overflow());
819 } 819 }
820 820
821 // Make sure the target stack is empty. 821 // Make sure the target stack is empty.
822 ASSERT(target_stack_ == NULL); 822 ASSERT(target_stack_ == NULL);
823 823
824 // If there was a stack overflow we have to get rid of AST and it is 824 // If there was a stack overflow we have to get rid of AST and it is
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 int parameters = fun->shared()->formal_parameter_count(); 1141 int parameters = fun->shared()->formal_parameter_count();
1142 boilerplate->shared()->set_formal_parameter_count(parameters); 1142 boilerplate->shared()->set_formal_parameter_count(parameters);
1143 1143
1144 // TODO(1240846): It's weird that native function declarations are 1144 // TODO(1240846): It's weird that native function declarations are
1145 // introduced dynamically when we meet their declarations, whereas 1145 // introduced dynamically when we meet their declarations, whereas
1146 // other functions are setup when entering the surrounding scope. 1146 // other functions are setup when entering the surrounding scope.
1147 FunctionBoilerplateLiteral* lit = 1147 FunctionBoilerplateLiteral* lit =
1148 NEW(FunctionBoilerplateLiteral(boilerplate)); 1148 NEW(FunctionBoilerplateLiteral(boilerplate));
1149 VariableProxy* var = Declare(name, Variable::VAR, NULL, true, CHECK_OK); 1149 VariableProxy* var = Declare(name, Variable::VAR, NULL, true, CHECK_OK);
1150 return NEW(ExpressionStatement( 1150 return NEW(ExpressionStatement(
1151 new Assignment(Token::INIT_VAR, var, lit, kNoPosition))); 1151 new Assignment(Token::INIT_VAR, var, lit, RelocInfo::kNoPosition)));
1152 } 1152 }
1153 1153
1154 1154
1155 Statement* Parser::ParseFunctionDeclaration(bool* ok) { 1155 Statement* Parser::ParseFunctionDeclaration(bool* ok) {
1156 // Parse a function literal. We may or may not have a function name. 1156 // Parse a function literal. We may or may not have a function name.
1157 // If we have a name we use it as the variable name for the function 1157 // If we have a name we use it as the variable name for the function
1158 // (a function declaration) and not as the function name of a function 1158 // (a function declaration) and not as the function name of a function
1159 // expression. 1159 // expression.
1160 1160
1161 Expect(Token::FUNCTION, CHECK_OK); 1161 Expect(Token::FUNCTION, CHECK_OK);
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after
2682 // literal. 2682 // literal.
2683 bool is_getter = false; 2683 bool is_getter = false;
2684 bool is_setter = false; 2684 bool is_setter = false;
2685 Handle<String> id = 2685 Handle<String> id =
2686 ParseIdentifierOrGetOrSet(&is_getter, &is_setter, CHECK_OK); 2686 ParseIdentifierOrGetOrSet(&is_getter, &is_setter, CHECK_OK);
2687 if (is_getter || is_setter) { 2687 if (is_getter || is_setter) {
2688 // Special handling of getter and setter syntax. 2688 // Special handling of getter and setter syntax.
2689 if (peek() == Token::IDENTIFIER) { 2689 if (peek() == Token::IDENTIFIER) {
2690 Handle<String> name = ParseIdentifier(CHECK_OK); 2690 Handle<String> name = ParseIdentifier(CHECK_OK);
2691 FunctionLiteral* value = 2691 FunctionLiteral* value =
2692 ParseFunctionLiteral(name, kNoPosition, DECLARATION, CHECK_OK); 2692 ParseFunctionLiteral(name, RelocInfo::kNoPosition,
2693 DECLARATION, CHECK_OK);
2693 ObjectLiteral::Property* property = 2694 ObjectLiteral::Property* property =
2694 NEW(ObjectLiteral::Property(is_getter, value)); 2695 NEW(ObjectLiteral::Property(is_getter, value));
2695 if (IsBoilerplateProperty(property)) 2696 if (IsBoilerplateProperty(property))
2696 number_of_boilerplate_properties++; 2697 number_of_boilerplate_properties++;
2697 properties.Add(property); 2698 properties.Add(property);
2698 if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK); 2699 if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK);
2699 continue; // restart the while 2700 continue; // restart the while
2700 } 2701 }
2701 } 2702 }
2702 key = NEW(Literal(id)); 2703 key = NEW(Literal(id));
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 // NOTE: We create a proxy and resolve it here so that in the 2879 // NOTE: We create a proxy and resolve it here so that in the
2879 // future we can change the AST to only refer to VariableProxies 2880 // future we can change the AST to only refer to VariableProxies
2880 // instead of Variables and Proxis as is the case now. 2881 // instead of Variables and Proxis as is the case now.
2881 if (!function_name.is_null() && function_name->length() > 0) { 2882 if (!function_name.is_null() && function_name->length() > 0) {
2882 Variable* fvar = top_scope_->DeclareFunctionVar(function_name); 2883 Variable* fvar = top_scope_->DeclareFunctionVar(function_name);
2883 VariableProxy* fproxy = 2884 VariableProxy* fproxy =
2884 top_scope_->NewUnresolved(function_name, inside_with()); 2885 top_scope_->NewUnresolved(function_name, inside_with());
2885 fproxy->BindTo(fvar); 2886 fproxy->BindTo(fvar);
2886 body.Add(new ExpressionStatement( 2887 body.Add(new ExpressionStatement(
2887 new Assignment(Token::INIT_VAR, fproxy, 2888 new Assignment(Token::INIT_VAR, fproxy,
2888 NEW(ThisFunction()), kNoPosition))); 2889 NEW(ThisFunction()),
2890 RelocInfo::kNoPosition)));
2889 } 2891 }
2890 2892
2891 // Determine if the function will be lazily compiled. The mode can 2893 // Determine if the function will be lazily compiled. The mode can
2892 // only be PARSE_LAZILY if the --lazy flag is true. 2894 // only be PARSE_LAZILY if the --lazy flag is true.
2893 bool is_lazily_compiled = 2895 bool is_lazily_compiled =
2894 mode() == PARSE_LAZILY && top_scope_->HasTrivialOuterContext(); 2896 mode() == PARSE_LAZILY && top_scope_->HasTrivialOuterContext();
2895 2897
2896 int materialized_literal_count; 2898 int materialized_literal_count;
2897 int expected_property_count; 2899 int expected_property_count;
2898 bool contains_array_literal; 2900 bool contains_array_literal;
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
3255 start_position, 3257 start_position,
3256 is_expression); 3258 is_expression);
3257 return result; 3259 return result;
3258 } 3260 }
3259 3261
3260 3262
3261 #undef NEW 3263 #undef NEW
3262 3264
3263 3265
3264 } } // namespace v8::internal 3266 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698