38 lines
789 B
JavaScript
38 lines
789 B
JavaScript
(function(tree) {
|
|
|
|
tree.Comparison = function Comparison(str) {
|
|
this.value = str;
|
|
};
|
|
|
|
tree.Comparison.prototype = {
|
|
toString: function() {
|
|
return {
|
|
'<': '<',
|
|
'>': '>',
|
|
'=': '=',
|
|
'!=': '!=',
|
|
'<=': '<=',
|
|
'>=': '>='}[this.value];
|
|
},
|
|
negate: function() {
|
|
return new tree.Comparison({
|
|
'<': '>=',
|
|
'<=': '>',
|
|
'>': '<=',
|
|
'>=': '<',
|
|
'=': '!=',
|
|
'!=': '='
|
|
}[this.value]);
|
|
},
|
|
eval: function() {
|
|
return this;
|
|
},
|
|
clone: function() {
|
|
var obj = Object.create(Object.getPrototypeOf(this));
|
|
obj.value = this.value;
|
|
return obj;
|
|
}
|
|
};
|
|
|
|
})(require('mess/tree'));
|