OLD | NEW |
| (Empty) |
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 /// Contains the names of globals that are embedded into the output by the | |
6 /// compiler. | |
7 /// | |
8 /// Variables embedded this way should be access with `JS_EMBEDDED_GLOBAL` from | |
9 /// the `_foreign_helper` library. | |
10 /// | |
11 /// This library is shared between the compiler and the runtime system. | |
12 library dart2js._embedded_names; | |
13 | |
14 const DISPATCH_PROPERTY_NAME = "dispatchPropertyName"; | |
15 const TYPE_INFORMATION = 'typeInformation'; | |
16 const GLOBAL_FUNCTIONS = 'globalFunctions'; | |
17 const STATICS = 'statics'; | |
18 | |
19 /// If [JSInvocationMirror._invokeOn] is being used, this embedded global | |
20 /// contains a JavaScript map with the names of methods that are | |
21 /// intercepted. | |
22 const INTERCEPTED_NAMES = 'interceptedNames'; | |
23 | |
24 /// A JS map from mangled global names to their unmangled names. | |
25 /// | |
26 /// If the program does not use reflection may be empty (but not null or | |
27 /// undefined). | |
28 const MANGLED_GLOBAL_NAMES = 'mangledGlobalNames'; | |
29 | |
30 const MANGLED_NAMES = 'mangledNames'; | |
31 const LIBRARIES = 'libraries'; | |
32 const FINISHED_CLASSES = 'finishedClasses'; | |
33 const ALL_CLASSES = 'allClasses'; | |
34 const INTERCEPTORS_BY_TAG = 'interceptorsByTag'; | |
35 const LEAF_TAGS = 'leafTags'; | |
36 const LAZIES = 'lazies'; | |
37 const GET_ISOLATE_TAG = 'getIsolateTag'; | |
38 const ISOLATE_TAG = 'isolateTag'; | |
39 const CURRENT_SCRIPT = 'currentScript'; | |
40 const DEFERRED_LIBRARY_URIS = 'deferredLibraryUris'; | |
41 const DEFERRED_LIBRARY_HASHES = 'deferredLibraryHashes'; | |
42 const INITIALIZE_LOADED_HUNK = 'initializeLoadedHunk'; | |
43 const IS_HUNK_LOADED = 'isHunkLoaded'; | |
44 const IS_HUNK_INITIALIZED = 'isHunkInitialized'; | |
45 const DEFERRED_INITIALIZED = 'deferredInitialized'; | |
46 const PRECOMPILED = 'precompiled'; | |
47 | |
48 /// The name of the embedded global for metadata. | |
49 /// | |
50 /// Use [JsBuiltin.getMetadata] instead of directly accessing this embedded | |
51 /// global. | |
52 const METADATA = 'metadata'; | |
53 | |
54 /// A list of types used in the program e.g. for reflection or encoding of | |
55 /// function types. | |
56 /// | |
57 /// Use [JsBuiltin.getType] instead of directly accessing this embedded global. | |
58 const TYPES = 'types'; | |
59 | |
60 /// Returns a function that creates a new Isolate (its static state). | |
61 /// | |
62 /// (floitsch): Note that this will probably go away, since one JS heap will | |
63 /// only contain one Dart isolate. | |
64 const CREATE_NEW_ISOLATE = 'createNewIsolate'; | |
65 | |
66 const CLASS_ID_EXTRACTOR = 'classIdExtractor'; | |
67 const CLASS_FIELDS_EXTRACTOR = 'classFieldsExtractor'; | |
68 const INSTANCE_FROM_CLASS_ID = "instanceFromClassId"; | |
69 const INITIALIZE_EMPTY_INSTANCE = "initializeEmptyInstance"; | |
70 const TYPEDEF_TYPE_PROPERTY_NAME = r"$typedefType"; | |
71 const TYPEDEF_PREDICATE_PROPERTY_NAME = r"$$isTypedef"; | |
72 const NATIVE_SUPERCLASS_TAG_NAME = r"$nativeSuperclassTag"; | |
73 | |
74 /// Returns the type given the name of a class. | |
75 /// This function is called by the runtime when computing rti. | |
76 const GET_TYPE_FROM_NAME = 'getTypeFromName'; | |
77 const TYPE_TO_INTERCEPTOR_MAP = "typeToInterceptorMap"; | |
78 | |
79 /// Names that are supported by [JS_GET_NAME]. | |
80 // TODO(herhut): Make entries lower case (as in fields) and find a better name. | |
81 enum JsGetName { | |
82 GETTER_PREFIX, | |
83 SETTER_PREFIX, | |
84 CALL_PREFIX, | |
85 CALL_PREFIX0, | |
86 CALL_PREFIX1, | |
87 CALL_PREFIX2, | |
88 CALL_PREFIX3, | |
89 CALL_CATCH_ALL, | |
90 REFLECTABLE, | |
91 CLASS_DESCRIPTOR_PROPERTY, | |
92 REQUIRED_PARAMETER_PROPERTY, | |
93 DEFAULT_VALUES_PROPERTY, | |
94 CALL_NAME_PROPERTY, | |
95 DEFERRED_ACTION_PROPERTY, | |
96 /// Prefix used for generated type argument substitutions on classes. | |
97 OPERATOR_AS_PREFIX, | |
98 /// Name used for generated function types on classes and methods. | |
99 SIGNATURE_NAME, | |
100 /// Name used to tag typedefs. | |
101 TYPEDEF_TAG, | |
102 /// Name used to tag void return in function type representations in | |
103 /// JavaScript. | |
104 FUNCTION_TYPE_VOID_RETURN_TAG, | |
105 /// Name used to tag return types in function type representations in | |
106 /// JavaScript. | |
107 FUNCTION_TYPE_RETURN_TYPE_TAG, | |
108 /// Name used to tag required parameters in function type representations | |
109 /// in JavaScript. | |
110 FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG, | |
111 /// Name used to tag optional parameters in function type representations | |
112 /// in JavaScript. | |
113 FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG, | |
114 /// Name used to tag named parameters in function type representations in | |
115 /// JavaScript. | |
116 FUNCTION_TYPE_NAMED_PARAMETERS_TAG, | |
117 /// Field name used for determining if an object or its interceptor has | |
118 /// JavaScript indexing behavior. | |
119 IS_INDEXABLE_FIELD_NAME, | |
120 /// String representation of the type of the null class. | |
121 NULL_CLASS_TYPE_NAME, | |
122 /// String representation of the type of the object class. | |
123 OBJECT_CLASS_TYPE_NAME, | |
124 /// String representation of the type of the function class. | |
125 FUNCTION_CLASS_TYPE_NAME, | |
126 } | |
127 | |
128 enum JsBuiltin { | |
129 /// Returns the JavaScript constructor function for Dart's Object class. | |
130 /// This can be used for type tests, as in | |
131 /// | |
132 /// var constructor = JS_BUILTIN('', JsBuiltin.dartObjectContructor); | |
133 /// if (JS('bool', '# instanceof #', obj, constructor)) | |
134 /// ... | |
135 dartObjectConstructor, | |
136 | |
137 /// Returns the JavaScript-constructor name given an [isCheckProperty]. | |
138 /// | |
139 /// This relies on a deterministic encoding of is-check properties (for | |
140 /// example `$isFoo` for a class `Foo`). In minified code the returned | |
141 /// classname is the minified name of the class. | |
142 /// | |
143 /// JS_BUILTIN('returns:String;depends:none;effects:none', | |
144 /// JsBuiltin.isCheckPropertyToJsConstructorName, | |
145 /// isCheckProperty); | |
146 isCheckPropertyToJsConstructorName, | |
147 | |
148 /// Returns true if the given type is a function type. Returns false for | |
149 /// the one `Function` type singleton. (See [isFunctionTypeSingleton]). | |
150 /// | |
151 /// JS_BUILTIN('bool', JsBuiltin.isFunctionType, o) | |
152 isFunctionType, | |
153 | |
154 /// Returns a new function type object. | |
155 /// | |
156 /// JS_BUILTIN('=Object', JsBuiltin.createFunctionType) | |
157 createFunctionTypeRti, | |
158 | |
159 /// Returns the JavaScript-constructor name given an rti encoding. | |
160 /// | |
161 /// JS_BUILTIN('String', JsBuiltin.rawRtiToJsConstructorName, rti) | |
162 rawRtiToJsConstructorName, | |
163 | |
164 /// Returns the raw runtime type of the given object. The given argument | |
165 /// [o] should be the interceptor (for non-Dart objects). | |
166 /// | |
167 /// JS_BUILTIN('', JsBuiltin.rawRuntimeType, o) | |
168 rawRuntimeType, | |
169 | |
170 /// Returns whether the given type is a subtype of other. | |
171 /// | |
172 /// The argument `other` is the name of the potential supertype. It is | |
173 /// computed by `runtimeTypeToString`; | |
174 /// | |
175 /// *The `other` name must be passed in before the `type`.* | |
176 /// | |
177 /// JS_BUILTIN('returns:bool;effects:none;depends:none', | |
178 /// JsBuiltin.isSubtype, other, type); | |
179 isSubtype, | |
180 | |
181 /// Returns true if the given type equals the type given as second | |
182 /// argument. Use the JS_GET_NAME helpers to get the type representation | |
183 /// for various Dart classes. | |
184 /// | |
185 /// JS_BUILTIN('returns:bool;effects:none;depends:none', | |
186 /// JsBuiltin.isFunctionTypeLiteral, type, name); | |
187 isGivenTypeRti, | |
188 | |
189 /// Returns the metadata of the given [index]. | |
190 /// | |
191 /// JS_BUILTIN('returns:var;effects:none;depends:none', | |
192 /// JsBuiltin.getMetadata, index); | |
193 getMetadata, | |
194 | |
195 /// Returns the type of the given [index]. | |
196 /// | |
197 /// JS_BUILTIN('returns:var;effects:none;depends:none', | |
198 /// JsBuiltin.getType, index); | |
199 getType, | |
200 } | |
OLD | NEW |