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 "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 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 } | 938 } |
939 | 939 |
940 if (type->AsFunctionTableType() != nullptr) { | 940 if (type->AsFunctionTableType() != nullptr) { |
941 FAIL(fun_export, "Module cannot export function tables."); | 941 FAIL(fun_export, "Module cannot export function tables."); |
942 } | 942 } |
943 | 943 |
944 if (fun_info->type()->AsFunctionType() == nullptr) { | 944 if (fun_info->type()->AsFunctionType() == nullptr) { |
945 FAIL(fun_export, "Module export is not an asm.js function."); | 945 FAIL(fun_export, "Module export is not an asm.js function."); |
946 } | 946 } |
947 | 947 |
| 948 if (!fun_export->var()->is_function()) { |
| 949 FAIL(fun_export, "Module exports must be function declarations."); |
| 950 } |
| 951 |
948 return type; | 952 return type; |
949 } | 953 } |
950 | 954 |
951 AsmType* AsmTyper::ValidateExport(ReturnStatement* exports) { | 955 AsmType* AsmTyper::ValidateExport(ReturnStatement* exports) { |
952 // asm.js modules can export single functions, or multiple functions in an | 956 // asm.js modules can export single functions, or multiple functions in an |
953 // object literal. | 957 // object literal. |
954 if (auto* fun_export = exports->expression()->AsVariableProxy()) { | 958 if (auto* fun_export = exports->expression()->AsVariableProxy()) { |
955 // Exporting single function. | 959 // Exporting single function. |
956 AsmType* export_type; | 960 AsmType* export_type; |
957 RECURSE(export_type = ExportType(fun_export)); | 961 RECURSE(export_type = ExportType(fun_export)); |
(...skipping 1952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2910 return true; | 2914 return true; |
2911 } | 2915 } |
2912 | 2916 |
2913 *error_message = typer.error_message(); | 2917 *error_message = typer.error_message(); |
2914 return false; | 2918 return false; |
2915 } | 2919 } |
2916 | 2920 |
2917 } // namespace wasm | 2921 } // namespace wasm |
2918 } // namespace internal | 2922 } // namespace internal |
2919 } // namespace v8 | 2923 } // namespace v8 |
OLD | NEW |