基于JavaScript的公式解释器 - 9 【逻辑操作符的实现】
2010-10-18 22:52
423 查看
逻辑操作符的基类型
逻辑操作符包括一元和二元类型,因此有两个基类型
文件:OperatorLogicBase.js
逻辑操作符的实现
文件:OperatorLogic.js
逻辑操作符包括一元和二元类型,因此有两个基类型
文件:OperatorLogicBase.js
function OperatorBinaryLogicBase() { this.DeriveFrom(new OperatorBinaryBase()); this.set_ClassName("OperatorBinaryLogicBase"); this.set_Sign("undefined"); }; function OperatorUnaryLogicBase() { this.DeriveFrom(new OperatorUnaryBase()); this.set_ClassName("OperatorUnaryLogicBase"); this.set_Sign("undefined"); };
逻辑操作符的实现
文件:OperatorLogic.js
function OperatorLogicAnd() { this.DeriveFrom(new OperatorBinaryLogicBase()); this.set_ClassName("OperatorLogicAnd"); this.set_Sign("&&"); }; OperatorLogicAnd.prototype.Evaluate = function(operands) { var values = this._getTwoNumberOperands(operands); return new OperandBoolean(values[0].get_Value() && values[1].get_Value()); }; function OperatorLogicOr() { this.DeriveFrom(new OperatorBinaryLogicBase()); this.set_ClassName("OperatorLogicOr"); this.set_Sign("||"); }; OperatorLogicOr.prototype.Evaluate = function(operands) { var values = this._getTwoNumberOperands(operands); return new OperandBoolean(values[0].get_Value() || values[1].get_Value()); }; function OperatorLogicNot() { this.DeriveFrom(new OperatorUnaryLogicBase()); this.set_ClassName("OperatorLogicOr"); this.set_Sign("!"); }; OperatorLogicNot.prototype.Evaluate = function(operands) { var val = this.GetOneNumberOperand(operands); return new OperandBoolean(!val.get_Value()); };
相关文章推荐
- 基于JavaScript的公式解释器 - 5 【一元操作符的实现】
- 基于JavaScript的公式解释器 - 6 【二元操作符基类的实现】
- 基于JavaScript的公式解释器 - 7 【算术操作符的实现】
- 基于JavaScript的公式解释器 - 8 【比较操作符的实现】
- 基于JavaScript的公式解释器 - 11 【函数的实现】
- 基于JavaScript的公式解释器 - 10 【位操作符的实现】
- 基于JavaScript的公式解释器 - 13 【公式估值器的实现】
- 基于JavaScript的公式解释器 - 3 【操作数类型的实现】
- 基于JavaScript的公式解释器 - 4 【操作符基类型的实现】
- 基于JavaScript的公式解释器 - 14 【单元格对象】
- 基于JavaScript的公式解释器 - 15 【单元格范围对象】
- 基于JavaScript+HTML5 实现打地鼠小游戏逻辑流程图文详解(附完整代码)
- 基于JavaScript的公式解释器 - 16 【MailStone,测试】
- 基于JavaScript的公式解释器 - 1 【设计】
- 基于JavaScript的公式解释器 - 12 【公式解析器】
- 基于JavaScript的公式解释器 - 2 【完善自己的类型系统】
- 基于JavaScript实现拖动滑块效果
- 基于JavaScript实现弹出框效果
- 基于javascript实现全国省市二级联动下拉选择菜单
- 基于SpringMVC+Spring+MyBatis实现秒杀系统【业务逻辑】