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

Side by Side Diff: src/parser.cc

Issue 3150032: Introduce a new intermediate AST node for encapsulating the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 4 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/full-codegen.cc ('k') | src/prettyprinter.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 3068 matching lines...) Expand 10 before | Expand all | Expand 10 after
3079 op = Next(); 3079 op = Next();
3080 Expression* expression = ParseUnaryExpression(CHECK_OK); 3080 Expression* expression = ParseUnaryExpression(CHECK_OK);
3081 // Signal a reference error if the expression is an invalid 3081 // Signal a reference error if the expression is an invalid
3082 // left-hand side expression. We could report this as a syntax 3082 // left-hand side expression. We could report this as a syntax
3083 // error here but for compatibility with JSC we choose to report the 3083 // error here but for compatibility with JSC we choose to report the
3084 // error at runtime. 3084 // error at runtime.
3085 if (expression == NULL || !expression->IsValidLeftHandSide()) { 3085 if (expression == NULL || !expression->IsValidLeftHandSide()) {
3086 Handle<String> type = Factory::invalid_lhs_in_prefix_op_symbol(); 3086 Handle<String> type = Factory::invalid_lhs_in_prefix_op_symbol();
3087 expression = NewThrowReferenceError(type); 3087 expression = NewThrowReferenceError(type);
3088 } 3088 }
3089 return NEW(CountOperation(true /* prefix */, op, expression)); 3089 IncrementOperation* increment = NEW(IncrementOperation(op, expression));
3090 return NEW(CountOperation(true /* prefix */, increment));
3090 3091
3091 } else { 3092 } else {
3092 return ParsePostfixExpression(ok); 3093 return ParsePostfixExpression(ok);
3093 } 3094 }
3094 } 3095 }
3095 3096
3096 3097
3097 Expression* Parser::ParsePostfixExpression(bool* ok) { 3098 Expression* Parser::ParsePostfixExpression(bool* ok) {
3098 // PostfixExpression :: 3099 // PostfixExpression ::
3099 // LeftHandSideExpression ('++' | '--')? 3100 // LeftHandSideExpression ('++' | '--')?
3100 3101
3101 Expression* expression = ParseLeftHandSideExpression(CHECK_OK); 3102 Expression* expression = ParseLeftHandSideExpression(CHECK_OK);
3102 if (!scanner_.has_line_terminator_before_next() && Token::IsCountOp(peek())) { 3103 if (!scanner_.has_line_terminator_before_next() && Token::IsCountOp(peek())) {
3103 // Signal a reference error if the expression is an invalid 3104 // Signal a reference error if the expression is an invalid
3104 // left-hand side expression. We could report this as a syntax 3105 // left-hand side expression. We could report this as a syntax
3105 // error here but for compatibility with JSC we choose to report the 3106 // error here but for compatibility with JSC we choose to report the
3106 // error at runtime. 3107 // error at runtime.
3107 if (expression == NULL || !expression->IsValidLeftHandSide()) { 3108 if (expression == NULL || !expression->IsValidLeftHandSide()) {
3108 Handle<String> type = Factory::invalid_lhs_in_postfix_op_symbol(); 3109 Handle<String> type = Factory::invalid_lhs_in_postfix_op_symbol();
3109 expression = NewThrowReferenceError(type); 3110 expression = NewThrowReferenceError(type);
3110 } 3111 }
3111 Token::Value next = Next(); 3112 Token::Value next = Next();
3112 expression = NEW(CountOperation(false /* postfix */, next, expression)); 3113 IncrementOperation* increment = NEW(IncrementOperation(next, expression));
3114 expression = NEW(CountOperation(false /* postfix */, increment));
3113 } 3115 }
3114 return expression; 3116 return expression;
3115 } 3117 }
3116 3118
3117 3119
3118 Expression* Parser::ParseLeftHandSideExpression(bool* ok) { 3120 Expression* Parser::ParseLeftHandSideExpression(bool* ok) {
3119 // LeftHandSideExpression :: 3121 // LeftHandSideExpression ::
3120 // (NewExpression | MemberExpression) ... 3122 // (NewExpression | MemberExpression) ...
3121 3123
3122 Expression* result; 3124 Expression* result;
(...skipping 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after
5312 parser.ParseLazy(script_source, name, 5314 parser.ParseLazy(script_source, name,
5313 start_position, end_position, is_expression); 5315 start_position, end_position, is_expression);
5314 return result; 5316 return result;
5315 } 5317 }
5316 5318
5317 5319
5318 #undef NEW 5320 #undef NEW
5319 5321
5320 5322
5321 } } // namespace v8::internal 5323 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/full-codegen.cc ('k') | src/prettyprinter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698