Revert "Export"
[platform/framework/web/web-ui-fw.git] / build-tools / lib / less / tree / operation.js
1 (function (tree) {
2
3 tree.Operation = function (op, operands) {
4     this.op = op.trim();
5     this.operands = operands;
6 };
7 tree.Operation.prototype.eval = function (env) {
8     var a = this.operands[0].eval(env),
9         b = this.operands[1].eval(env),
10         temp;
11
12     if (a instanceof tree.Dimension && b instanceof tree.Color) {
13         if (this.op === '*' || this.op === '+') {
14             temp = b, b = a, a = temp;
15         } else {
16             throw { name: "OperationError",
17                     message: "Can't substract or divide a color from a number" };
18         }
19     }
20     return a.operate(this.op, b);
21 };
22
23 tree.operate = function (op, a, b) {
24     switch (op) {
25         case '+': return a + b;
26         case '-': return a - b;
27         case '*': return a * b;
28         case '/': return a / b;
29     }
30 };
31
32 })(require('less/tree'));