Flutter Engine
The Flutter Engine
method_recognizer.h
Go to the documentation of this file.
1// Copyright (c) 2014, 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_COMPILER_METHOD_RECOGNIZER_H_
6#define RUNTIME_VM_COMPILER_METHOD_RECOGNIZER_H_
7
8#include "vm/allocation.h"
10#include "vm/growable_array.h"
11#include "vm/token.h"
12
13namespace dart {
14
15// Forward declarations.
16class Function;
17class Library;
18class Object;
19class String;
20class Zone;
21
22// Class that recognizes the name and owner of a function and returns the
23// corresponding enum. See RECOGNIZED_LIST above for list of recognizable
24// functions.
26 public:
27 enum Kind {
29#define DEFINE_ENUM_LIST(class_name, function_name, enum_name, fp) k##enum_name,
31#undef DEFINE_ENUM_LIST
33 };
34
35 static intptr_t NumArgsCheckedForStaticCall(const Function& function);
36
37 // Try to find an annotation of the form
38 // @pragma("vm:exact-result-type", int)
39 // @pragma("vm:exact-result-type", "dart:core#_Smi")
40 // and return the exact cid if found or kDynamicCid otherwise.
41 //
42 // See [result_type_pragma.md].
43 static intptr_t ResultCidFromPragma(const Object& function_or_field);
44
45 static intptr_t MethodKindToReceiverCid(Kind kind);
46 static const char* KindToCString(Kind kind);
47 static const char* KindToFunctionNameCString(Kind kind);
48
49 static bool IsMarkedAsRecognized(const Function& function,
50 const char* kind = nullptr);
51 static void InitializeState();
52
53 private:
54 static void Libraries(GrowableArray<Library*>* libs);
55};
56
57// Recognizes token corresponding to a method name.
59 public:
61};
62
63// Class that recognizes factories and returns corresponding result cid.
65 public:
66 // Return result cid of 'factory' if it is recognized.
67 // Return kDynamicCid if factory is not recognized.
68 static intptr_t ResultCid(const Function& factory);
69
70 // Return result cid of 'function' called with 'argument_count' arguments,
71 // if function is a recognized list factory constructor.
72 // Return kDynamicCid if function is not recognized.
73 static intptr_t GetResultCidOfListFactory(Zone* zone,
74 const Function& function,
75 intptr_t argument_count);
76};
77
78} // namespace dart
79
80#endif // RUNTIME_VM_COMPILER_METHOD_RECOGNIZER_H_
static intptr_t ResultCid(const Function &factory)
static intptr_t GetResultCidOfListFactory(Zone *zone, const Function &function, intptr_t argument_count)
static intptr_t ResultCidFromPragma(const Object &function_or_field)
static bool IsMarkedAsRecognized(const Function &function, const char *kind=nullptr)
static intptr_t MethodKindToReceiverCid(Kind kind)
static intptr_t NumArgsCheckedForStaticCall(const Function &function)
static const char * KindToCString(Kind kind)
static const char * KindToFunctionNameCString(Kind kind)
static Token::Kind RecognizeTokenKind(const String &name)
Dart_NativeFunction function
Definition: fuchsia.cc:51
int argument_count
Definition: fuchsia.cc:52
#define DEFINE_ENUM_LIST(class_name, function_name, enum_name, fp)
Definition: dart_vm.cc:33
const char *const name
#define RECOGNIZED_LIST(V)