Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 // Try to find an annotation of the form
46 // @pragma("vm:non-nullable-result-type")
47 // and returns true iff `false` was specified in the annotation.
48 //
49 // See [pragmas.md].
51 const Object& function_or_field);
52
53 static intptr_t MethodKindToReceiverCid(Kind kind);
54 static const char* KindToCString(Kind kind);
55 static const char* KindToFunctionNameCString(Kind kind);
56
57 static bool IsMarkedAsRecognized(const Function& function,
58 const char* kind = nullptr);
59 static void InitializeState();
60
61 private:
62 static void Libraries(GrowableArray<Library*>* libs);
63};
64
65// Recognizes token corresponding to a method name.
67 public:
69};
70
71// Class that recognizes factories and returns corresponding result cid.
73 public:
74 // Return result cid of 'factory' if it is recognized.
75 // Return kDynamicCid if factory is not recognized.
76 static intptr_t ResultCid(const Function& factory);
77
78 // Return result cid of 'function' called with 'argument_count' arguments,
79 // if function is a recognized list factory constructor.
80 // Return kDynamicCid if function is not recognized.
81 static intptr_t GetResultCidOfListFactory(Zone* zone,
82 const Function& function,
83 intptr_t argument_count);
84};
85
86} // namespace dart
87
88#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 bool HasNonNullableResultTypeFromPragma(const Object &function_or_field)
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)
const char *const name
#define RECOGNIZED_LIST(V)