private ThreeAddressValueType GenVariable(LogicExprNode expr) { if (expr is BooleanNode) { return(new ThreeAddressLogicValue((expr as BooleanNode).Val)); } if (expr is LogicIdNode) { return(new ThreeAddressStringValue((expr as LogicIdNode).Name.Name)); } if (expr is LogicOpNode) { LogicOpNode op = expr as LogicOpNode; string res = GenTempVariable(); ThreeAddressValueType arg1 = GenVariable(op.Left); ThreeAddressValueType arg2 = GenVariable(op.Right); ThreeOperator p = ThreeCode.ParseOperator(op.Operation); AddCode(new ThreeCode(res, p, arg1, arg2)); return(new ThreeAddressStringValue(res)); } if (expr is LogicNotNode) { LogicNotNode lnot = expr as LogicNotNode; string res = GenTempVariable(); ThreeAddressValueType arg1 = GenVariable(lnot.LogExpr); AddCode(new ThreeCode(res, ThreeOperator.Logic_not, arg1)); return(new ThreeAddressStringValue(res)); } throw new Exception("UNKNOW VALUE. Send autors of ThreeAddressCode"); }
public virtual TResult Visit(LogicExprNode node) => this.VisitChildren(node);
public override Expr Visit(LogicExprNode node) => this.EvaluateBinaryExpression(node);