Skip to content

Commit

Permalink
Extract spread runtime code into a new file
Browse files Browse the repository at this point in the history
The intent is to make the runtime library more modular.

See #1007
  • Loading branch information
arv committed May 12, 2014
1 parent cbc7e8c commit 72dab8a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 24 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
RUNTIME_SRC = \
src/runtime/runtime.js \
src/runtime/spread.js \
src/runtime/url.js \
src/runtime/ModuleStore.js
SRC = \
Expand Down
28 changes: 16 additions & 12 deletions bin/traceur.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,6 @@
throw $TypeError(x + ' is not an Object');
return x;
}
function spread() {
var rv = [],
k = 0;
for (var i = 0; i < arguments.length; i++) {
var valueToSpread = toObject(arguments[i]);
for (var j = 0; j < valueToSpread.length; j++) {
rv[k++] = valueToSpread[j];
}
}
return rv;
}
function superDescriptor(homeObject, name) {
var proto = $getPrototypeOf(homeObject);
do {
Expand Down Expand Up @@ -571,7 +560,6 @@
getOwnHashObject: getOwnHashObject,
setProperty: setProperty,
setupGlobals: setupGlobals,
spread: spread,
superCall: superCall,
superGet: superGet,
superSet: superSet,
Expand All @@ -581,6 +569,22 @@
typeof: typeOf
};
})(typeof global !== 'undefined' ? global : this);
(function() {
'use strict';
var toObject = $traceurRuntime.toObject;
function spread() {
var rv = [],
k = 0;
for (var i = 0; i < arguments.length; i++) {
var valueToSpread = toObject(arguments[i]);
for (var j = 0; j < valueToSpread.length; j++) {
rv[k++] = valueToSpread[j];
}
}
return rv;
}
$traceurRuntime.spread = spread;
})();
(function() {
function buildFromEncodedParts(opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_queryData, opt_fragment) {
var out = [];
Expand Down
12 changes: 0 additions & 12 deletions src/runtime/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,17 +392,6 @@
return x;
}

function spread() {
var rv = [], k = 0;
for (var i = 0; i < arguments.length; i++) {
var valueToSpread = toObject(arguments[i]);
for (var j = 0; j < valueToSpread.length; j++) {
rv[k++] = valueToSpread[j];
}
}
return rv;
}

function superDescriptor(homeObject, name) {
var proto = $getPrototypeOf(homeObject);
do {
Expand Down Expand Up @@ -743,7 +732,6 @@
getOwnHashObject: getOwnHashObject,
setProperty: setProperty,
setupGlobals: setupGlobals,
spread: spread,
superCall: superCall,
superGet: superGet,
superSet: superSet,
Expand Down
32 changes: 32 additions & 0 deletions src/runtime/spread.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2014 Traceur Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

(function() {
'use strict';

var toObject = $traceurRuntime.toObject;

function spread() {
var rv = [], k = 0;
for (var i = 0; i < arguments.length; i++) {
var valueToSpread = toObject(arguments[i]);
for (var j = 0; j < valueToSpread.length; j++) {
rv[k++] = valueToSpread[j];
}
}
return rv;
}

$traceurRuntime.spread = spread;
})();

0 comments on commit 72dab8a

Please sign in to comment.