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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 i::ParseInfo info(zone, script); | 56 i::ParseInfo info(zone, script); |
57 i::Parser parser(&info); | 57 i::Parser parser(&info); |
58 parser.set_allow_harmony_arrow_functions(true); | 58 parser.set_allow_harmony_arrow_functions(true); |
59 parser.set_allow_harmony_sloppy(true); | 59 parser.set_allow_harmony_sloppy(true); |
60 info.set_global(); | 60 info.set_global(); |
61 info.set_lazy(false); | 61 info.set_lazy(false); |
62 info.set_allow_lazy_parsing(false); | 62 info.set_allow_lazy_parsing(false); |
63 info.set_toplevel(true); | 63 info.set_toplevel(true); |
64 | 64 |
65 i::CompilationInfo compilation_info(&info); | |
66 CHECK(i::Compiler::ParseAndAnalyze(&info)); | 65 CHECK(i::Compiler::ParseAndAnalyze(&info)); |
67 info.set_literal( | |
68 info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun()); | |
69 | 66 |
70 AsmTyper typer( | 67 FunctionLiteral* root = |
71 isolate, zone, *script, | 68 info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun(); |
72 info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun()); | 69 AsmTyper typer(isolate, zone, *script, root); |
73 if (typer.Validate()) { | 70 if (typer.Validate()) { |
74 ExpressionTypeCollector(&compilation_info, types).Run(); | 71 ExpressionTypeCollector(isolate, zone, root, types).Run(); |
75 return ""; | 72 return ""; |
76 } else { | 73 } else { |
77 return typer.error_message(); | 74 return typer.error_message(); |
78 } | 75 } |
79 } | 76 } |
80 } | 77 } |
81 | 78 |
82 | 79 |
83 TEST(ValidateMinimum) { | 80 TEST(ValidateMinimum) { |
84 const char test_function[] = | 81 const char test_function[] = |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 "return {foo: foo, bar: 1};" | 906 "return {foo: foo, bar: 1};" |
910 "}\n"; | 907 "}\n"; |
911 | 908 |
912 v8::V8::Initialize(); | 909 v8::V8::Initialize(); |
913 HandleAndZoneScope handles; | 910 HandleAndZoneScope handles; |
914 Zone* zone = handles.main_zone(); | 911 Zone* zone = handles.main_zone(); |
915 ZoneVector<ExpressionTypeEntry> types(zone); | 912 ZoneVector<ExpressionTypeEntry> types(zone); |
916 CHECK_EQ("asm: line 40: non-function in function table\n", | 913 CHECK_EQ("asm: line 40: non-function in function table\n", |
917 Validate(zone, test_function, &types)); | 914 Validate(zone, test_function, &types)); |
918 } | 915 } |
OLD | NEW |