Flutter Engine
The Flutter Engine
stub_code_test.cc
Go to the documentation of this file.
1// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
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.
4
5#include "vm/globals.h"
6#include "vm/object.h"
7#include "vm/symbols.h"
8
9namespace dart {
10
11// Add function to a class and that class to the class dictionary so that
12// frame walking can be used.
13const Function& RegisterFakeFunction(const char* name, const Code& code) {
14 Thread* thread = Thread::Current();
15 const String& class_name = String::Handle(Symbols::New(thread, "ownerClass"));
16 const Script& script = Script::Handle();
18 const Class& owner_class = Class::Handle(
19 Class::New(lib, class_name, script, TokenPosition::kNoSource));
23 signature, function_name, UntaggedFunction::kRegularFunction, true, false,
24 false, false, false, owner_class, TokenPosition::kNoSource));
25 const Array& functions = Array::Handle(Array::New(1));
26 functions.SetAt(0, function);
27 {
28 SafepointWriteRwLocker ml(thread, thread->isolate_group()->program_lock());
29 owner_class.SetFunctions(functions);
30 }
31 lib.AddClass(owner_class);
32 function.AttachCode(code);
33 return function;
34}
35
36} // namespace dart
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition: object.h:10959
void SetAt(intptr_t index, const Object &value) const
Definition: object.h:10880
static ClassPtr New(IsolateGroup *isolate_group, bool register_class=true)
Definition: object.cc:3053
void SetFunctions(const Array &value) const
Definition: object.cc:3264
static FunctionTypePtr New(intptr_t num_parent_type_arguments=0, Nullability nullability=Nullability::kNonNullable, Heap::Space space=Heap::kOld)
Definition: object.cc:11631
static FunctionPtr New(const FunctionType &signature, const String &name, UntaggedFunction::Kind kind, bool is_static, bool is_const, bool is_abstract, bool is_external, bool is_native, const Object &owner, TokenPosition token_pos, Heap::Space space=Heap::kOld)
Definition: object.cc:10243
SafepointRwLock * program_lock()
Definition: isolate.h:537
static LibraryPtr CoreLibrary()
Definition: object.cc:14787
void AddClass(const Class &cls) const
Definition: object.cc:13914
static Object & Handle()
Definition: object.h:407
static Object & ZoneHandle()
Definition: object.h:419
static StringPtr New(Thread *thread, const char *cstr)
Definition: symbols.h:723
static Thread * Current()
Definition: thread.h:362
IsolateGroup * isolate_group() const
Definition: thread.h:541
Dart_NativeFunction function
Definition: fuchsia.cc:51
Definition: dart_vm.cc:33
const char *const name
const char *const class_name
const Function & RegisterFakeFunction(const char *name, const Code &code)
const char *const function_name