-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.js
34 lines (28 loc) · 951 Bytes
/
application.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Lambda.Application = function (func, arg) {
this.func = func;
this.arg = arg;
};
Lambda.Application.prototype = Object.create(Lambda.lambda_prototype);
Lambda.Application.prototype.step = function () {
if (!this.func.isNormal()) {
return new Lambda.Application(this.func.step(), this.arg);
} else if (this.func.apply) {
return this.func.apply(this.arg);
} else {
return this;
}
};
Lambda.Application.prototype.using = function (scope) {
return new Lambda.Application(this.func.using(scope), this.arg.using(scope));
};
Lambda.Application.prototype.isNormal = function () {
return this.func.isNormal() && !this.func.apply;
};
Lambda.Application.prototype.toString = function () {
return '(' + this.func + ' ' + this.arg + ')';
};
Lambda.Application.prototype.toJavaScript = function (indent) {
indent = indent || '';
return '(' + this.func.toJavaScript(indent) + ')(' +
this.arg.toJavaScript(indent) + ')';
};