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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/ast.h" | 7 #include "src/ast.h" |
8 #include "src/ast-expression-visitor.h" | 8 #include "src/ast-expression-visitor.h" |
9 #include "src/parser.h" | 9 #include "src/parser.h" |
10 #include "src/rewriter.h" | 10 #include "src/rewriter.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 FunctionLiteral* root = | 67 FunctionLiteral* root = |
68 info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun(); | 68 info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun(); |
69 AsmTyper typer(isolate, zone, *script, root); | 69 AsmTyper typer(isolate, zone, *script, root); |
70 if (typer.Validate()) { | 70 if (typer.Validate()) { |
71 ExpressionTypeCollector(isolate, zone, root, types).Run(); | 71 ExpressionTypeCollector(isolate, zone, root, types).Run(); |
72 return ""; | 72 return ""; |
73 } else { | 73 } else { |
74 return typer.error_message(); | 74 return typer.error_message(); |
75 } | 75 } |
76 } | 76 } |
77 } | 77 |
| 78 } // namespace |
78 | 79 |
79 | 80 |
80 TEST(ValidateMinimum) { | 81 TEST(ValidateMinimum) { |
81 const char test_function[] = | 82 const char test_function[] = |
82 "function GeometricMean(stdlib, foreign, buffer) {\n" | 83 "function GeometricMean(stdlib, foreign, buffer) {\n" |
83 " \"use asm\";\n" | 84 " \"use asm\";\n" |
84 "\n" | 85 "\n" |
85 " var exp = stdlib.Math.exp;\n" | 86 " var exp = stdlib.Math.exp;\n" |
86 " var log = stdlib.Math.log;\n" | 87 " var log = stdlib.Math.log;\n" |
87 " var values = new stdlib.Float64Array(buffer);\n" | 88 " var values = new stdlib.Float64Array(buffer);\n" |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 // var values = new stdlib.*Array(buffer); | 433 // var values = new stdlib.*Array(buffer); |
433 CHECK_VAR_NEW_SHORTCUT(u8, Bounds(cache.kUint8Array)); | 434 CHECK_VAR_NEW_SHORTCUT(u8, Bounds(cache.kUint8Array)); |
434 CHECK_VAR_NEW_SHORTCUT(i8, Bounds(cache.kInt8Array)); | 435 CHECK_VAR_NEW_SHORTCUT(i8, Bounds(cache.kInt8Array)); |
435 CHECK_VAR_NEW_SHORTCUT(u16, Bounds(cache.kUint16Array)); | 436 CHECK_VAR_NEW_SHORTCUT(u16, Bounds(cache.kUint16Array)); |
436 CHECK_VAR_NEW_SHORTCUT(i16, Bounds(cache.kInt16Array)); | 437 CHECK_VAR_NEW_SHORTCUT(i16, Bounds(cache.kInt16Array)); |
437 CHECK_VAR_NEW_SHORTCUT(u32, Bounds(cache.kUint32Array)); | 438 CHECK_VAR_NEW_SHORTCUT(u32, Bounds(cache.kUint32Array)); |
438 CHECK_VAR_NEW_SHORTCUT(i32, Bounds(cache.kInt32Array)); | 439 CHECK_VAR_NEW_SHORTCUT(i32, Bounds(cache.kInt32Array)); |
439 CHECK_VAR_NEW_SHORTCUT(f32, Bounds(cache.kFloat32Array)); | 440 CHECK_VAR_NEW_SHORTCUT(f32, Bounds(cache.kFloat32Array)); |
440 CHECK_VAR_NEW_SHORTCUT(f64, Bounds(cache.kFloat64Array)); | 441 CHECK_VAR_NEW_SHORTCUT(f64, Bounds(cache.kFloat64Array)); |
441 } | 442 } |
442 } | 443 |
| 444 } // namespace |
443 | 445 |
444 | 446 |
445 #define CHECK_FUNC_TYPES_BEGIN(func) \ | 447 #define CHECK_FUNC_TYPES_BEGIN(func) \ |
446 HARNESS_PREAMBLE() \ | 448 HARNESS_PREAMBLE() \ |
447 func "\n" HARNESS_POSTAMBLE(); \ | 449 func "\n" HARNESS_POSTAMBLE(); \ |
448 \ | 450 \ |
449 v8::V8::Initialize(); \ | 451 v8::V8::Initialize(); \ |
450 HandleAndZoneScope handles; \ | 452 HandleAndZoneScope handles; \ |
451 Zone* zone = handles.main_zone(); \ | 453 Zone* zone = handles.main_zone(); \ |
452 ZoneVector<ExpressionTypeEntry> types(zone); \ | 454 ZoneVector<ExpressionTypeEntry> types(zone); \ |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 "return {foo: foo, bar: 1};" | 908 "return {foo: foo, bar: 1};" |
907 "}\n"; | 909 "}\n"; |
908 | 910 |
909 v8::V8::Initialize(); | 911 v8::V8::Initialize(); |
910 HandleAndZoneScope handles; | 912 HandleAndZoneScope handles; |
911 Zone* zone = handles.main_zone(); | 913 Zone* zone = handles.main_zone(); |
912 ZoneVector<ExpressionTypeEntry> types(zone); | 914 ZoneVector<ExpressionTypeEntry> types(zone); |
913 CHECK_EQ("asm: line 40: non-function in function table\n", | 915 CHECK_EQ("asm: line 40: non-function in function table\n", |
914 Validate(zone, test_function, &types)); | 916 Validate(zone, test_function, &types)); |
915 } | 917 } |
OLD | NEW |