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

Side by Side Diff: src/parsing/parser.h

Issue 2685293003: [parsing] Fix maybe-assigned for top-level class declarations. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « src/ast/scopes.cc ('k') | src/parsing/parser.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSING_PARSER_H_ 5 #ifndef V8_PARSING_PARSER_H_
6 #define V8_PARSING_PARSER_H_ 6 #define V8_PARSING_PARSER_H_
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/base/compiler-specific.h" 10 #include "src/base/compiler-specific.h"
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 817
818 // Determine if the expression is a variable proxy and mark it as being used 818 // Determine if the expression is a variable proxy and mark it as being used
819 // in an assignment or with a increment/decrement operator. 819 // in an assignment or with a increment/decrement operator.
820 V8_INLINE static void MarkExpressionAsAssigned(Expression* expression) { 820 V8_INLINE static void MarkExpressionAsAssigned(Expression* expression) {
821 DCHECK_NOT_NULL(expression); 821 DCHECK_NOT_NULL(expression);
822 if (expression->IsVariableProxy()) { 822 if (expression->IsVariableProxy()) {
823 expression->AsVariableProxy()->set_is_assigned(); 823 expression->AsVariableProxy()->set_is_assigned();
824 } 824 }
825 } 825 }
826 826
827 // Pessimistically assume that top-level variables will be assigned.
828 //
829 // Top-level variables in a script can be accessed by other scripts or even
830 // become global properties. While this does not apply to top-level variables
831 // in a module (assuming they are not exported), we must still mark these as
832 // assigned because they might be accessed by a lazily parsed top-level
833 // function, which, for efficiency, we preparse without variable tracking.
834 V8_INLINE static void MarkTopLevelVariableAsAssigned(Scope* scope,
835 VariableProxy* proxy) {
836 if (scope->is_script_scope() || scope->is_module_scope()) {
837 proxy->set_is_assigned();
838 }
839 }
840
841 // Returns true if we have a binary expression between two numeric 827 // Returns true if we have a binary expression between two numeric
842 // literals. In that case, *x will be changed to an expression which is the 828 // literals. In that case, *x will be changed to an expression which is the
843 // computed value. 829 // computed value.
844 bool ShortcutNumericLiteralBinaryExpression(Expression** x, Expression* y, 830 bool ShortcutNumericLiteralBinaryExpression(Expression** x, Expression* y,
845 Token::Value op, int pos); 831 Token::Value op, int pos);
846 832
847 // Rewrites the following types of unary expressions: 833 // Rewrites the following types of unary expressions:
848 // not <literal> -> true / false 834 // not <literal> -> true / false
849 // + <numeric literal> -> <numeric literal> 835 // + <numeric literal> -> <numeric literal>
850 // - <numeric literal> -> <numeric literal with value negated> 836 // - <numeric literal> -> <numeric literal with value negated>
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 1177
1192 private: 1178 private:
1193 ParserTarget** variable_; 1179 ParserTarget** variable_;
1194 ParserTarget* previous_; 1180 ParserTarget* previous_;
1195 }; 1181 };
1196 1182
1197 } // namespace internal 1183 } // namespace internal
1198 } // namespace v8 1184 } // namespace v8
1199 1185
1200 #endif // V8_PARSING_PARSER_H_ 1186 #endif // V8_PARSING_PARSER_H_
OLDNEW
« no previous file with comments | « src/ast/scopes.cc ('k') | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698