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

Side by Side Diff: test/codegen/expect/dart/_js_names.js

Issue 1020043002: Replace dart_core.js with actual compiled SDK (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: merge Created 5 years, 9 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
« no previous file with comments | « test/codegen/expect/dart/_js_helper.js ('k') | test/codegen/expect/dart/_js_primitives.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 var _js_names;
2 (function(exports) {
3 'use strict';
4 // Function preserveNames: () → dynamic
5 function preserveNames() {
6 }
7 dart.defineLazyProperties(exports, {
8 get mangledNames() {
9 return computeMangledNames(_foreign_helper.JS_EMBEDDED_GLOBAL('=Object', _ js_embedded_names.MANGLED_NAMES), false);
10 },
11 get reflectiveNames() {
12 return computeReflectiveNames(exports.mangledNames);
13 },
14 get mangledGlobalNames() {
15 return computeMangledNames(_foreign_helper.JS_EMBEDDED_GLOBAL('=Object', _ js_embedded_names.MANGLED_GLOBAL_NAMES), true);
16 },
17 get reflectiveGlobalNames() {
18 return computeReflectiveNames(exports.mangledGlobalNames);
19 }
20 });
21 // Function computeMangledNames: (dynamic, bool) → Map<String, String>
22 function computeMangledNames(jsMangledNames, isGlobal) {
23 preserveNames();
24 let keys = extractKeys(jsMangledNames);
25 let result = dart.map();
26 let getterPrefix = _foreign_helper.JS_GET_NAME('GETTER_PREFIX');
27 let getterPrefixLength = getterPrefix.length;
28 let setterPrefix = _foreign_helper.JS_GET_NAME('SETTER_PREFIX');
29 for (let key of keys) {
30 let value = jsMangledNames[key];
31 result.set(key, value);
32 if (!dart.notNull(isGlobal)) {
33 if (key.startsWith(getterPrefix)) {
34 result.set(`${setterPrefix}${key.substring(getterPrefixLength)}`, `${v alue}=`);
35 }
36 }
37 }
38 return result;
39 }
40 // Function computeReflectiveNames: (Map<String, String>) → Map
41 function computeReflectiveNames(map) {
42 preserveNames();
43 let result = dart.map();
44 map.forEach((mangledName, reflectiveName) => {
45 result.set(reflectiveName, mangledName);
46 });
47 return result;
48 }
49 // Function extractKeys: (dynamic) → List<dynamic>
50 function extractKeys(victim) {
51 let result = function(victim, hasOwnProperty) {
52 var result = [];
53 for (var key in victim) {
54 if (hasOwnProperty.call(victim, key))
55 result.push(key);
56 }
57 return result;
58 }(victim, Object.prototype.hasOwnProperty);
59 return new _interceptors.JSArray.markFixed(result);
60 }
61 // Function unmangleGlobalNameIfPreservedAnyways: (String) → String
62 function unmangleGlobalNameIfPreservedAnyways(name) {
63 let names = _foreign_helper.JS_EMBEDDED_GLOBAL('=Object', _js_embedded_names .MANGLED_GLOBAL_NAMES);
64 return dart.as(_js_helper.JsCache.fetch(names, name), core.String);
65 }
66 // Function unmangleAllIdentifiersIfPreservedAnyways: (String) → String
67 function unmangleAllIdentifiersIfPreservedAnyways(str) {
68 return str.replace(/[^<,> ]+/g, function(m) {
69 return _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.MANGLED_G LOBAL_NAMES)[m] || m;
70 });
71 }
72 // Exports:
73 exports.preserveNames = preserveNames;
74 exports.computeMangledNames = computeMangledNames;
75 exports.computeReflectiveNames = computeReflectiveNames;
76 exports.extractKeys = extractKeys;
77 exports.unmangleGlobalNameIfPreservedAnyways = unmangleGlobalNameIfPreservedAn yways;
78 exports.unmangleAllIdentifiersIfPreservedAnyways = unmangleAllIdentifiersIfPre servedAnyways;
79 })(_js_names || (_js_names = {}));
OLDNEW
« no previous file with comments | « test/codegen/expect/dart/_js_helper.js ('k') | test/codegen/expect/dart/_js_primitives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698