def fold(self, elems):
        """
        Perform constant folding.  If the result of applying the
        operator to the elements would be a fixed constant value,
        returns the result of applying the operator to the operands.
        Otherwise, returns an instance of ``Instructions`` containing
        the instructions necessary to apply the operator.

        :param elems: A list (or list-like object) containing the
                      elements.

        :returns: A list of one element, containing the instructions
                  necessary to implement the operator.
        """

        cond, if_true, if_false = elems

        if isinstance(cond, Constant):
            return [if_true if cond.value else if_false]

        return [Instructions([cond, JumpIfNot(len(if_true) + 2), pop, if_true,
                              Jump(len(if_false) + 1), pop, if_false])]