Skip to content

Commit 4dfc907

Browse files
committedApr 21, 2016
Move Proper Tail Calls runtime into individual modules (#2105)
Move Proper Tail Calls runtime into individual modules
1 parent 2d783f3 commit 4dfc907

6 files changed

+66
-11
lines changed
 

‎src/runtime/modules/call.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2016 Traceur Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
export {tailCall as default} from './properTailCalls.js';

‎src/runtime/modules/construct.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2016 Traceur Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
export {construct as default} from './properTailCalls.js';

‎src/runtime/modules/continuation.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2016 Traceur Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
export {createContinuation as default} from './properTailCalls.js';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2016 Traceur Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
export {initTailRecursiveFunction as default} from './properTailCalls.js';

‎src/runtime/modules/properTailCalls.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var CONTINUATION_TYPE = Object.create(null);
2020

2121
var isTailRecursiveName = null;
2222

23-
function createContinuation(operand, thisArg, argsArray) {
23+
export function createContinuation(operand, thisArg, argsArray) {
2424
return [CONTINUATION_TYPE, operand, thisArg, argsArray];
2525
}
2626

@@ -47,7 +47,7 @@ function isTailRecursive(func) {
4747
return !!getPrivate(func, isTailRecursiveName);
4848
}
4949

50-
function tailCall(func, thisArg, argArray) {
50+
export function tailCall(func, thisArg, argArray) {
5151
var continuation = argArray[0];
5252
if (isContinuation(continuation)) {
5353
continuation = $apply(func, thisArg, continuation[3]);
@@ -113,6 +113,3 @@ export function initTailRecursiveFunction(func) {
113113
setPrivate(func, isTailRecursiveName, true);
114114
return func;
115115
}
116-
117-
export {tailCall as call};
118-
export {createContinuation as continuation};

‎src/runtime/properTailCalls.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import {
16-
initTailRecursiveFunction,
17-
call,
18-
continuation,
19-
construct,
20-
} from './modules/properTailCalls.js';
15+
import initTailRecursiveFunction from './modules/initTailRecursiveFunction.js';
16+
import call from './modules/call.js';
17+
import continuation from './modules/continuation.js';
18+
import construct from './modules/construct.js';
2119

2220
$traceurRuntime.initTailRecursiveFunction = initTailRecursiveFunction;
2321
$traceurRuntime.call = call;

0 commit comments

Comments
 (0)
Failed to load comments.