def classical_comparison(self, op, target, left, right): if op == "EQ": return ClassicalEqual(target, left, right) elif op == "GT": return ClassicalGreaterThan(target, left, right) elif op == "GE": return ClassicalGreaterEqual(target, left, right) elif op == "LT": return ClassicalLessThan(target, left, right) elif op == "LE": return ClassicalLessEqual(target, left, right)
def GT(classical_reg1, classical_reg2, classical_reg3): """ Produce an GT instruction. :param classical_reg1: Memory address to which to store the comparison result. :param classical_reg2: Left comparison operand. :param classical_reg3: Right comparison operand. :return: A ClassicalGreaterThan instance. """ classical_reg1, classical_reg2, classical_reg3 = prepare_ternary_operands( classical_reg1, classical_reg2, classical_reg3) return ClassicalGreaterThan(classical_reg1, classical_reg2, classical_reg3)
def GT( classical_reg1: MemoryReferenceDesignator, classical_reg2: MemoryReferenceDesignator, classical_reg3: Union[MemoryReferenceDesignator, int, float], ) -> ClassicalGreaterThan: """ Produce an GT instruction. :param classical_reg1: Memory address to which to store the comparison result. :param classical_reg2: Left comparison operand. :param classical_reg3: Right comparison operand. :return: A ClassicalGreaterThan instance. """ classical_reg1, classical_reg2, classical_reg3 = prepare_ternary_operands( classical_reg1, classical_reg2, classical_reg3) return ClassicalGreaterThan(classical_reg1, classical_reg2, classical_reg3)
def exitClassicalComparison(self, ctx): # type: (QuilParser.ClassicalComparisonContext) -> None target = _addr(ctx.addr(0)) left = _addr(ctx.addr(1)) if ctx.number(): right = _number(ctx.number()) else: right = _addr(ctx.addr(2)) if ctx.EQ(): self.result.append(ClassicalEqual(target, left, right)) elif ctx.GT(): self.result.append(ClassicalGreaterThan(target, left, right)) elif ctx.GE(): self.result.append(ClassicalGreaterEqual(target, left, right)) elif ctx.LT(): self.result.append(ClassicalLessThan(target, left, right)) elif ctx.LE(): self.result.append(ClassicalLessEqual(target, left, right))