OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013, 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 part of dart2js.js_emitter; | |
6 | |
7 /// Enables debugging of fast/slow objects using V8-specific primitives. | |
8 const DEBUG_FAST_OBJECTS = false; | |
9 | |
10 /** | |
11 * Call-back for adding property with [name] and [value]. | |
12 */ | |
13 typedef jsAst.Property AddPropertyFunction(jsAst.Name name, | |
14 jsAst.Expression value); | |
15 | |
16 /** | |
17 * [member] is a field (instance, static, or top level). | |
18 * | |
19 * [name] is the field name that the [Namer] has picked for this field's | |
20 * storage, that is, the JavaScript property name. | |
21 * | |
22 * [accessorName] is the name of the accessor. For instance fields this is | |
23 * mostly the same as [name] except when [member] is shadowing a field in its | |
24 * superclass. For other fields, they are rarely the same. | |
25 * | |
26 * [needsGetter] and [needsSetter] represent if a getter or a setter | |
27 * respectively is needed. There are many factors in this, for example, if the | |
28 * accessor can be inlined. | |
29 * | |
30 * [needsCheckedSetter] indicates that a checked getter is needed, and in this | |
31 * case, [needsSetter] is always false. [needsCheckedSetter] is only true when | |
32 * type assertions are enabled (checked mode). | |
33 */ | |
34 typedef void AcceptField(VariableElement member, | |
35 jsAst.Name name, | |
36 jsAst.Name accessorName, | |
37 bool needsGetter, | |
38 bool needsSetter, | |
39 bool needsCheckedSetter); | |
40 | |
41 // Function signatures used in the generation of runtime type information. | |
42 typedef void FunctionTypeSignatureEmitter(Element method, | |
43 FunctionType methodType); | |
44 | |
45 typedef void SubstitutionEmitter(Element element, {bool emitNull}); | |
46 | |
47 const String GENERATED_BY = """ | |
48 // Generated by dart2js, the Dart to JavaScript compiler. | |
49 """; | |
50 | |
51 const String HOOKS_API_USAGE = """ | |
52 // The code supports the following hooks: | |
53 // dartPrint(message): | |
54 // if this function is defined it is called instead of the Dart [print] | |
55 // method. | |
56 // | |
57 // dartMainRunner(main, args): | |
58 // if this function is defined, the Dart [main] method will not be invoked | |
59 // directly. Instead, a closure that will invoke [main], and its arguments | |
60 // [args] is passed to [dartMainRunner]. | |
61 // | |
62 // dartDeferredLibraryLoader(uri, successCallback, errorCallback): | |
63 // if this function is defined, it will be called when a deferered library | |
64 // is loaded. It should load and eval the javascript of `uri`, and call | |
65 // successCallback. If it fails to do so, it should call errorCallback with | |
66 // an error. | |
67 """; | |
68 | |
69 // Compact field specifications. The format of the field specification is | |
70 // <accessorName>:<fieldName><suffix> where the suffix and accessor name | |
71 // prefix are optional. The suffix directs the generation of getter and | |
72 // setter methods. Each of the getter and setter has two bits to determine | |
73 // the calling convention. Setter listed below, getter is similar. | |
74 // | |
75 // 00: no setter | |
76 // 01: function(value) { this.field = value; } | |
77 // 10: function(receiver, value) { receiver.field = value; } | |
78 // 11: function(receiver, value) { this.field = value; } | |
79 // | |
80 // The suffix encodes 4 bits using three ASCII ranges of non-identifier | |
81 // characters. | |
82 const FIELD_CODE_CHARACTERS = r"<=>?@{|}~%&'()*"; | |
83 const NO_FIELD_CODE = 0; | |
84 const FIRST_FIELD_CODE = 1; | |
85 const RANGE1_FIRST = 0x3c; // <=>?@ encodes 1..5 | |
86 const RANGE1_LAST = 0x40; | |
87 const RANGE2_FIRST = 0x7b; // {|}~ encodes 6..9 | |
88 const RANGE2_LAST = 0x7e; | |
89 const RANGE3_FIRST = 0x25; // %&'()*+ encodes 10..16 | |
90 const RANGE3_LAST = 0x2b; | |
OLD | NEW |