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 #include "vm/runtime_entry.h" | 5 #include "vm/runtime_entry.h" |
6 | 6 |
7 #include "vm/object.h" | 7 #include "vm/object.h" |
8 #include "vm/symbols.h" | 8 #include "vm/symbols.h" |
9 #include "vm/verifier.h" | 9 #include "vm/verifier.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 | 13 |
14 // Add function to a class and that class to the class dictionary so that | 14 // Add function to a class and that class to the class dictionary so that |
15 // frame walking can be used. | 15 // frame walking can be used. |
16 const Function& RegisterFakeFunction(const char* name, const Code& code) { | 16 const Function& RegisterFakeFunction(const char* name, const Code& code) { |
17 const String& class_name = String::Handle(Symbols::New("ownerClass")); | 17 const String& class_name = String::Handle(Symbols::New("ownerClass")); |
18 const Script& script = Script::Handle(); | 18 const Script& script = Script::Handle(); |
19 const Class& owner_class = | 19 const Class& owner_class = |
20 Class::Handle(Class::New(class_name, script, Scanner::kNoSourcePos)); | 20 Class::Handle(Class::New(class_name, script, Token::kNoSourcePos)); |
21 const String& function_name = String::ZoneHandle(Symbols::New(name)); | 21 const String& function_name = String::ZoneHandle(Symbols::New(name)); |
22 const Function& function = Function::ZoneHandle( | 22 const Function& function = Function::ZoneHandle( |
23 Function::New(function_name, RawFunction::kRegularFunction, | 23 Function::New(function_name, RawFunction::kRegularFunction, |
24 true, false, false, false, false, owner_class, 0)); | 24 true, false, false, false, false, owner_class, 0)); |
25 const Array& functions = Array::Handle(Array::New(1)); | 25 const Array& functions = Array::Handle(Array::New(1)); |
26 functions.SetAt(0, function); | 26 functions.SetAt(0, function); |
27 owner_class.SetFunctions(functions); | 27 owner_class.SetFunctions(functions); |
28 Library& lib = Library::Handle(Library::CoreLibrary()); | 28 Library& lib = Library::Handle(Library::CoreLibrary()); |
29 lib.AddClass(owner_class); | 29 lib.AddClass(owner_class); |
30 function.AttachCode(code); | 30 function.AttachCode(code); |
31 return function; | 31 return function; |
32 } | 32 } |
33 | 33 |
34 } // namespace dart | 34 } // namespace dart |
OLD | NEW |