| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 #include "vm/ast_printer.h" | 6 #include "vm/ast_printer.h" |
| 7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/longjump.h" | 8 #include "vm/longjump.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/parser.h" | 10 #include "vm/parser.h" |
| 11 #include "vm/symbols.h" | 11 #include "vm/symbols.h" |
| 12 #include "vm/unit_test.h" | 12 #include "vm/unit_test.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 | 16 |
| 17 void DumpFunction(const Library& lib, const char* cname, const char* fname) { | 17 void DumpFunction(const Library& lib, const char* cname, const char* fname) { |
| 18 const String& classname = String::Handle(Symbols::New(cname)); | 18 const String& classname = String::Handle(Symbols::New(cname)); |
| 19 Class& cls = Class::Handle(lib.LookupClass(classname)); | 19 Class& cls = Class::Handle(lib.LookupClass(classname)); |
| 20 EXPECT(!cls.IsNull()); | 20 EXPECT(!cls.IsNull()); |
| 21 | 21 |
| 22 String& funcname = String::Handle(String::New(fname)); | 22 String& funcname = String::Handle(String::New(fname)); |
| 23 Function& function = Function::ZoneHandle(cls.LookupStaticFunction(funcname)); | 23 Function& function = Function::ZoneHandle(cls.LookupStaticFunction(funcname)); |
| 24 EXPECT(!function.IsNull()); | 24 EXPECT(!function.IsNull()); |
| 25 | 25 |
| 26 bool retval; | 26 bool retval; |
| 27 Isolate* isolate = Isolate::Current(); | 27 EXPECT(Isolate::Current() != NULL); |
| 28 EXPECT(isolate != NULL); | 28 LongJumpScope jump; |
| 29 LongJump* base = isolate->long_jump_base(); | |
| 30 LongJump jump; | |
| 31 isolate->set_long_jump_base(&jump); | |
| 32 if (setjmp(*jump.Set()) == 0) { | 29 if (setjmp(*jump.Set()) == 0) { |
| 33 ParsedFunction* parsed_function = new ParsedFunction(function); | 30 ParsedFunction* parsed_function = new ParsedFunction(function); |
| 34 Parser::ParseFunction(parsed_function); | 31 Parser::ParseFunction(parsed_function); |
| 35 EXPECT(parsed_function->node_sequence() != NULL); | 32 EXPECT(parsed_function->node_sequence() != NULL); |
| 36 printf("Class %s function %s:\n", cname, fname); | 33 printf("Class %s function %s:\n", cname, fname); |
| 37 AstPrinter::PrintFunctionNodes(*parsed_function); | 34 AstPrinter::PrintFunctionNodes(*parsed_function); |
| 38 retval = true; | 35 retval = true; |
| 39 } else { | 36 } else { |
| 40 retval = false; | 37 retval = false; |
| 41 } | 38 } |
| 42 EXPECT(retval); | 39 EXPECT(retval); |
| 43 isolate->set_long_jump_base(base); | |
| 44 } | 40 } |
| 45 | 41 |
| 46 | 42 |
| 47 void CheckField(const Library& lib, | 43 void CheckField(const Library& lib, |
| 48 const char* class_name, | 44 const char* class_name, |
| 49 const char* field_name, | 45 const char* field_name, |
| 50 bool expect_static, | 46 bool expect_static, |
| 51 bool is_final) { | 47 bool is_final) { |
| 52 const String& classname = String::Handle(Symbols::New(class_name)); | 48 const String& classname = String::Handle(Symbols::New(class_name)); |
| 53 Class& cls = Class::Handle(lib.LookupClass(classname)); | 49 Class& cls = Class::Handle(lib.LookupClass(classname)); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 Parser::ParseCompilationUnit(lib, script); | 156 Parser::ParseCompilationUnit(lib, script); |
| 161 EXPECT(ClassFinalizer::ProcessPendingClasses()); | 157 EXPECT(ClassFinalizer::ProcessPendingClasses()); |
| 162 | 158 |
| 163 DumpFunction(lib, "A", "foo"); | 159 DumpFunction(lib, "A", "foo"); |
| 164 DumpFunction(lib, "A", "bar"); | 160 DumpFunction(lib, "A", "bar"); |
| 165 DumpFunction(lib, "A", "baz"); | 161 DumpFunction(lib, "A", "baz"); |
| 166 DumpFunction(lib, "B", "bam"); | 162 DumpFunction(lib, "B", "bam"); |
| 167 } | 163 } |
| 168 | 164 |
| 169 } // namespace dart | 165 } // namespace dart |
| OLD | NEW |