Last change
on this file since 256 was
256,
checked in by hendrikvanantwerpen, 13 years ago
|
Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).
|
-
Property svn:executable set to
*
|
File size:
836 bytes
|
Line | |
---|
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')); |
---|
Note: See
TracBrowser
for help on using the repository browser.