Skip to content

Commit

Permalink
fixes #131, use before define from variables to classes
Browse files Browse the repository at this point in the history
Factored the load order logic into its own file, as it was easier to work with that way. We could definitely tweak the structure.

Also tried hoisting constants out to top level, but it's not quite ready yet, so splitting that work out into a separate CL.

(also fixes #152 about cleaning up lazyClass, and fixes #181 about static fields)

[email protected]

Review URL: https://codereview.chromium.org/1133593004
  • Loading branch information
John Messerly committed May 12, 2015
1 parent 32f3c78 commit aba85e3
Show file tree
Hide file tree
Showing 28 changed files with 1,476 additions and 1,314 deletions.
16 changes: 8 additions & 8 deletions pkg/dev_compiler/lib/runtime/dart/_interceptors.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ var _js_embedded_names = dart.import(_js_embedded_names);
return JSExtendableArray;
});
let JSExtendableArray = JSExtendableArray$();
let _isInt32 = Symbol('_isInt32');
let _tdivFast = Symbol('_tdivFast');
let _tdivSlow = Symbol('_tdivSlow');
let _shlPositive = Symbol('_shlPositive');
let _shrReceiverPositive = Symbol('_shrReceiverPositive');
let _shrOtherPositive = Symbol('_shrOtherPositive');
let _shrBothPositive = Symbol('_shrBothPositive');
class Interceptor extends core.Object {
Interceptor() {
}
Expand All @@ -53,6 +46,13 @@ var _js_embedded_names = dart.import(_js_embedded_names);
return _js_helper.getRuntimeType(this);
}
}
let _isInt32 = Symbol('_isInt32');
let _tdivFast = Symbol('_tdivFast');
let _tdivSlow = Symbol('_tdivSlow');
let _shlPositive = Symbol('_shlPositive');
let _shrReceiverPositive = Symbol('_shrReceiverPositive');
let _shrOtherPositive = Symbol('_shrOtherPositive');
let _shrBothPositive = Symbol('_shrBothPositive');
class JSNumber extends Interceptor {
JSNumber() {
super.Interceptor();
Expand Down Expand Up @@ -1062,8 +1062,8 @@ var _js_embedded_names = dart.import(_js_embedded_names);
exports.JSFixedArray = JSFixedArray;
exports.JSExtendableArray$ = JSExtendableArray$;
exports.JSExtendableArray = JSExtendableArray;
exports.JSNumber = JSNumber;
exports.Interceptor = Interceptor;
exports.JSNumber = JSNumber;
exports.JSInt = JSInt;
exports.JSDouble = JSDouble;
exports.JSPositiveInt = JSPositiveInt;
Expand Down
24 changes: 12 additions & 12 deletions pkg/dev_compiler/lib/runtime/dart/_internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ var _js_primitives = dart.lazyImport(_js_primitives);
});
let ListIterator = ListIterator$();
let _Transformation$ = dart.generic(function(S, T) {
let _Transformation = dart.typedef('_Transformation', () => dart.functionType(T, [S]));
let _Transformation = dart.typedef('_Transformation', dart.functionType(T, [S]));
return _Transformation;
});
let _Transformation = _Transformation$();
Expand Down Expand Up @@ -463,7 +463,7 @@ var _js_primitives = dart.lazyImport(_js_primitives);
});
let MappedListIterable = MappedListIterable$();
let _ElementPredicate$ = dart.generic(function(E) {
let _ElementPredicate = dart.typedef('_ElementPredicate', () => dart.functionType(core.bool, [E]));
let _ElementPredicate = dart.typedef('_ElementPredicate', dart.functionType(core.bool, [E]));
return _ElementPredicate;
});
let _ElementPredicate = _ElementPredicate$();
Expand Down Expand Up @@ -503,7 +503,7 @@ var _js_primitives = dart.lazyImport(_js_primitives);
});
let WhereIterator = WhereIterator$();
let _ExpandFunction$ = dart.generic(function(S, T) {
let _ExpandFunction = dart.typedef('_ExpandFunction', () => dart.functionType(core.Iterable$(T), [S]));
let _ExpandFunction = dart.typedef('_ExpandFunction', dart.functionType(core.Iterable$(T), [S]));
return _ExpandFunction;
});
let _ExpandFunction = _ExpandFunction$();
Expand Down Expand Up @@ -1162,11 +1162,11 @@ var _js_primitives = dart.lazyImport(_js_primitives);
core.RangeError.checkValidRange(start, end, list[core.$length]);
}
getRangeList(list, start, end) {
IterableMixinWorkaround._rangeCheck(list, start, end);
IterableMixinWorkaround$()._rangeCheck(list, start, end);
return new (SubListIterable$(T))(dart.as(list, core.Iterable$(T)), start, end);
}
static setRangeList(list, start, end, from, skipCount) {
IterableMixinWorkaround._rangeCheck(list, start, end);
IterableMixinWorkaround$()._rangeCheck(list, start, end);
let length = dart.notNull(end) - dart.notNull(start);
if (length == 0)
return;
Expand All @@ -1187,7 +1187,7 @@ var _js_primitives = dart.lazyImport(_js_primitives);
Lists.copy(otherList, otherStart, list, start, length);
}
static replaceRangeList(list, start, end, iterable) {
IterableMixinWorkaround._rangeCheck(list, start, end);
IterableMixinWorkaround$()._rangeCheck(list, start, end);
if (!dart.is(iterable, EfficientLength)) {
iterable = iterable[core.$toList]();
}
Expand All @@ -1212,7 +1212,7 @@ var _js_primitives = dart.lazyImport(_js_primitives);
}
}
static fillRangeList(list, start, end, fillValue) {
IterableMixinWorkaround._rangeCheck(list, start, end);
IterableMixinWorkaround$()._rangeCheck(list, start, end);
for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(i) + 1) {
list[core.$set](i, fillValue);
}
Expand Down Expand Up @@ -1299,22 +1299,22 @@ var _js_primitives = dart.lazyImport(_js_primitives);
}
}
let __CastType0$ = dart.generic(function(S, T) {
let __CastType0 = dart.typedef('__CastType0', () => dart.functionType(core.Iterable$(T), [S]));
let __CastType0 = dart.typedef('__CastType0', dart.functionType(core.Iterable$(T), [S]));
return __CastType0;
});
let __CastType0 = __CastType0$();
let __CastType2$ = dart.generic(function(E) {
let __CastType2 = dart.typedef('__CastType2', () => dart.functionType(core.bool, [E]));
let __CastType2 = dart.typedef('__CastType2', dart.functionType(core.bool, [E]));
return __CastType2;
});
let __CastType2 = __CastType2$();
let __CastType4$ = dart.generic(function(E) {
let __CastType4 = dart.typedef('__CastType4', () => dart.functionType(core.bool, [E]));
let __CastType4 = dart.typedef('__CastType4', dart.functionType(core.bool, [E]));
return __CastType4;
});
let __CastType4 = __CastType4$();
let __CastType6$ = dart.generic(function(T) {
let __CastType6 = dart.typedef('__CastType6', () => dart.functionType(core.bool, [T]));
let __CastType6 = dart.typedef('__CastType6', dart.functionType(core.bool, [T]));
return __CastType6;
});
let __CastType6 = __CastType6$();
Expand Down Expand Up @@ -1963,6 +1963,7 @@ var _js_primitives = dart.lazyImport(_js_primitives);
Symbol.publicIdentifierRE = '(?!' + `${Symbol.reservedWordRE}` + '\\b(?!\\$))[a-zA-Z$][\\w$]*';
Symbol.identifierRE = '(?!' + `${Symbol.reservedWordRE}` + '\\b(?!\\$))[a-zA-Z$_][\\w$]*';
Symbol.operatorRE = '(?:[\\-+*/%&|^]|\\[\\]=?|==|~/?|<[<=]?|>[>=]?|unary-)';
let POWERS_OF_TEN = dart.const([1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, 10000000.0, 100000000.0, 1000000000.0, 10000000000.0, 100000000000.0, 1000000000000.0, 10000000000000.0, 100000000000000.0, 1000000000000000.0, 10000000000000000.0, 100000000000000000.0, 1000000000000000000.0, 10000000000000000000.0, 100000000000000000000.0, 1e+21, 1e+22]);
dart.defineLazyProperties(Symbol, {
get publicSymbolPattern() {
return new core.RegExp(`^(?:${Symbol.operatorRE}$|${Symbol.publicIdentifierRE}(?:=?$|[.](?!$)))+?$`);
Expand All @@ -1971,7 +1972,6 @@ var _js_primitives = dart.lazyImport(_js_primitives);
return new core.RegExp(`^(?:${Symbol.operatorRE}$|${Symbol.identifierRE}(?:=?$|[.](?!$)))+?$`);
}
});
let POWERS_OF_TEN = dart.const([1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, 10000000.0, 100000000.0, 1000000000.0, 10000000000.0, 100000000000.0, 1000000000000.0, 10000000000000.0, 100000000000000.0, 1000000000000000.0, 10000000000000000.0, 100000000000000000.0, 1000000000000000000.0, 10000000000000000000.0, 100000000000000000000.0, 1e+21, 1e+22]);
// Exports:
exports.EfficientLength = EfficientLength;
exports.ListIterable$ = ListIterable$;
Expand Down
8 changes: 4 additions & 4 deletions pkg/dev_compiler/lib/runtime/dart/_isolate_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ var async = dart.import(async);
return initializeObject(classId, emptyInstance, fields);
}
}
let __CastType0 = dart.typedef('__CastType0', () => dart.functionType(dart.dynamic, [dart.dynamic]));
let __CastType0 = dart.typedef('__CastType0', dart.functionType(dart.dynamic, [dart.dynamic]));
// Function _callInIsolate: (_IsolateContext, Function) → dynamic
function _callInIsolate(isolate, func) {
let result = isolate.eval(func);
Expand Down Expand Up @@ -840,9 +840,9 @@ var async = dart.import(async);
return !!self.postMessage;
}
});
let _MainFunction = dart.typedef('_MainFunction', () => dart.functionType(dart.dynamic, []));
let _MainFunctionArgs = dart.typedef('_MainFunctionArgs', () => dart.functionType(dart.dynamic, [dart.dynamic]));
let _MainFunctionArgsMessage = dart.typedef('_MainFunctionArgsMessage', () => dart.functionType(dart.dynamic, [dart.dynamic, dart.dynamic]));
let _MainFunction = dart.typedef('_MainFunction', dart.functionType(dart.dynamic, []));
let _MainFunctionArgs = dart.typedef('_MainFunctionArgs', dart.functionType(dart.dynamic, [dart.dynamic]));
let _MainFunctionArgsMessage = dart.typedef('_MainFunctionArgsMessage', dart.functionType(dart.dynamic, [dart.dynamic, dart.dynamic]));
class IsolateNatives extends core.Object {
static computeThisScript() {
let currentScript = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.CURRENT_SCRIPT);
Expand Down
8 changes: 4 additions & 4 deletions pkg/dev_compiler/lib/runtime/dart/_js_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3723,7 +3723,7 @@ var _isolate_helper = dart.lazyImport(_isolate_helper);
let isolateTagGetter = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.GET_ISOLATE_TAG);
return isolateTagGetter(name);
}
let LoadLibraryFunctionType = dart.typedef('LoadLibraryFunctionType', () => dart.functionType(async.Future$(core.Null), []));
let LoadLibraryFunctionType = dart.typedef('LoadLibraryFunctionType', dart.functionType(async.Future$(core.Null), []));
// Function _loadLibraryWrapper: (String) → () → Future<Null>
function _loadLibraryWrapper(loadId) {
return () => loadDeferredLibrary(loadId);
Expand All @@ -3736,7 +3736,7 @@ var _isolate_helper = dart.lazyImport(_isolate_helper);
return new (core.Set$(core.String))();
}
});
let DeferredLoadCallback = dart.typedef('DeferredLoadCallback', () => dart.functionType(dart.void, []));
let DeferredLoadCallback = dart.typedef('DeferredLoadCallback', dart.functionType(dart.void, []));
exports.deferredLoadHook = null;
// Function loadDeferredLibrary: (String) → Future<Null>
function loadDeferredLibrary(loadId) {
Expand Down Expand Up @@ -3855,8 +3855,8 @@ var _isolate_helper = dart.lazyImport(_isolate_helper);
function mainHasTooManyParameters() {
throw new MainError("'main' expects too many parameters.");
}
let __CastType0 = dart.typedef('__CastType0', () => dart.functionType(core.int, [core.String]));
let __CastType2 = dart.typedef('__CastType2', () => dart.functionType(core.double, [core.String]));
let __CastType0 = dart.typedef('__CastType0', dart.functionType(core.int, [core.String]));
let __CastType2 = dart.typedef('__CastType2', dart.functionType(core.double, [core.String]));
// Exports:
exports.NoSideEffects = NoSideEffects;
exports.NoThrows = NoThrows;
Expand Down
2 changes: 1 addition & 1 deletion pkg/dev_compiler/lib/runtime/dart/_native_typed_data.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var _native_typed_data = dart.defineLibrary(_native_typed_data, {});
var core = dart.import(core);
var typed_data = dart.lazyImport(typed_data);
var typed_data = dart.import(typed_data);
var collection = dart.import(collection);
var _internal = dart.import(_internal);
var _interceptors = dart.lazyImport(_interceptors);
Expand Down
Loading

0 comments on commit aba85e3

Please sign in to comment.