Skip to content

Commit

Permalink
fixes #157, renaming local library identifiers if needed.
Browse files Browse the repository at this point in the history
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.

R=vsm@google.com

Review URL: https://codereview.chromium.org/1122133003
  • Loading branch information
John Messerly committed May 6, 2015
1 parent bf567bb commit da20815
Show file tree
Hide file tree
Showing 40 changed files with 247 additions and 121 deletions.
7 changes: 4 additions & 3 deletions pkg/dev_compiler/lib/runtime/dart/_foreign_helper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var _foreign_helper;
(function(exports) {
var _foreign_helper = dart.defineLibrary(_foreign_helper, {});
var core = dart.import(core);
(function(exports, core) {
'use strict';
// Function JS: (String, String, [dynamic, dynamic, dynamic, dynamic, dynamic, dynamic, dynamic, dynamic, dynamic, dynamic, dynamic, dynamic]) → dynamic
function JS(typeDescription, codeTemplate, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) {
Expand Down Expand Up @@ -152,4 +153,4 @@ var _foreign_helper;
exports.JS_EFFECT = JS_EFFECT;
exports.JS_CONST = JS_CONST;
exports.JS_STRING_CONCAT = JS_STRING_CONCAT;
})(_foreign_helper || (_foreign_helper = {}));
})(_foreign_helper, core);
11 changes: 8 additions & 3 deletions pkg/dev_compiler/lib/runtime/dart/_interceptors.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
var _interceptors;
(function(exports) {
var _interceptors = dart.defineLibrary(_interceptors, {});
var core = dart.import(core);
var _js_helper = dart.lazyImport(_js_helper);
var _internal = dart.import(_internal);
var _foreign_helper = dart.import(_foreign_helper);
var _js_embedded_names = dart.import(_js_embedded_names);
(function(exports, core, _js_helper, _internal, _foreign_helper, _js_embedded_names) {
'use strict';
let JSArray = Array;
let JSMutableArray$ = dart.generic(function(E) {
Expand Down Expand Up @@ -1086,4 +1091,4 @@ var _interceptors;
exports.JavaScriptObject = JavaScriptObject;
exports.PlainJavaScriptObject = PlainJavaScriptObject;
exports.UnknownJavaScriptObject = UnknownJavaScriptObject;
})(_interceptors || (_interceptors = {}));
})(_interceptors, core, _js_helper, _internal, _foreign_helper, _js_embedded_names);
11 changes: 8 additions & 3 deletions pkg/dev_compiler/lib/runtime/dart/_internal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
var _internal;
(function(exports) {
var _internal = dart.defineLibrary(_internal, {});
var core = dart.import(core);
var collection = dart.import(collection);
var math = dart.lazyImport(math);
var _interceptors = dart.lazyImport(_interceptors);
var _js_primitives = dart.lazyImport(_js_primitives);
(function(exports, core, collection, math, _interceptors, _js_primitives) {
'use strict';
class EfficientLength extends core.Object {}
let ListIterable$ = dart.generic(function(E) {
Expand Down Expand Up @@ -2040,4 +2045,4 @@ var _internal;
exports.Sort = Sort;
exports.Symbol = Symbol;
exports.POWERS_OF_TEN = POWERS_OF_TEN;
})(_internal || (_internal = {}));
})(_internal, core, collection, math, _interceptors, _js_primitives);
15 changes: 12 additions & 3 deletions pkg/dev_compiler/lib/runtime/dart/_isolate_helper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
var _isolate_helper;
(function(exports) {
var _isolate_helper = dart.defineLibrary(_isolate_helper, {});
var core = dart.import(core);
var _native_typed_data = dart.import(_native_typed_data);
var _interceptors = dart.lazyImport(_interceptors);
var _js_helper = dart.lazyImport(_js_helper);
var isolate = dart.import(isolate);
var _foreign_helper = dart.import(_foreign_helper);
var _js_embedded_names = dart.import(_js_embedded_names);
var collection = dart.import(collection);
var async = dart.import(async);
(function(exports, core, _native_typed_data, _interceptors, _js_helper, isolate, _foreign_helper, _js_embedded_names, collection, async) {
'use strict';
// Function _serializeMessage: (dynamic) → dynamic
function _serializeMessage(message) {
Expand Down Expand Up @@ -1384,4 +1393,4 @@ var _isolate_helper;
exports.TimerImpl = TimerImpl;
exports.hasTimer = hasTimer;
exports.CapabilityImpl = CapabilityImpl;
})(_isolate_helper || (_isolate_helper = {}));
})(_isolate_helper, core, _native_typed_data, _interceptors, _js_helper, isolate, _foreign_helper, _js_embedded_names, collection, async);
4 changes: 2 additions & 2 deletions pkg/dev_compiler/lib/runtime/dart/_js_embedded_names.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var _js_embedded_names;
var _js_embedded_names = dart.defineLibrary(_js_embedded_names, {});
(function(exports) {
'use strict';
let DISPATCH_PROPERTY_NAME = "dispatchPropertyName";
Expand Down Expand Up @@ -64,4 +64,4 @@ var _js_embedded_names;
exports.TYPEDEF_PREDICATE_PROPERTY_NAME = TYPEDEF_PREDICATE_PROPERTY_NAME;
exports.NATIVE_SUPERCLASS_TAG_NAME = NATIVE_SUPERCLASS_TAG_NAME;
exports.MAP_TYPE_TO_INTERCEPTOR = MAP_TYPE_TO_INTERCEPTOR;
})(_js_embedded_names || (_js_embedded_names = {}));
})(_js_embedded_names);
15 changes: 12 additions & 3 deletions pkg/dev_compiler/lib/runtime/dart/_js_helper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
var _js_helper;
(function(exports) {
var _js_helper = dart.defineLibrary(_js_helper, {});
var core = dart.import(core);
var collection = dart.import(collection);
var _internal = dart.import(_internal);
var _foreign_helper = dart.import(_foreign_helper);
var _js_embedded_names = dart.import(_js_embedded_names);
var _interceptors = dart.lazyImport(_interceptors);
var _js_names = dart.import(_js_names);
var async = dart.import(async);
var _isolate_helper = dart.lazyImport(_isolate_helper);
(function(exports, core, collection, _internal, _foreign_helper, _js_embedded_names, _interceptors, _js_names, async, _isolate_helper) {
'use strict';
class NoSideEffects extends core.Object {
NoSideEffects() {
Expand Down Expand Up @@ -4080,4 +4089,4 @@ var _js_helper;
exports.missingMain = missingMain;
exports.badMain = badMain;
exports.mainHasTooManyParameters = mainHasTooManyParameters;
})(_js_helper || (_js_helper = {}));
})(_js_helper, core, collection, _internal, _foreign_helper, _js_embedded_names, _interceptors, _js_names, async, _isolate_helper);
11 changes: 8 additions & 3 deletions pkg/dev_compiler/lib/runtime/dart/_js_names.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
var _js_names;
(function(exports) {
var _js_names = dart.defineLibrary(_js_names, {});
var _foreign_helper = dart.lazyImport(_foreign_helper);
var _js_embedded_names = dart.import(_js_embedded_names);
var core = dart.import(core);
var _interceptors = dart.import(_interceptors);
var _js_helper = dart.lazyImport(_js_helper);
(function(exports, _foreign_helper, _js_embedded_names, core, _interceptors, _js_helper) {
'use strict';
// Function preserveNames: () → dynamic
function preserveNames() {
Expand Down Expand Up @@ -76,4 +81,4 @@ var _js_names;
exports.extractKeys = extractKeys;
exports.unmangleGlobalNameIfPreservedAnyways = unmangleGlobalNameIfPreservedAnyways;
exports.unmangleAllIdentifiersIfPreservedAnyways = unmangleAllIdentifiersIfPreservedAnyways;
})(_js_names || (_js_names = {}));
})(_js_names, _foreign_helper, _js_embedded_names, core, _interceptors, _js_helper);
4 changes: 2 additions & 2 deletions pkg/dev_compiler/lib/runtime/dart/_js_primitives.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var _js_primitives;
var _js_primitives = dart.defineLibrary(_js_primitives, {});
(function(exports) {
'use strict';
// Function printString: (String) → void
Expand All @@ -22,4 +22,4 @@ var _js_primitives;
}
// Exports:
exports.printString = printString;
})(_js_primitives || (_js_primitives = {}));
})(_js_primitives);
13 changes: 10 additions & 3 deletions pkg/dev_compiler/lib/runtime/dart/_native_typed_data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
var _native_typed_data;
(function(exports) {
var _native_typed_data = dart.defineLibrary(_native_typed_data, {});
var core = dart.import(core);
var typed_data = dart.lazyImport(typed_data);
var collection = dart.import(collection);
var _internal = dart.import(_internal);
var _interceptors = dart.lazyImport(_interceptors);
var _js_helper = dart.lazyImport(_js_helper);
var math = dart.import(math);
(function(exports, core, typed_data, collection, _internal, _interceptors, _js_helper, math) {
'use strict';
class NativeByteBuffer extends core.Object {
NativeByteBuffer() {
Expand Down Expand Up @@ -1555,4 +1562,4 @@ var _native_typed_data;
exports.NativeFloat32x4 = NativeFloat32x4;
exports.NativeInt32x4 = NativeInt32x4;
exports.NativeFloat64x2 = NativeFloat64x2;
})(_native_typed_data || (_native_typed_data = {}));
})(_native_typed_data, core, typed_data, collection, _internal, _interceptors, _js_helper, math);
11 changes: 8 additions & 3 deletions pkg/dev_compiler/lib/runtime/dart/async.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
var async;
(function(exports) {
var async = dart.defineLibrary(async, {});
var core = dart.import(core);
var _internal = dart.import(_internal);
var _js_helper = dart.lazyImport(_js_helper);
var _isolate_helper = dart.lazyImport(_isolate_helper);
var collection = dart.import(collection);
(function(exports, core, _internal, _js_helper, _isolate_helper, collection) {
'use strict';
// Function _invokeErrorHandler: (Function, Object, StackTrace) → dynamic
function _invokeErrorHandler(errorHandler, error, stackTrace) {
Expand Down Expand Up @@ -5361,4 +5366,4 @@ var async;
exports.ZoneDelegate = ZoneDelegate;
exports.Zone = Zone;
exports.runZoned = runZoned;
})(async || (async = {}));
})(async, core, _internal, _js_helper, _isolate_helper, collection);
10 changes: 7 additions & 3 deletions pkg/dev_compiler/lib/runtime/dart/collection.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
var collection;
(function(exports) {
var collection = dart.defineLibrary(collection, {});
var _internal = dart.lazyImport(_internal);
var core = dart.import(core);
var _js_helper = dart.lazyImport(_js_helper);
var math = dart.lazyImport(math);
(function(exports, _internal, core, _js_helper, math) {
'use strict';
let _source = Symbol('_source');
let UnmodifiableListView$ = dart.generic(function(E) {
Expand Down Expand Up @@ -5153,4 +5157,4 @@ var collection;
exports.LinkedHashSetCell = LinkedHashSetCell;
exports.LinkedHashSetIterator$ = LinkedHashSetIterator$;
exports.LinkedHashSetIterator = LinkedHashSetIterator;
})(collection || (collection = {}));
})(collection, _internal, core, _js_helper, math);
11 changes: 8 additions & 3 deletions pkg/dev_compiler/lib/runtime/dart/convert.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
var convert;
(function(exports) {
var convert = dart.defineLibrary(convert, {});
var core = dart.import(core);
var async = dart.lazyImport(async);
var typed_data = dart.lazyImport(typed_data);
var _internal = dart.import(_internal);
var collection = dart.import(collection);
(function(exports, core, async, typed_data, _internal, collection) {
'use strict';
let ASCII = dart.const(new AsciiCodec());
let _ASCII_MASK = 127;
Expand Down Expand Up @@ -2429,4 +2434,4 @@ var convert;
exports.Utf8Codec = Utf8Codec;
exports.Utf8Encoder = Utf8Encoder;
exports.Utf8Decoder = Utf8Decoder;
})(convert || (convert = {}));
})(convert, core, async, typed_data, _internal, collection);
11 changes: 8 additions & 3 deletions pkg/dev_compiler/lib/runtime/dart/core.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
var core;
(function(exports) {
var core = dart.defineLibrary(core, {});
var _js_helper = dart.lazyImport(_js_helper);
var _internal = dart.lazyImport(_internal);
var collection = dart.lazyImport(collection);
var _interceptors = dart.lazyImport(_interceptors);
var convert = dart.lazyImport(convert);
(function(exports, _js_helper, _internal, collection, _interceptors, convert) {
'use strict';
class Object {
constructor() {
Expand Down Expand Up @@ -3486,4 +3491,4 @@ var core;
exports.Type = Type;
exports.Uri = Uri;
exports.SupportJsExtensionMethods = SupportJsExtensionMethods;
})(core || (core = {}));
})(core, _js_helper, _internal, collection, _interceptors, convert);
9 changes: 6 additions & 3 deletions pkg/dev_compiler/lib/runtime/dart/isolate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
var isolate;
(function(exports) {
var isolate = dart.defineLibrary(isolate, {});
var core = dart.import(core);
var _isolate_helper = dart.lazyImport(_isolate_helper);
var async = dart.import(async);
(function(exports, core, _isolate_helper, async) {
'use strict';
class Capability extends core.Object {
Capability() {
Expand Down Expand Up @@ -217,4 +220,4 @@ var isolate;
exports.ReceivePort = ReceivePort;
exports.RawReceivePort = RawReceivePort;
exports.RemoteError = RemoteError;
})(isolate || (isolate = {}));
})(isolate, core, _isolate_helper, async);
8 changes: 5 additions & 3 deletions pkg/dev_compiler/lib/runtime/dart/math.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var math;
(function(exports) {
var math = dart.defineLibrary(math, {});
var core = dart.import(core);
var _js_helper = dart.lazyImport(_js_helper);
(function(exports, core, _js_helper) {
'use strict';
class _JenkinsSmiHash extends core.Object {
static combine(hash, value) {
Expand Down Expand Up @@ -460,4 +462,4 @@ var math;
exports.sqrt = sqrt;
exports.exp = exp;
exports.log = log;
})(math || (math = {}));
})(math, core, _js_helper);
8 changes: 5 additions & 3 deletions pkg/dev_compiler/lib/runtime/dart/typed_data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var typed_data;
(function(exports) {
var typed_data = dart.defineLibrary(typed_data, {});
var core = dart.import(core);
var _native_typed_data = dart.lazyImport(_native_typed_data);
(function(exports, core, _native_typed_data) {
'use strict';
class ByteBuffer extends core.Object {}
class TypedData extends core.Object {}
Expand Down Expand Up @@ -882,4 +884,4 @@ var typed_data;
exports.Float32x4 = Float32x4;
exports.Int32x4 = Int32x4;
exports.Float64x2 = Float64x2;
})(typed_data || (typed_data = {}));
})(typed_data, core, _native_typed_data);
16 changes: 16 additions & 0 deletions pkg/dev_compiler/lib/runtime/dart_runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,22 @@ var dart, _js_helper, _js_primitives;
dart.global = window || global;
dart.JsSymbol = Symbol;

function import_(value) {
if (!value) throw 'missing required module';
return value;
}
dart.import = import_;

function lazyImport(value) {
return defineLibrary(value, {});
}
dart.lazyImport = lazyImport;

function defineLibrary(value, defaultValue) {
return value ? value : defaultValue;
}
dart.defineLibrary = defineLibrary;

// TODO(jmesserly): hack to bootstrap the SDK
_js_helper = _js_helper || {};
_js_helper.checkNum = notNull;
Expand Down
Loading

0 comments on commit da20815

Please sign in to comment.