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

Side by Side Diff: src/asmjs/asm-typer.cc

Issue 2457393003: Thread decls-list through Declaration (Closed)
Patch Set: rebase Created 4 years, 1 month 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 | « no previous file | src/asmjs/asm-wasm-builder.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/asmjs/asm-typer.h" 5 #include "src/asmjs/asm-typer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 FAIL(fun, "Multiple export statements."); 640 FAIL(fun, "Multiple export statements.");
641 } 641 }
642 module_return = current_as_return; 642 module_return = current_as_return;
643 source_layout.AddExport(*module_return); 643 source_layout.AddExport(*module_return);
644 continue; 644 continue;
645 } 645 }
646 646
647 FAIL(current, "Invalid top-level statement in asm.js module."); 647 FAIL(current, "Invalid top-level statement in asm.js module.");
648 } 648 }
649 649
650 ZoneList<Declaration*>* decls = scope->declarations(); 650 Declaration::List* decls = scope->declarations();
651 651 for (Declaration* decl : *decls) {
652 for (int ii = 0; ii < decls->length(); ++ii) {
653 Declaration* decl = decls->at(ii);
654
655 if (FunctionDeclaration* fun_decl = decl->AsFunctionDeclaration()) { 652 if (FunctionDeclaration* fun_decl = decl->AsFunctionDeclaration()) {
656 RECURSE(ValidateFunction(fun_decl)); 653 RECURSE(ValidateFunction(fun_decl));
657 source_layout.AddFunction(*fun_decl); 654 source_layout.AddFunction(*fun_decl);
658 continue; 655 continue;
659 } 656 }
660 } 657 }
661 658
662 for (auto* function_table : function_pointer_tables) { 659 for (auto* function_table : function_pointer_tables) {
663 RECURSE(ValidateFunctionTable(function_table)); 660 RECURSE(ValidateFunctionTable(function_table));
664 source_layout.AddTable(*function_table); 661 source_layout.AddTable(*function_table);
665 } 662 }
666 663
667 for (int ii = 0; ii < decls->length(); ++ii) { 664 for (Declaration* decl : *decls) {
668 Declaration* decl = decls->at(ii);
669
670 if (decl->IsFunctionDeclaration()) { 665 if (decl->IsFunctionDeclaration()) {
671 continue; 666 continue;
672 } 667 }
673 668
674 VariableDeclaration* var_decl = decl->AsVariableDeclaration(); 669 VariableDeclaration* var_decl = decl->AsVariableDeclaration();
675 if (var_decl == nullptr) { 670 if (var_decl == nullptr) {
676 FAIL(decl, "Invalid asm.js declaration."); 671 FAIL(decl, "Invalid asm.js declaration.");
677 } 672 }
678 673
679 auto* var_proxy = var_decl->proxy(); 674 auto* var_proxy = var_decl->proxy();
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 // We don't check whether AsReturnStatement() below returns non-null -- 1149 // We don't check whether AsReturnStatement() below returns non-null --
1155 // we leave that to the ReturnTypeAnnotations method. 1150 // we leave that to the ReturnTypeAnnotations method.
1156 RECURSE(return_type_ = 1151 RECURSE(return_type_ =
1157 ReturnTypeAnnotations(last_statement->AsReturnStatement())); 1152 ReturnTypeAnnotations(last_statement->AsReturnStatement()));
1158 } 1153 }
1159 } 1154 }
1160 } while (return_type_ == AsmType::None()); 1155 } while (return_type_ == AsmType::None());
1161 1156
1162 DCHECK(return_type_->IsReturnType()); 1157 DCHECK(return_type_->IsReturnType());
1163 1158
1164 for (auto* decl : *fun->scope()->declarations()) { 1159 for (Declaration* decl : *fun->scope()->declarations()) {
1165 auto* var_decl = decl->AsVariableDeclaration(); 1160 auto* var_decl = decl->AsVariableDeclaration();
1166 if (var_decl == nullptr) { 1161 if (var_decl == nullptr) {
1167 FAIL(decl, "Functions may only define inner variables."); 1162 FAIL(decl, "Functions may only define inner variables.");
1168 } 1163 }
1169 1164
1170 auto* var_proxy = var_decl->proxy(); 1165 auto* var_proxy = var_decl->proxy();
1171 if (var_proxy == nullptr) { 1166 if (var_proxy == nullptr) {
1172 FAIL(decl, "Invalid local declaration declaration."); 1167 FAIL(decl, "Invalid local declaration declaration.");
1173 } 1168 }
1174 1169
(...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after
2858 return true; 2853 return true;
2859 } 2854 }
2860 2855
2861 *error_message = typer.error_message(); 2856 *error_message = typer.error_message();
2862 return false; 2857 return false;
2863 } 2858 }
2864 2859
2865 } // namespace wasm 2860 } // namespace wasm
2866 } // namespace internal 2861 } // namespace internal
2867 } // namespace v8 2862 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/asmjs/asm-wasm-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698