Skip to content

Commit 5c41457

Browse files
committed
1 parent d9e0533 commit 5c41457

File tree

3 files changed

+74
-67
lines changed

3 files changed

+74
-67
lines changed

pkg/dev_compiler/lib/runtime/dart_sdk.js

Lines changed: 58 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3660,7 +3660,7 @@ dart_library.library('dart_sdk', null, /* Imports */[
36603660
return this[dartx['+']](padding[dartx['*']](delta));
36613661
}
36623662
get [dartx.codeUnits]() {
3663-
return new _interceptors._CodeUnits(this);
3663+
return new _internal.CodeUnits(this);
36643664
}
36653665
get [dartx.runes]() {
36663666
return new core.Runes(this);
@@ -3793,6 +3793,53 @@ dart_library.library('dart_sdk', null, /* Imports */[
37933793
});
37943794
_interceptors.JSString[dart.metadata] = () => [dart.const(new _js_helper.JsPeerInterface({name: 'String'}))];
37953795
dart.registerExtension(dart.global.String, _interceptors.JSString);
3796+
core.num = class num extends core.Object {
3797+
static parse(input, onError) {
3798+
if (onError === void 0) onError = null;
3799+
let source = input[dartx.trim]();
3800+
let result = core.int.parse(source, {onError: core.num._returnIntNull});
3801+
if (result != null) return result;
3802+
result = core.double.parse(source, core.num._returnDoubleNull);
3803+
if (result != null) return result;
3804+
if (onError == null) dart.throw(new core.FormatException(input));
3805+
return onError(input);
3806+
}
3807+
static _returnIntNull(_) {
3808+
return null;
3809+
}
3810+
static _returnDoubleNull(_) {
3811+
return null;
3812+
}
3813+
};
3814+
core.num[dart.implements] = () => [core.Comparable$(core.num)];
3815+
dart.setSignature(core.num, {
3816+
statics: () => ({
3817+
parse: [core.num, [core.String], [dart.functionType(core.num, [core.String])]],
3818+
_returnIntNull: [core.int, [core.String]],
3819+
_returnDoubleNull: [core.double, [core.String]]
3820+
}),
3821+
names: ['parse', '_returnIntNull', '_returnDoubleNull']
3822+
});
3823+
core.double = class double extends core.num {
3824+
static parse(source, onError) {
3825+
if (onError === void 0) onError = null;
3826+
return _js_helper.Primitives.parseDouble(source, onError);
3827+
}
3828+
};
3829+
dart.setSignature(core.double, {
3830+
statics: () => ({parse: [core.double, [core.String], [dart.functionType(core.double, [core.String])]]}),
3831+
names: ['parse']
3832+
});
3833+
core.double.NAN = 0.0 / 0.0;
3834+
core.double.INFINITY = 1.0 / 0.0;
3835+
core.double.MIN_POSITIVE = 5e-324;
3836+
core.double.MAX_FINITE = 1.7976931348623157e+308;
3837+
dart.defineLazy(core.double, {
3838+
get NEGATIVE_INFINITY() {
3839+
return -dart.notNull(core.double.INFINITY);
3840+
}
3841+
});
3842+
_internal.POWERS_OF_TEN = dart.const(dart.list([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], core.double));
37963843
const _string = Symbol('_string');
37973844
collection.ListMixin$ = dart.generic(E => {
37983845
dart.defineExtensionNames([
@@ -4562,33 +4609,6 @@ dart_library.library('dart_sdk', null, /* Imports */[
45624609
return UnmodifiableListBase;
45634610
});
45644611
_internal.UnmodifiableListBase = _internal.UnmodifiableListBase$();
4565-
core.num = class num extends core.Object {
4566-
static parse(input, onError) {
4567-
if (onError === void 0) onError = null;
4568-
let source = input[dartx.trim]();
4569-
let result = core.int.parse(source, {onError: core.num._returnIntNull});
4570-
if (result != null) return result;
4571-
result = core.double.parse(source, core.num._returnDoubleNull);
4572-
if (result != null) return result;
4573-
if (onError == null) dart.throw(new core.FormatException(input));
4574-
return onError(input);
4575-
}
4576-
static _returnIntNull(_) {
4577-
return null;
4578-
}
4579-
static _returnDoubleNull(_) {
4580-
return null;
4581-
}
4582-
};
4583-
core.num[dart.implements] = () => [core.Comparable$(core.num)];
4584-
dart.setSignature(core.num, {
4585-
statics: () => ({
4586-
parse: [core.num, [core.String], [dart.functionType(core.num, [core.String])]],
4587-
_returnIntNull: [core.int, [core.String]],
4588-
_returnDoubleNull: [core.double, [core.String]]
4589-
}),
4590-
names: ['parse', '_returnIntNull', '_returnDoubleNull']
4591-
});
45924612
core.int = class int extends core.num {
45934613
static fromEnvironment(name, opts) {
45944614
let defaultValue = opts && 'defaultValue' in opts ? opts.defaultValue : null;
@@ -4605,8 +4625,8 @@ dart_library.library('dart_sdk', null, /* Imports */[
46054625
statics: () => ({parse: [core.int, [core.String], {radix: core.int, onError: dart.functionType(core.int, [core.String])}]}),
46064626
names: ['parse']
46074627
});
4608-
_interceptors._CodeUnits = class _CodeUnits extends _internal.UnmodifiableListBase$(core.int) {
4609-
_CodeUnits(string) {
4628+
_internal.CodeUnits = class CodeUnits extends _internal.UnmodifiableListBase$(core.int) {
4629+
CodeUnits(string) {
46104630
this[_string] = string;
46114631
}
46124632
get length() {
@@ -4618,32 +4638,17 @@ dart_library.library('dart_sdk', null, /* Imports */[
46184638
get(i) {
46194639
return this[_string][dartx.codeUnitAt](i);
46204640
}
4621-
};
4622-
dart.setSignature(_interceptors._CodeUnits, {
4623-
constructors: () => ({_CodeUnits: [_interceptors._CodeUnits, [core.String]]}),
4624-
methods: () => ({get: [core.int, [core.int]]})
4625-
});
4626-
dart.defineExtensionMembers(_interceptors._CodeUnits, ['get', 'length']);
4627-
core.double = class double extends core.num {
4628-
static parse(source, onError) {
4629-
if (onError === void 0) onError = null;
4630-
return _js_helper.Primitives.parseDouble(source, onError);
4641+
static stringOf(u) {
4642+
return u[_string];
46314643
}
46324644
};
4633-
dart.setSignature(core.double, {
4634-
statics: () => ({parse: [core.double, [core.String], [dart.functionType(core.double, [core.String])]]}),
4635-
names: ['parse']
4645+
dart.setSignature(_internal.CodeUnits, {
4646+
constructors: () => ({CodeUnits: [_internal.CodeUnits, [core.String]]}),
4647+
methods: () => ({get: [core.int, [core.int]]}),
4648+
statics: () => ({stringOf: [core.String, [_internal.CodeUnits]]}),
4649+
names: ['stringOf']
46364650
});
4637-
core.double.NAN = 0.0 / 0.0;
4638-
core.double.INFINITY = 1.0 / 0.0;
4639-
core.double.MIN_POSITIVE = 5e-324;
4640-
core.double.MAX_FINITE = 1.7976931348623157e+308;
4641-
dart.defineLazy(core.double, {
4642-
get NEGATIVE_INFINITY() {
4643-
return -dart.notNull(core.double.INFINITY);
4644-
}
4645-
});
4646-
_internal.POWERS_OF_TEN = dart.const(dart.list([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], core.double));
4651+
dart.defineExtensionMembers(_internal.CodeUnits, ['get', 'length']);
46474652
_internal.EfficientLength = class EfficientLength extends core.Object {};
46484653
core.Iterable$ = dart.generic(E => {
46494654
dart.defineExtensionNames([

pkg/dev_compiler/tool/input_sdk/lib/internal/internal.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,18 @@ const POWERS_OF_TEN = const [
4545
1000000000000000000000.0,
4646
10000000000000000000000.0,
4747
];
48+
49+
/**
50+
* An [Iterable] of the UTF-16 code units of a [String] in index order.
51+
*/
52+
class CodeUnits extends UnmodifiableListBase<int> {
53+
/** The string that this is the code units of. */
54+
final String _string;
55+
56+
CodeUnits(this._string);
57+
58+
int get length => _string.length;
59+
int operator[](int i) => _string.codeUnitAt(i);
60+
61+
static String stringOf(CodeUnits u) => u._string;
62+
}

pkg/dev_compiler/tool/input_sdk/private/js_string.dart

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ class JSString extends Interceptor implements String, JSIndexable {
374374
return this + padding * delta;
375375
}
376376

377-
List<int> get codeUnits => new _CodeUnits(this);
377+
List<int> get codeUnits => new CodeUnits(this);
378378

379379
Runes get runes => new Runes(this);
380380

@@ -471,16 +471,3 @@ class JSString extends Interceptor implements String, JSIndexable {
471471
return JS('String', '#[#]', this, index);
472472
}
473473
}
474-
475-
/**
476-
* An [Iterable] of the UTF-16 code units of a [String] in index order.
477-
*/
478-
class _CodeUnits extends UnmodifiableListBase<int> {
479-
/** The string that this is the code units of. */
480-
String _string;
481-
482-
_CodeUnits(this._string);
483-
484-
int get length => _string.length;
485-
int operator[](int i) => _string.codeUnitAt(i);
486-
}

0 commit comments

Comments
 (0)