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
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_RESOLVER_H_
6#define RUNTIME_VM_RESOLVER_H_
7
8#include "vm/allocation.h"
9#include "vm/tagged_pointer.h"
10
11namespace dart {
12
13// Forward declarations.
14class Array;
15class Class;
16class Instance;
17class Library;
18class String;
19class ArgumentsDescriptor;
20
21// Resolver abstracts functionality needed to resolve dart functions at
22// invocations.
23class Resolver : public AllStatic {
24 public:
25 // Resolve specified dart instance function.
26 static FunctionPtr ResolveDynamic(const Instance& receiver,
27 const String& function_name,
28 const ArgumentsDescriptor& args_desc);
29
30 // If 'allow_add' is true we may add a function to the class during lookup.
31 static FunctionPtr ResolveDynamicForReceiverClass(
32 const Class& receiver_class,
33 const String& function_name,
34 const ArgumentsDescriptor& args_desc,
35 bool allow_add = true);
36 static FunctionPtr ResolveDynamicForReceiverClassAllowPrivate(
37 const Class& receiver_class,
38 const String& function_name,
39 const ArgumentsDescriptor& args_desc,
40 bool allow_add);
41
42 // If 'allow_add' is true we may add a function to the class during lookup.
43 static FunctionPtr ResolveDynamicAnyArgs(Zone* zone,
44 const Class& receiver_class,
45 const String& function_name,
46 bool allow_add = true);
47 static FunctionPtr ResolveDynamicAnyArgsAllowPrivate(
48 Zone* zone,
49 const Class& receiver_class,
50 const String& function_name,
51 bool allow_add);
52
53 // Resolve specified dart static function. If library.IsNull, use
54 // either application library or core library if no application library
55 // exists. Passing negative num_arguments means that the function
56 // will be resolved by name only.
57 // Otherwise null is returned if the number or names of arguments are not
58 // valid for the resolved function.
59 static FunctionPtr ResolveStatic(const Library& library,
60 const String& cls_name,
61 const String& function_name,
62 intptr_t type_args_len,
63 intptr_t num_arguments,
64 const Array& argument_names);
65
66 // Resolve specified dart static function with specified arity. Only resolves
67 // public functions.
68 static FunctionPtr ResolveStatic(const Class& cls,
69 const String& function_name,
70 intptr_t type_args_len,
71 intptr_t num_arguments,
72 const Array& argument_names);
73};
74
75} // namespace dart
76
77#endif // RUNTIME_VM_RESOLVER_H_
78