OLD | NEW |
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 <cstring> | 5 #include <cstring> |
6 #include <functional> | 6 #include <functional> |
7 #include <iostream> | 7 #include <iostream> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/asmjs/asm-typer.h" | 10 #include "src/asmjs/asm-typer.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 info.set_ast_value_factory(&ast_value_factory_); | 57 info.set_ast_value_factory(&ast_value_factory_); |
58 info.set_ast_value_factory_owned(false); | 58 info.set_ast_value_factory_owned(false); |
59 Parser parser(&info); | 59 Parser parser(&info); |
60 | 60 |
61 if (!Compiler::ParseAndAnalyze(&info)) { | 61 if (!Compiler::ParseAndAnalyze(&info)) { |
62 std::cerr << "Failed to parse:\n" << source_ << "\n"; | 62 std::cerr << "Failed to parse:\n" << source_ << "\n"; |
63 CHECK(false); | 63 CHECK(false); |
64 } | 64 } |
65 | 65 |
66 outer_scope_ = info.script_scope(); | 66 outer_scope_ = info.script_scope(); |
67 module_ = | 67 module_ = info.scope() |
68 info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun(); | 68 ->declarations() |
| 69 ->AtForTest(0) |
| 70 ->AsFunctionDeclaration() |
| 71 ->fun(); |
69 typer_.reset(new AsmTyper(isolate_, zone_, *script_, module_)); | 72 typer_.reset(new AsmTyper(isolate_, zone_, *script_, module_)); |
70 | 73 |
71 if (validation_type_ == ValidateStatement || | 74 if (validation_type_ == ValidateStatement || |
72 validation_type_ == ValidateExpression) { | 75 validation_type_ == ValidateExpression) { |
73 fun_scope_.reset(new AsmTyper::FunctionScope(typer_.get())); | 76 fun_scope_.reset(new AsmTyper::FunctionScope(typer_.get())); |
74 | 77 |
75 auto* decls = module_->scope()->declarations(); | 78 for (Declaration* decl : *module_->scope()->declarations()) { |
76 for (int ii = 0; ii < decls->length(); ++ii) { | |
77 Declaration* decl = decls->at(ii); | |
78 if (FunctionDeclaration* fun_decl = decl->AsFunctionDeclaration()) { | 79 if (FunctionDeclaration* fun_decl = decl->AsFunctionDeclaration()) { |
79 fun_decl_ = fun_decl; | 80 fun_decl_ = fun_decl; |
80 break; | 81 break; |
81 } | 82 } |
82 } | 83 } |
83 CHECK_NOT_NULL(fun_decl_); | 84 CHECK_NOT_NULL(fun_decl_); |
84 } | 85 } |
85 } | 86 } |
86 | 87 |
87 struct VariableName { | 88 struct VariableName { |
(...skipping 1931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2019 for (size_t ii = 0; ii < arraysize(kTests); ++ii) { | 2020 for (size_t ii = 0; ii < arraysize(kTests); ++ii) { |
2020 if (!ValidationOf(Module(kTests[ii])) | 2021 if (!ValidationOf(Module(kTests[ii])) |
2021 ->FailsWithMessage("Can't assign to immutable symbol")) { | 2022 ->FailsWithMessage("Can't assign to immutable symbol")) { |
2022 std::cerr << "Test:\n" << kTests[ii]; | 2023 std::cerr << "Test:\n" << kTests[ii]; |
2023 CHECK(false); | 2024 CHECK(false); |
2024 } | 2025 } |
2025 } | 2026 } |
2026 } | 2027 } |
2027 | 2028 |
2028 } // namespace | 2029 } // namespace |
OLD | NEW |