Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(678)

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/foreign_helper.dart

Issue 954253002: dart2js: add compiler builtins to the core-runtime. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move more foreigns to builtins. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library _foreign_helper; 5 library _foreign_helper;
6 6
7 import 'dart:_js_embedded_names' show JsGetName; 7 import 'dart:_js_embedded_names' show JsGetName, JsBuiltin;
8 8
9 /** 9 /**
10 * Emits a JavaScript code fragment parameterized by arguments. 10 * Emits a JavaScript code fragment parameterized by arguments.
11 * 11 *
12 * Hash characters `#` in the [codeTemplate] are replaced in left-to-right order 12 * Hash characters `#` in the [codeTemplate] are replaced in left-to-right order
13 * with expressions that contain the values of, or evaluate to, the arguments. 13 * with expressions that contain the values of, or evaluate to, the arguments.
14 * The number of hash marks must match the number or arguments. Although 14 * The number of hash marks must match the number or arguments. Although
15 * declared with arguments [arg0] through [arg2], the form actually has no limit 15 * declared with arguments [arg0] through [arg2], the form actually has no limit
16 * on the number of arguments. 16 * on the number of arguments.
17 * 17 *
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 * https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi. 183 * https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi.
184 */ 184 */
185 RAW_DART_FUNCTION_REF(Function function) {} 185 RAW_DART_FUNCTION_REF(Function function) {}
186 186
187 /** 187 /**
188 * Sets the current isolate to [isolate]. 188 * Sets the current isolate to [isolate].
189 */ 189 */
190 void JS_SET_CURRENT_ISOLATE(isolate) {} 190 void JS_SET_CURRENT_ISOLATE(isolate) {}
191 191
192 /** 192 /**
193 * Returns the JavaScript constructor function for Dart's Object class.
194 * This can be used for type tests, as in
195 *
196 * if (JS('bool', '# instanceof #', obj, JS_DART_OBJECT_CONSTRUCTOR()))
197 * ...
198 */
199 JS_DART_OBJECT_CONSTRUCTOR() {}
200
201 /**
202 * Returns the interceptor for class [type]. The interceptor is the type's 193 * Returns the interceptor for class [type]. The interceptor is the type's
203 * constructor's `prototype` property. [type] will typically be the class, not 194 * constructor's `prototype` property. [type] will typically be the class, not
204 * an interface, e.g. `JS_INTERCEPTOR_CONSTANT(JSInt)`, not 195 * an interface, e.g. `JS_INTERCEPTOR_CONSTANT(JSInt)`, not
205 * `JS_INTERCEPTOR_CONSTANT(int)`. 196 * `JS_INTERCEPTOR_CONSTANT(int)`.
206 */ 197 */
207 JS_INTERCEPTOR_CONSTANT(Type type) {} 198 JS_INTERCEPTOR_CONSTANT(Type type) {}
208 199
209 /** 200 /**
210 * Returns the prefix used for generated is checks on classes. 201 * Returns the prefix used for generated is checks on classes.
211 */ 202 */
212 String JS_OPERATOR_IS_PREFIX() {} 203 String JS_OPERATOR_IS_PREFIX() {}
213 204
214 /** 205 /**
215 * Returns the prefix used for generated type argument substitutions on classes. 206 * Returns the prefix used for generated type argument substitutions on classes.
216 */ 207 */
217 String JS_OPERATOR_AS_PREFIX() {} 208 String JS_OPERATOR_AS_PREFIX() {}
218 209
219 /// Returns the name of the class `Object` in the generated code. 210 /// Returns the name of the class `Object` in the generated code.
220 String JS_OBJECT_CLASS_NAME() {} 211 String JS_OBJECT_CLASS_NAME() {}
221 212
222 /// Returns the name of the class `Null` in the generated code. 213 /// Returns the name of the class `Null` in the generated code.
223 String JS_NULL_CLASS_NAME() {} 214 String JS_NULL_CLASS_NAME() {}
224 215
225 /// Returns the name of the class `Function` in the generated code.
226 String JS_FUNCTION_CLASS_NAME() {}
227
228 /** 216 /**
229 * Returns the field name used for determining if an object or its 217 * Returns the field name used for determining if an object or its
230 * interceptor has JavaScript indexing behavior. 218 * interceptor has JavaScript indexing behavior.
231 */ 219 */
232 String JS_IS_INDEXABLE_FIELD_NAME() {} 220 String JS_IS_INDEXABLE_FIELD_NAME() {}
233 221
234 /** 222 /**
235 * Returns the object corresponding to Namer.CURRENT_ISOLATE. 223 * Returns the object corresponding to Namer.CURRENT_ISOLATE.
236 */ 224 */
237 JS_CURRENT_ISOLATE() {} 225 JS_CURRENT_ISOLATE() {}
238 226
239 /// Returns the name used for generated function types on classes and methods. 227 /// Returns the name used for generated function types on classes and methods.
240 String JS_SIGNATURE_NAME() {} 228 String JS_SIGNATURE_NAME() {}
241 229
242 /// Returns the name used to tag typedefs. 230 /// Returns the name used to tag typedefs.
243 String JS_TYPEDEF_TAG() {} 231 String JS_TYPEDEF_TAG() {}
244 232
245 /// Returns the name used to tag function type representations in JavaScript.
246 String JS_FUNCTION_TYPE_TAG() {}
247
248 /** 233 /**
249 * Returns the name used to tag void return in function type representations 234 * Returns the name used to tag void return in function type representations
250 * in JavaScript. 235 * in JavaScript.
251 */ 236 */
252 String JS_FUNCTION_TYPE_VOID_RETURN_TAG() {} 237 String JS_FUNCTION_TYPE_VOID_RETURN_TAG() {}
253 238
254 /** 239 /**
255 * Returns the name used to tag return types in function type representations 240 * Returns the name used to tag return types in function type representations
256 * in JavaScript. 241 * in JavaScript.
257 */ 242 */
(...skipping 18 matching lines...) Expand all
276 String JS_FUNCTION_TYPE_NAMED_PARAMETERS_TAG() {} 261 String JS_FUNCTION_TYPE_NAMED_PARAMETERS_TAG() {}
277 262
278 /// Returns the JS name for [name] from the Namer. 263 /// Returns the JS name for [name] from the Namer.
279 String JS_GET_NAME(JsGetName name) {} 264 String JS_GET_NAME(JsGetName name) {}
280 265
281 /// Reads an embedded global. 266 /// Reads an embedded global.
282 /// 267 ///
283 /// The [name] should be a constant defined in the `_embedded_names` library. 268 /// The [name] should be a constant defined in the `_embedded_names` library.
284 JS_EMBEDDED_GLOBAL(String typeDescription, String name) {} 269 JS_EMBEDDED_GLOBAL(String typeDescription, String name) {}
285 270
271 /// Instructs the compiler to execute the [builtinName] action at the call-site.
272 ///
273 /// The [builtin] should be a constant defined in the `_embedded_names`
274 /// library.
275 // Add additional optional arguments if needed. The method is treated internally
276 // as a variable argument method.
277 JS_BUILTIN(String typeDescription, JsBuiltin builtin,
278 [arg0, arg1, arg2, arg3, arg4, arg5, arg6,
279 arg7, arg8, arg9, arg10, arg11]) {}
280
286 /// Returns the state of a flag that is determined by the state of the compiler 281 /// Returns the state of a flag that is determined by the state of the compiler
287 /// when the program has been analyzed. 282 /// when the program has been analyzed.
288 bool JS_GET_FLAG(String name) {} 283 bool JS_GET_FLAG(String name) {}
289 284
290 /** 285 /**
291 * Pretend [code] is executed. Generates no executable code. This is used to 286 * Pretend [code] is executed. Generates no executable code. This is used to
292 * model effects at some other point in external code. For example, the 287 * model effects at some other point in external code. For example, the
293 * following models an assignment to foo with an unknown value. 288 * following models an assignment to foo with an unknown value.
294 * 289 *
295 * var foo; 290 * var foo;
(...skipping 22 matching lines...) Expand all
318 } 313 }
319 314
320 /** 315 /**
321 * JavaScript string concatenation. Inputs must be Strings. Corresponds to the 316 * JavaScript string concatenation. Inputs must be Strings. Corresponds to the
322 * HStringConcat SSA instruction and may be constant-folded. 317 * HStringConcat SSA instruction and may be constant-folded.
323 */ 318 */
324 String JS_STRING_CONCAT(String a, String b) { 319 String JS_STRING_CONCAT(String a, String b) {
325 // This body is unused, only here for type analysis. 320 // This body is unused, only here for type analysis.
326 return JS('String', '# + #', a, b); 321 return JS('String', '# + #', a, b);
327 } 322 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698