Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit d9fadc3

Browse files
author
John Messerly
committed
fixes #157, renaming local library identifiers if needed.
readability regression, but fairly simple fix. looks okay in libraries with few imports, bad if they have a lot. ultimately I think this gets cleaned up as part of emitting modules + handling module lowering in JS codegen, see issue #34. [email protected] Review URL: https://codereview.chromium.org/1122133003
1 parent ca517db commit d9fadc3

40 files changed

+247
-121
lines changed

lib/runtime/dart/_foreign_helper.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
var _foreign_helper;
2-
(function(exports) {
1+
var _foreign_helper = dart.defineLibrary(_foreign_helper, {});
2+
var core = dart.import(core);
3+
(function(exports, core) {
34
'use strict';
45
// Function JS: (String, String, [dynamic, dynamic, dynamic, dynamic, dynamic, dynamic, dynamic, dynamic, dynamic, dynamic, dynamic, dynamic]) → dynamic
56
function JS(typeDescription, codeTemplate, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) {
@@ -152,4 +153,4 @@ var _foreign_helper;
152153
exports.JS_EFFECT = JS_EFFECT;
153154
exports.JS_CONST = JS_CONST;
154155
exports.JS_STRING_CONCAT = JS_STRING_CONCAT;
155-
})(_foreign_helper || (_foreign_helper = {}));
156+
})(_foreign_helper, core);

lib/runtime/dart/_interceptors.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
var _interceptors;
2-
(function(exports) {
1+
var _interceptors = dart.defineLibrary(_interceptors, {});
2+
var core = dart.import(core);
3+
var _js_helper = dart.lazyImport(_js_helper);
4+
var _internal = dart.import(_internal);
5+
var _foreign_helper = dart.import(_foreign_helper);
6+
var _js_embedded_names = dart.import(_js_embedded_names);
7+
(function(exports, core, _js_helper, _internal, _foreign_helper, _js_embedded_names) {
38
'use strict';
49
let JSArray = Array;
510
let JSMutableArray$ = dart.generic(function(E) {
@@ -1086,4 +1091,4 @@ var _interceptors;
10861091
exports.JavaScriptObject = JavaScriptObject;
10871092
exports.PlainJavaScriptObject = PlainJavaScriptObject;
10881093
exports.UnknownJavaScriptObject = UnknownJavaScriptObject;
1089-
})(_interceptors || (_interceptors = {}));
1094+
})(_interceptors, core, _js_helper, _internal, _foreign_helper, _js_embedded_names);

lib/runtime/dart/_internal.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
var _internal;
2-
(function(exports) {
1+
var _internal = dart.defineLibrary(_internal, {});
2+
var core = dart.import(core);
3+
var collection = dart.import(collection);
4+
var math = dart.lazyImport(math);
5+
var _interceptors = dart.lazyImport(_interceptors);
6+
var _js_primitives = dart.lazyImport(_js_primitives);
7+
(function(exports, core, collection, math, _interceptors, _js_primitives) {
38
'use strict';
49
class EfficientLength extends core.Object {}
510
let ListIterable$ = dart.generic(function(E) {
@@ -2040,4 +2045,4 @@ var _internal;
20402045
exports.Sort = Sort;
20412046
exports.Symbol = Symbol;
20422047
exports.POWERS_OF_TEN = POWERS_OF_TEN;
2043-
})(_internal || (_internal = {}));
2048+
})(_internal, core, collection, math, _interceptors, _js_primitives);

lib/runtime/dart/_isolate_helper.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
var _isolate_helper;
2-
(function(exports) {
1+
var _isolate_helper = dart.defineLibrary(_isolate_helper, {});
2+
var core = dart.import(core);
3+
var _native_typed_data = dart.import(_native_typed_data);
4+
var _interceptors = dart.lazyImport(_interceptors);
5+
var _js_helper = dart.lazyImport(_js_helper);
6+
var isolate = dart.import(isolate);
7+
var _foreign_helper = dart.import(_foreign_helper);
8+
var _js_embedded_names = dart.import(_js_embedded_names);
9+
var collection = dart.import(collection);
10+
var async = dart.import(async);
11+
(function(exports, core, _native_typed_data, _interceptors, _js_helper, isolate, _foreign_helper, _js_embedded_names, collection, async) {
312
'use strict';
413
// Function _serializeMessage: (dynamic) → dynamic
514
function _serializeMessage(message) {
@@ -1384,4 +1393,4 @@ var _isolate_helper;
13841393
exports.TimerImpl = TimerImpl;
13851394
exports.hasTimer = hasTimer;
13861395
exports.CapabilityImpl = CapabilityImpl;
1387-
})(_isolate_helper || (_isolate_helper = {}));
1396+
})(_isolate_helper, core, _native_typed_data, _interceptors, _js_helper, isolate, _foreign_helper, _js_embedded_names, collection, async);

lib/runtime/dart/_js_embedded_names.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var _js_embedded_names;
1+
var _js_embedded_names = dart.defineLibrary(_js_embedded_names, {});
22
(function(exports) {
33
'use strict';
44
let DISPATCH_PROPERTY_NAME = "dispatchPropertyName";
@@ -64,4 +64,4 @@ var _js_embedded_names;
6464
exports.TYPEDEF_PREDICATE_PROPERTY_NAME = TYPEDEF_PREDICATE_PROPERTY_NAME;
6565
exports.NATIVE_SUPERCLASS_TAG_NAME = NATIVE_SUPERCLASS_TAG_NAME;
6666
exports.MAP_TYPE_TO_INTERCEPTOR = MAP_TYPE_TO_INTERCEPTOR;
67-
})(_js_embedded_names || (_js_embedded_names = {}));
67+
})(_js_embedded_names);

lib/runtime/dart/_js_helper.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
var _js_helper;
2-
(function(exports) {
1+
var _js_helper = dart.defineLibrary(_js_helper, {});
2+
var core = dart.import(core);
3+
var collection = dart.import(collection);
4+
var _internal = dart.import(_internal);
5+
var _foreign_helper = dart.import(_foreign_helper);
6+
var _js_embedded_names = dart.import(_js_embedded_names);
7+
var _interceptors = dart.lazyImport(_interceptors);
8+
var _js_names = dart.import(_js_names);
9+
var async = dart.import(async);
10+
var _isolate_helper = dart.lazyImport(_isolate_helper);
11+
(function(exports, core, collection, _internal, _foreign_helper, _js_embedded_names, _interceptors, _js_names, async, _isolate_helper) {
312
'use strict';
413
class NoSideEffects extends core.Object {
514
NoSideEffects() {
@@ -4080,4 +4089,4 @@ var _js_helper;
40804089
exports.missingMain = missingMain;
40814090
exports.badMain = badMain;
40824091
exports.mainHasTooManyParameters = mainHasTooManyParameters;
4083-
})(_js_helper || (_js_helper = {}));
4092+
})(_js_helper, core, collection, _internal, _foreign_helper, _js_embedded_names, _interceptors, _js_names, async, _isolate_helper);

lib/runtime/dart/_js_names.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
var _js_names;
2-
(function(exports) {
1+
var _js_names = dart.defineLibrary(_js_names, {});
2+
var _foreign_helper = dart.lazyImport(_foreign_helper);
3+
var _js_embedded_names = dart.import(_js_embedded_names);
4+
var core = dart.import(core);
5+
var _interceptors = dart.import(_interceptors);
6+
var _js_helper = dart.lazyImport(_js_helper);
7+
(function(exports, _foreign_helper, _js_embedded_names, core, _interceptors, _js_helper) {
38
'use strict';
49
// Function preserveNames: () → dynamic
510
function preserveNames() {
@@ -76,4 +81,4 @@ var _js_names;
7681
exports.extractKeys = extractKeys;
7782
exports.unmangleGlobalNameIfPreservedAnyways = unmangleGlobalNameIfPreservedAnyways;
7883
exports.unmangleAllIdentifiersIfPreservedAnyways = unmangleAllIdentifiersIfPreservedAnyways;
79-
})(_js_names || (_js_names = {}));
84+
})(_js_names, _foreign_helper, _js_embedded_names, core, _interceptors, _js_helper);

lib/runtime/dart/_js_primitives.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var _js_primitives;
1+
var _js_primitives = dart.defineLibrary(_js_primitives, {});
22
(function(exports) {
33
'use strict';
44
// Function printString: (String) → void
@@ -22,4 +22,4 @@ var _js_primitives;
2222
}
2323
// Exports:
2424
exports.printString = printString;
25-
})(_js_primitives || (_js_primitives = {}));
25+
})(_js_primitives);

lib/runtime/dart/_native_typed_data.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
var _native_typed_data;
2-
(function(exports) {
1+
var _native_typed_data = dart.defineLibrary(_native_typed_data, {});
2+
var core = dart.import(core);
3+
var typed_data = dart.lazyImport(typed_data);
4+
var collection = dart.import(collection);
5+
var _internal = dart.import(_internal);
6+
var _interceptors = dart.lazyImport(_interceptors);
7+
var _js_helper = dart.lazyImport(_js_helper);
8+
var math = dart.import(math);
9+
(function(exports, core, typed_data, collection, _internal, _interceptors, _js_helper, math) {
310
'use strict';
411
class NativeByteBuffer extends core.Object {
512
NativeByteBuffer() {
@@ -1555,4 +1562,4 @@ var _native_typed_data;
15551562
exports.NativeFloat32x4 = NativeFloat32x4;
15561563
exports.NativeInt32x4 = NativeInt32x4;
15571564
exports.NativeFloat64x2 = NativeFloat64x2;
1558-
})(_native_typed_data || (_native_typed_data = {}));
1565+
})(_native_typed_data, core, typed_data, collection, _internal, _interceptors, _js_helper, math);

lib/runtime/dart/async.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
var async;
2-
(function(exports) {
1+
var async = dart.defineLibrary(async, {});
2+
var core = dart.import(core);
3+
var _internal = dart.import(_internal);
4+
var _js_helper = dart.lazyImport(_js_helper);
5+
var _isolate_helper = dart.lazyImport(_isolate_helper);
6+
var collection = dart.import(collection);
7+
(function(exports, core, _internal, _js_helper, _isolate_helper, collection) {
38
'use strict';
49
// Function _invokeErrorHandler: (Function, Object, StackTrace) → dynamic
510
function _invokeErrorHandler(errorHandler, error, stackTrace) {
@@ -5361,4 +5366,4 @@ var async;
53615366
exports.ZoneDelegate = ZoneDelegate;
53625367
exports.Zone = Zone;
53635368
exports.runZoned = runZoned;
5364-
})(async || (async = {}));
5369+
})(async, core, _internal, _js_helper, _isolate_helper, collection);

lib/runtime/dart/collection.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
var collection;
2-
(function(exports) {
1+
var collection = dart.defineLibrary(collection, {});
2+
var _internal = dart.lazyImport(_internal);
3+
var core = dart.import(core);
4+
var _js_helper = dart.lazyImport(_js_helper);
5+
var math = dart.lazyImport(math);
6+
(function(exports, _internal, core, _js_helper, math) {
37
'use strict';
48
let _source = Symbol('_source');
59
let UnmodifiableListView$ = dart.generic(function(E) {
@@ -5153,4 +5157,4 @@ var collection;
51535157
exports.LinkedHashSetCell = LinkedHashSetCell;
51545158
exports.LinkedHashSetIterator$ = LinkedHashSetIterator$;
51555159
exports.LinkedHashSetIterator = LinkedHashSetIterator;
5156-
})(collection || (collection = {}));
5160+
})(collection, _internal, core, _js_helper, math);

lib/runtime/dart/convert.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
var convert;
2-
(function(exports) {
1+
var convert = dart.defineLibrary(convert, {});
2+
var core = dart.import(core);
3+
var async = dart.lazyImport(async);
4+
var typed_data = dart.lazyImport(typed_data);
5+
var _internal = dart.import(_internal);
6+
var collection = dart.import(collection);
7+
(function(exports, core, async, typed_data, _internal, collection) {
38
'use strict';
49
let ASCII = dart.const(new AsciiCodec());
510
let _ASCII_MASK = 127;
@@ -2429,4 +2434,4 @@ var convert;
24292434
exports.Utf8Codec = Utf8Codec;
24302435
exports.Utf8Encoder = Utf8Encoder;
24312436
exports.Utf8Decoder = Utf8Decoder;
2432-
})(convert || (convert = {}));
2437+
})(convert, core, async, typed_data, _internal, collection);

lib/runtime/dart/core.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
var core;
2-
(function(exports) {
1+
var core = dart.defineLibrary(core, {});
2+
var _js_helper = dart.lazyImport(_js_helper);
3+
var _internal = dart.lazyImport(_internal);
4+
var collection = dart.lazyImport(collection);
5+
var _interceptors = dart.lazyImport(_interceptors);
6+
var convert = dart.lazyImport(convert);
7+
(function(exports, _js_helper, _internal, collection, _interceptors, convert) {
38
'use strict';
49
class Object {
510
constructor() {
@@ -3486,4 +3491,4 @@ var core;
34863491
exports.Type = Type;
34873492
exports.Uri = Uri;
34883493
exports.SupportJsExtensionMethods = SupportJsExtensionMethods;
3489-
})(core || (core = {}));
3494+
})(core, _js_helper, _internal, collection, _interceptors, convert);

lib/runtime/dart/isolate.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
var isolate;
2-
(function(exports) {
1+
var isolate = dart.defineLibrary(isolate, {});
2+
var core = dart.import(core);
3+
var _isolate_helper = dart.lazyImport(_isolate_helper);
4+
var async = dart.import(async);
5+
(function(exports, core, _isolate_helper, async) {
36
'use strict';
47
class Capability extends core.Object {
58
Capability() {
@@ -217,4 +220,4 @@ var isolate;
217220
exports.ReceivePort = ReceivePort;
218221
exports.RawReceivePort = RawReceivePort;
219222
exports.RemoteError = RemoteError;
220-
})(isolate || (isolate = {}));
223+
})(isolate, core, _isolate_helper, async);

lib/runtime/dart/math.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
var math;
2-
(function(exports) {
1+
var math = dart.defineLibrary(math, {});
2+
var core = dart.import(core);
3+
var _js_helper = dart.lazyImport(_js_helper);
4+
(function(exports, core, _js_helper) {
35
'use strict';
46
class _JenkinsSmiHash extends core.Object {
57
static combine(hash, value) {
@@ -460,4 +462,4 @@ var math;
460462
exports.sqrt = sqrt;
461463
exports.exp = exp;
462464
exports.log = log;
463-
})(math || (math = {}));
465+
})(math, core, _js_helper);

lib/runtime/dart/typed_data.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
var typed_data;
2-
(function(exports) {
1+
var typed_data = dart.defineLibrary(typed_data, {});
2+
var core = dart.import(core);
3+
var _native_typed_data = dart.lazyImport(_native_typed_data);
4+
(function(exports, core, _native_typed_data) {
35
'use strict';
46
class ByteBuffer extends core.Object {}
57
class TypedData extends core.Object {}
@@ -882,4 +884,4 @@ var typed_data;
882884
exports.Float32x4 = Float32x4;
883885
exports.Int32x4 = Int32x4;
884886
exports.Float64x2 = Float64x2;
885-
})(typed_data || (typed_data = {}));
887+
})(typed_data, core, _native_typed_data);

lib/runtime/dart_runtime.js

+16
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,22 @@ var dart, _js_helper, _js_primitives;
966966
dart.global = window || global;
967967
dart.JsSymbol = Symbol;
968968

969+
function import_(value) {
970+
if (!value) throw 'missing required module';
971+
return value;
972+
}
973+
dart.import = import_;
974+
975+
function lazyImport(value) {
976+
return defineLibrary(value, {});
977+
}
978+
dart.lazyImport = lazyImport;
979+
980+
function defineLibrary(value, defaultValue) {
981+
return value ? value : defaultValue;
982+
}
983+
dart.defineLibrary = defineLibrary;
984+
969985
// TODO(jmesserly): hack to bootstrap the SDK
970986
_js_helper = _js_helper || {};
971987
_js_helper.checkNum = notNull;

0 commit comments

Comments
 (0)