| 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/debugger.h" | 8 #include "vm/debugger.h" |
| 9 #include "vm/longjump.h" | 9 #include "vm/longjump.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| 11 #include "vm/parser.h" | 11 #include "vm/parser.h" |
| 12 #include "vm/symbols.h" | 12 #include "vm/symbols.h" |
| 13 #include "vm/thread.h" | 13 #include "vm/thread.h" |
| 14 #include "vm/unit_test.h" | 14 #include "vm/unit_test.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 DECLARE_FLAG(bool, show_invisible_frames); | 18 DECLARE_FLAG(bool, show_invisible_frames); |
| 19 | 19 |
| 20 | 20 |
| 21 void DumpFunction(const Library& lib, const char* cname, const char* fname) { | 21 static void DumpFunction(const Library& lib, |
| 22 const char* cname, |
| 23 const char* fname) { |
| 22 const String& classname = String::Handle(Symbols::New(cname)); | 24 const String& classname = String::Handle(Symbols::New(cname)); |
| 23 String& funcname = String::Handle(String::New(fname)); | 25 String& funcname = String::Handle(String::New(fname)); |
| 24 | 26 |
| 25 bool retval; | 27 bool retval; |
| 26 EXPECT(Isolate::Current() != NULL); | 28 EXPECT(Isolate::Current() != NULL); |
| 27 LongJumpScope jump; | 29 LongJumpScope jump; |
| 28 if (setjmp(*jump.Set()) == 0) { | 30 if (setjmp(*jump.Set()) == 0) { |
| 29 Class& cls = Class::Handle(lib.LookupClass(classname)); | 31 Class& cls = Class::Handle(lib.LookupClass(classname)); |
| 30 EXPECT(!cls.IsNull()); | 32 EXPECT(!cls.IsNull()); |
| 31 Function& function = | 33 Function& function = |
| 32 Function::ZoneHandle(cls.LookupStaticFunction(funcname)); | 34 Function::ZoneHandle(cls.LookupStaticFunction(funcname)); |
| 33 EXPECT(!function.IsNull()); | 35 EXPECT(!function.IsNull()); |
| 34 ParsedFunction* parsed_function = | 36 ParsedFunction* parsed_function = |
| 35 new ParsedFunction(Thread::Current(), function); | 37 new ParsedFunction(Thread::Current(), function); |
| 36 Parser::ParseFunction(parsed_function); | 38 Parser::ParseFunction(parsed_function); |
| 37 EXPECT(parsed_function->node_sequence() != NULL); | 39 EXPECT(parsed_function->node_sequence() != NULL); |
| 38 printf("Class %s function %s:\n", cname, fname); | 40 printf("Class %s function %s:\n", cname, fname); |
| 39 AstPrinter::PrintFunctionNodes(*parsed_function); | 41 if (FLAG_support_ast_printer) { |
| 42 AstPrinter::PrintFunctionNodes(*parsed_function); |
| 43 } else { |
| 44 OS::Print("AST printer not supported."); |
| 45 } |
| 40 retval = true; | 46 retval = true; |
| 41 } else { | 47 } else { |
| 42 retval = false; | 48 retval = false; |
| 43 } | 49 } |
| 44 EXPECT(retval); | 50 EXPECT(retval); |
| 45 } | 51 } |
| 46 | 52 |
| 47 | 53 |
| 48 void CheckField(const Library& lib, | 54 void CheckField(const Library& lib, |
| 49 const char* class_name, | 55 const char* class_name, |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 " name=:current_context_var\n" | 570 " name=:current_context_var\n" |
| 565 " 1 ContextLevel level=1 scope=2 begin=3 end=79\n" | 571 " 1 ContextLevel level=1 scope=2 begin=3 end=79\n" |
| 566 " 2 ContextVar level=1 begin=9 end=79 name=x\n" | 572 " 2 ContextVar level=1 begin=9 end=79 name=x\n" |
| 567 " 3 StackVar scope=2 begin=11 end=79 name=b\n", | 573 " 3 StackVar scope=2 begin=11 end=79 name=b\n", |
| 568 CaptureVarsAtLine(lib, "a", 10)); | 574 CaptureVarsAtLine(lib, "a", 10)); |
| 569 } | 575 } |
| 570 | 576 |
| 571 #endif // !PRODUCT | 577 #endif // !PRODUCT |
| 572 | 578 |
| 573 } // namespace dart | 579 } // namespace dart |
| OLD | NEW |