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

Side by Side Diff: src/rewriter.cc

Issue 1106383008: Remove unused Module-related AST nodes and associated codegen (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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/prettyprinter.cc ('k') | src/typing.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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/ast.h" 7 #include "src/ast.h"
8 #include "src/parser.h" 8 #include "src/parser.h"
9 #include "src/rewriter.h" 9 #include "src/rewriter.h"
10 #include "src/scopes.h" 10 #include "src/scopes.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // list of assignments corresponding to the initialization expressions. 80 // list of assignments corresponding to the initialization expressions.
81 // While unclear from the spec (ECMA-262, 3rd., 12.2), the value of 81 // While unclear from the spec (ECMA-262, 3rd., 12.2), the value of
82 // a variable declaration with initialization expression is 'undefined' 82 // a variable declaration with initialization expression is 'undefined'
83 // with some JS VMs: For instance, using smjs, print(eval('var x = 7')) 83 // with some JS VMs: For instance, using smjs, print(eval('var x = 7'))
84 // returns 'undefined'. To obtain the same behavior with v8, we need 84 // returns 'undefined'. To obtain the same behavior with v8, we need
85 // to prevent rewriting in that case. 85 // to prevent rewriting in that case.
86 if (!node->is_initializer_block()) Process(node->statements()); 86 if (!node->is_initializer_block()) Process(node->statements());
87 } 87 }
88 88
89 89
90 void Processor::VisitModuleStatement(ModuleStatement* node) {
91 bool set_after_body = is_set_;
92 Visit(node->body());
93 is_set_ = is_set_ && set_after_body;
94 }
95
96
97 void Processor::VisitExpressionStatement(ExpressionStatement* node) { 90 void Processor::VisitExpressionStatement(ExpressionStatement* node) {
98 // Rewrite : <x>; -> .result = <x>; 91 // Rewrite : <x>; -> .result = <x>;
99 if (!is_set_ && !node->expression()->IsThrow()) { 92 if (!is_set_ && !node->expression()->IsThrow()) {
100 node->set_expression(SetResult(node->expression())); 93 node->set_expression(SetResult(node->expression()));
101 if (!in_try_) is_set_ = true; 94 if (!in_try_) is_set_ = true;
102 } 95 }
103 } 96 }
104 97
105 98
106 void Processor::VisitIfStatement(IfStatement* node) { 99 void Processor::VisitIfStatement(IfStatement* node) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 void Processor::VisitWithStatement(WithStatement* node) { 187 void Processor::VisitWithStatement(WithStatement* node) {
195 bool set_after_body = is_set_; 188 bool set_after_body = is_set_;
196 Visit(node->statement()); 189 Visit(node->statement());
197 is_set_ = is_set_ && set_after_body; 190 is_set_ = is_set_ && set_after_body;
198 } 191 }
199 192
200 193
201 // Do nothing: 194 // Do nothing:
202 void Processor::VisitVariableDeclaration(VariableDeclaration* node) {} 195 void Processor::VisitVariableDeclaration(VariableDeclaration* node) {}
203 void Processor::VisitFunctionDeclaration(FunctionDeclaration* node) {} 196 void Processor::VisitFunctionDeclaration(FunctionDeclaration* node) {}
204 void Processor::VisitModuleDeclaration(ModuleDeclaration* node) {}
205 void Processor::VisitImportDeclaration(ImportDeclaration* node) {} 197 void Processor::VisitImportDeclaration(ImportDeclaration* node) {}
206 void Processor::VisitExportDeclaration(ExportDeclaration* node) {} 198 void Processor::VisitExportDeclaration(ExportDeclaration* node) {}
207 void Processor::VisitModuleLiteral(ModuleLiteral* node) {}
208 void Processor::VisitModulePath(ModulePath* node) {}
209 void Processor::VisitModuleUrl(ModuleUrl* node) {}
210 void Processor::VisitEmptyStatement(EmptyStatement* node) {} 199 void Processor::VisitEmptyStatement(EmptyStatement* node) {}
211 void Processor::VisitReturnStatement(ReturnStatement* node) {} 200 void Processor::VisitReturnStatement(ReturnStatement* node) {}
212 void Processor::VisitDebuggerStatement(DebuggerStatement* node) {} 201 void Processor::VisitDebuggerStatement(DebuggerStatement* node) {}
213 202
214 203
215 // Expressions are never visited yet. 204 // Expressions are never visited yet.
216 #define DEF_VISIT(type) \ 205 #define DEF_VISIT(type) \
217 void Processor::Visit##type(type* expr) { UNREACHABLE(); } 206 void Processor::Visit##type(type* expr) { UNREACHABLE(); }
218 EXPRESSION_NODE_LIST(DEF_VISIT) 207 EXPRESSION_NODE_LIST(DEF_VISIT)
219 #undef DEF_VISIT 208 #undef DEF_VISIT
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 processor.factory()->NewReturnStatement(result_proxy, pos); 242 processor.factory()->NewReturnStatement(result_proxy, pos);
254 body->Add(result_statement, info->zone()); 243 body->Add(result_statement, info->zone());
255 } 244 }
256 } 245 }
257 246
258 return true; 247 return true;
259 } 248 }
260 249
261 250
262 } } // namespace v8::internal 251 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/prettyprinter.cc ('k') | src/typing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698