Skip to content

Commit 7add882

Browse files
author
Olivier Chafik
committed
Move runtime js files down to lib/runtime/dart
Prepare for writing all the runtime in Dart: - Move js runtime files to lib/runtime/dart (dart_runtime.js -> dart/_runtime.js), - Use rest params instead of arguments slicing in a couple of places. BUG=dart-archive/dev_compiler#310 [email protected] Review URL: https://codereview.chromium.org/1413683006 .
1 parent 27db3b7 commit 7add882

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+139
-152
lines changed

pkg/dev_compiler/lib/runtime/_classes.js renamed to pkg/dev_compiler/lib/runtime/dart/_classes.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
*/
1111

1212
// TODO(leafp): Consider splitting some of this out.
13-
dart_library.library('dart_runtime/_classes', null, /* Imports */[
13+
dart_library.library('dart/_classes', null, /* Imports */[
1414
], /* Lazy Imports */[
1515
'dart/core',
1616
'dart/_interceptors',
17-
'dart_runtime/_types',
18-
'dart_runtime/_rtti',
17+
'dart/_types',
18+
'dart/_rtti',
1919
], function(exports, core, _interceptors, types, rtti) {
2020
'use strict';
2121

@@ -30,8 +30,6 @@ dart_library.library('dart_runtime/_classes', null, /* Imports */[
3030
const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
3131
const getOwnPropertySymbols = Object.getOwnPropertySymbols;
3232

33-
const slice = [].slice;
34-
3533
/** The Symbol for storing type arguments on a specialized generic type. */
3634
const _mixins = Symbol('mixins');
3735
const _implements = Symbol('implements');
@@ -48,15 +46,14 @@ dart_library.library('dart_runtime/_classes', null, /* Imports */[
4846
* For each mixin, we only take its own properties, not anything from its
4947
* superclass (prototype).
5048
*/
51-
function mixin(base/*, ...mixins*/) {
49+
function mixin(base, ...mixins) {
5250
// Create an initializer for the mixin, so when derived constructor calls
5351
// super, we can correctly initialize base and mixins.
54-
let mixins = slice.call(arguments, 1);
5552

5653
// Create a class that will hold all of the mixin methods.
5754
class Mixin extends base {
5855
// Initializer method: run mixin initializers, then the base.
59-
[base.name](/*...args*/) {
56+
[base.name](...args) {
6057
// Run mixin initializers. They cannot have arguments.
6158
// Run them backwards so most-derived mixin is initialized first.
6259
for (let i = mixins.length - 1; i >= 0; i--) {
@@ -66,7 +63,7 @@ dart_library.library('dart_runtime/_classes', null, /* Imports */[
6663
}
6764
// Run base initializer.
6865
let init = base.prototype[base.name];
69-
if (init) init.apply(this, arguments);
66+
if (init) init.apply(this, args);
7067
}
7168
}
7269
// Copy each mixin's methods, with later ones overwriting earlier entries.
@@ -113,11 +110,10 @@ dart_library.library('dart_runtime/_classes', null, /* Imports */[
113110
throwInternalError('must have at least one generic type argument');
114111
}
115112
let resultMap = new Map();
116-
function makeGenericType(/*...arguments*/) {
117-
if (arguments.length != length && arguments.length != 0) {
113+
function makeGenericType(...args) {
114+
if (args.length != length && args.length != 0) {
118115
throwInternalError('requires ' + length + ' or 0 type arguments');
119116
}
120-
let args = slice.call(arguments);
121117
while (args.length < length) args.push(types.dynamic);
122118

123119
let value = resultMap;
@@ -366,7 +362,7 @@ dart_library.library('dart_runtime/_classes', null, /* Imports */[
366362
*/
367363
// TODO(jmesserly): essentially this gives two names to the same method.
368364
// This benefit is roughly equivalent call performance either way, but the
369-
// cost is we need to call defineExtensionMembers any time a subclass
365+
// cost is we need to call defineExtensionMembers any time a subclass
370366
// overrides one of these methods.
371367
function defineExtensionMembers(type, methodNames) {
372368
let proto = type.prototype;

pkg/dev_compiler/lib/runtime/_errors.js renamed to pkg/dev_compiler/lib/runtime/dart/_errors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
*
88
*/
99

10-
dart_library.library('dart_runtime/_errors', null, /* Imports */[
10+
dart_library.library('dart/_errors', null, /* Imports */[
1111
], /* Lazy Imports */[
12-
'dart_runtime/_operations',
12+
'dart/_operations',
1313
'dart/core',
1414
'dart/_js_helper'
1515
], function(exports, operations, core, _js_helper) {

pkg/dev_compiler/lib/runtime/dart/_foreign_helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/_foreign_helper', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/core'
44
], /* Lazy imports */[
55
], function(exports, dart, core) {

pkg/dev_compiler/lib/runtime/_generators.js renamed to pkg/dev_compiler/lib/runtime/dart/_generators.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
* Inspired by `co`: https://github.com/tj/co/blob/master/index.js, which is a
1515
* stepping stone for proposed ES7 async/await, and uses ES6 Promises.
1616
*/
17-
dart_library.library('dart_runtime/_generators', null, /* Imports */[
17+
dart_library.library('dart/_generators', null, /* Imports */[
1818
], /* Lazy Imports */[
19-
'dart_runtime/_operations',
19+
'dart/_operations',
2020
'dart/_js_helper',
2121
'dart/core',
2222
'dart/collection',

pkg/dev_compiler/lib/runtime/dart/_interceptors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/_interceptors', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/core',
44
'dart/_internal',
55
'dart/collection',

pkg/dev_compiler/lib/runtime/dart/_internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/_internal', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/core',
44
'dart/collection'
55
], /* Lazy imports */[

pkg/dev_compiler/lib/runtime/dart/_isolate_helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/_isolate_helper', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/core',
44
'dart/_interceptors',
55
'dart/_js_helper',

pkg/dev_compiler/lib/runtime/dart/_js_embedded_names.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/_js_embedded_names', null, /* Imports */[
2-
"dart_runtime/dart"
2+
"dart/_runtime"
33
], /* Lazy imports */[
44
], function(exports, dart) {
55
'use strict';

pkg/dev_compiler/lib/runtime/dart/_js_helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/_js_helper', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/core',
44
'dart/collection',
55
'dart/_interceptors',

pkg/dev_compiler/lib/runtime/dart/_js_mirrors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/_js_mirrors', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/_internal',
44
'dart/core',
55
'dart/mirrors'

pkg/dev_compiler/lib/runtime/dart/_js_primitives.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/_js_primitives', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/core'
44
], /* Lazy imports */[
55
], function(exports, dart, core) {

pkg/dev_compiler/lib/runtime/dart/_native_typed_data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/_native_typed_data', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/core',
44
'dart/typed_data',
55
'dart/_js_helper',

pkg/dev_compiler/lib/runtime/_operations.js renamed to pkg/dev_compiler/lib/runtime/dart/_operations.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
/* This library defines runtime operations on objects used by the code
66
* generator.
77
*/
8-
dart_library.library('dart_runtime/_operations', null, /* Imports */[
8+
dart_library.library('dart/_operations', null, /* Imports */[
99
], /* Lazy Imports */[
1010
'dart/async',
1111
'dart/collection',
1212
'dart/core',
1313
'dart/_js_helper',
14-
'dart_runtime/_classes',
15-
'dart_runtime/_errors',
16-
'dart_runtime/_rtti',
17-
'dart_runtime/_types'
14+
'dart/_classes',
15+
'dart/_errors',
16+
'dart/_rtti',
17+
'dart/_types'
1818
], function(exports, async, collection, core, _js_helper, classes, errors, rtti,
1919
types) {
2020
'use strict';
@@ -25,8 +25,6 @@ dart_library.library('dart_runtime/_operations', null, /* Imports */[
2525
const getOwnPropertyNames = Object.getOwnPropertyNames;
2626
const hasOwnProperty = Object.prototype.hasOwnProperty;
2727

28-
const slice = [].slice;
29-
3028
function _canonicalFieldName(obj, name, args, displayName) {
3129
name = classes.canonicalMember(obj, name);
3230
if (name) return name;
@@ -143,8 +141,7 @@ dart_library.library('dart_runtime/_operations', null, /* Imports */[
143141
throwNoSuchMethod(obj, name, args, f);
144142
}
145143

146-
function dcall(f/*, ...args*/) {
147-
let args = slice.call(arguments, 1);
144+
function dcall(f, ...args) {
148145
let ftype = rtti.read(f);
149146
return checkAndCall(f, ftype, void 0, args, 'call');
150147
}
@@ -158,8 +155,8 @@ dart_library.library('dart_runtime/_operations', null, /* Imports */[
158155
return checkAndCall(f, ftype, obj, args, displayName);
159156
}
160157

161-
function dsend(obj, method/*, ...args*/) {
162-
return callMethod(obj, method, slice.call(arguments, 2), method);
158+
function dsend(obj, method, ...args) {
159+
return callMethod(obj, method, args, method);
163160
}
164161
exports.dsend = dsend;
165162

@@ -335,8 +332,7 @@ dart_library.library('dart_runtime/_operations', null, /* Imports */[
335332
* Will call each successive callback, unless one returns null, which stops
336333
* the sequence.
337334
*/
338-
function nullSafe(obj /*, ...callbacks*/) {
339-
let callbacks = slice.call(arguments, 1);
335+
function nullSafe(obj, ...callbacks) {
340336
if (obj == null) return obj;
341337
for (const callback of callbacks) {
342338
obj = callback(obj);

pkg/dev_compiler/lib/runtime/_rtti.js renamed to pkg/dev_compiler/lib/runtime/dart/_rtti.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@
66
* runtime types.
77
*/
88

9-
dart_library.library('dart_runtime/_rtti', null, /* Imports */[
9+
dart_library.library('dart/_rtti', null, /* Imports */[
1010
], /* Lazy Imports */[
1111
'dart/core',
12-
'dart_runtime/_types'
12+
'dart/_types'
1313
], function(exports, core, types) {
1414
'use strict';
1515

1616
const defineLazyProperty = dart_utils.defineLazyProperty;
1717

1818
const defineProperty = Object.defineProperty;
1919

20-
const slice = [].slice;
21-
2220
/**
2321
* Runtime type information. This module defines the mapping from
2422
* runtime objects to their runtime type information. See the types
@@ -63,22 +61,20 @@ dart_library.library('dart_runtime/_rtti', null, /* Imports */[
6361
* Note that since we are producing a type for a concrete function,
6462
* it is sound to use the definite arrow type.
6563
*/
66-
function fn(closure/* ...args*/) {
64+
function fn(closure, ...args) {
6765
// Closure and a lazy type constructor
68-
if (arguments.length == 2) {
69-
defineLazyProperty(closure, _runtimeType, {get : arguments[1]});
66+
if (args.length == 1) {
67+
defineLazyProperty(closure, _runtimeType, {get : args[0]});
7068
return closure;
7169
}
7270
let t;
73-
if (arguments.length == 1) {
71+
if (args.length == 0) {
7472
// No type arguments, it's all dynamic
75-
let len = closure.length;
76-
let args = Array.apply(null, new Array(len)).map(() => types.dynamic);
77-
t = types.definiteFunctionType(types.dynamic, args);
73+
t = types.definiteFunctionType(
74+
types.dynamic, Array(closure.length).fill(types.dynamic));
7875
} else {
7976
// We're passed the piecewise components of the function type,
8077
// construct it.
81-
let args = slice.call(arguments, 1);
8278
t = types.definiteFunctionType.apply(null, args);
8379
}
8480
tag(closure, t);
@@ -117,8 +113,7 @@ dart_library.library('dart_runtime/_rtti', null, /* Imports */[
117113

118114
function getFunctionType(obj) {
119115
// TODO(vsm): Encode this properly on the function for Dart-generated code.
120-
let args =
121-
Array.apply(null, new Array(obj.length)).map(() => types.dynamic);
116+
let args = Array(obj.length).fill(types.dynamic);
122117
return types.definiteFunctionType(types.bottom, args);
123118
}
124119

@@ -153,7 +148,7 @@ dart_library.library('dart_runtime/_rtti', null, /* Imports */[
153148
}
154149
exports.LazyTagged = LazyTagged;
155150

156-
function read(value) {
151+
function read(value) {
157152
return value[_runtimeType];
158153
}
159154
exports.read = read;

pkg/dev_compiler/lib/runtime/dart_runtime.js renamed to pkg/dev_compiler/lib/runtime/dart/_runtime.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
dart_library.library('dart_runtime/dart', null, /* Imports */[
6-
'dart_runtime/_classes',
7-
'dart_runtime/_errors',
8-
'dart_runtime/_generators',
9-
'dart_runtime/_operations',
10-
'dart_runtime/_rtti',
11-
'dart_runtime/_types',
5+
dart_library.library('dart/_runtime', null, /* Imports */[
6+
'dart/_classes',
7+
'dart/_errors',
8+
'dart/_generators',
9+
'dart/_operations',
10+
'dart/_rtti',
11+
'dart/_types',
1212
], /* Lazy Imports */[
1313
'dart/_js_helper'
1414
], function(exports, classes, errors, generators, operations, rtti, types,

pkg/dev_compiler/lib/runtime/_types.js renamed to pkg/dev_compiler/lib/runtime/dart/_types.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
/* This library defines the representation of runtime types.
66
*/
77

8-
dart_library.library('dart_runtime/_types', null, /* Imports */[
8+
dart_library.library('dart/_types', null, /* Imports */[
99
], /* Lazy Imports */[
1010
'dart/core',
11-
'dart_runtime/_classes',
12-
'dart_runtime/_rtti'
11+
'dart/_classes',
12+
'dart/_rtti'
1313
], function(exports, core, classes, rtti) {
1414
'use strict';
1515

pkg/dev_compiler/lib/runtime/dart/async.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/async', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/core',
44
'dart/_internal',
55
'dart/collection'

pkg/dev_compiler/lib/runtime/dart/collection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/collection', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/core'
44
], /* Lazy imports */[
55
'dart/_internal',

pkg/dev_compiler/lib/runtime/dart/convert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/convert', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/core',
44
'dart/async',
55
'dart/typed_data',

pkg/dev_compiler/lib/runtime/dart/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/core', null, /* Imports */[
2-
"dart_runtime/dart"
2+
"dart/_runtime"
33
], /* Lazy imports */[
44
'dart/_js_helper',
55
'dart/_internal',

pkg/dev_compiler/lib/runtime/dart/isolate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/isolate', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/core',
44
'dart/async'
55
], /* Lazy imports */[

pkg/dev_compiler/lib/runtime/dart/js.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/js', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/core',
44
'dart/collection',
55
'dart/_js_helper'

pkg/dev_compiler/lib/runtime/dart/math.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/math', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/core'
44
], /* Lazy imports */[
55
'dart/_js_helper'

pkg/dev_compiler/lib/runtime/dart/mirrors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/mirrors', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/core'
44
], /* Lazy imports */[
55
'dart/_js_mirrors'

pkg/dev_compiler/lib/runtime/dart/typed_data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dart_library.library('dart/typed_data', null, /* Imports */[
2-
"dart_runtime/dart",
2+
"dart/_runtime",
33
'dart/core'
44
], /* Lazy imports */[
55
'dart/_native_typed_data'

0 commit comments

Comments
 (0)