OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/typing-asm.h" | 5 #include "src/typing-asm.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 159 } |
160 | 160 |
161 | 161 |
162 void AsmTyper::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 162 void AsmTyper::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
163 if (in_function_) { | 163 if (in_function_) { |
164 FAIL(decl, "function declared inside another"); | 164 FAIL(decl, "function declared inside another"); |
165 } | 165 } |
166 // Set function type so global references to functions have some type | 166 // Set function type so global references to functions have some type |
167 // (so they can give a more useful error). | 167 // (so they can give a more useful error). |
168 Variable* var = decl->proxy()->var(); | 168 Variable* var = decl->proxy()->var(); |
| 169 if (GetVariableInfo(var)) { |
| 170 // Detect previously-seen functions. |
| 171 FAIL(decl->fun(), "function repeated in module"); |
| 172 } |
169 SetType(var, Type::Function()); | 173 SetType(var, Type::Function()); |
170 } | 174 } |
171 | 175 |
172 | 176 |
173 void AsmTyper::VisitFunctionAnnotation(FunctionLiteral* fun) { | 177 void AsmTyper::VisitFunctionAnnotation(FunctionLiteral* fun) { |
174 // Extract result type. | 178 // Extract result type. |
175 ZoneList<Statement*>* body = fun->body(); | 179 ZoneList<Statement*>* body = fun->body(); |
176 Type* result_type = Type::Undefined(); | 180 Type* result_type = Type::Undefined(); |
177 if (body->length() > 0) { | 181 if (body->length() > 0) { |
178 ReturnStatement* stmt = body->last()->AsReturnStatement(); | 182 ReturnStatement* stmt = body->last()->AsReturnStatement(); |
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1630 } | 1634 } |
1631 | 1635 |
1632 | 1636 |
1633 void AsmTyper::VisitRewritableExpression(RewritableExpression* expr) { | 1637 void AsmTyper::VisitRewritableExpression(RewritableExpression* expr) { |
1634 RECURSE(Visit(expr->expression())); | 1638 RECURSE(Visit(expr->expression())); |
1635 } | 1639 } |
1636 | 1640 |
1637 | 1641 |
1638 } // namespace internal | 1642 } // namespace internal |
1639 } // namespace v8 | 1643 } // namespace v8 |
OLD | NEW |