def test_jumps(): parse_equals("LABEL @test_1", JumpTarget(Label("test_1"))) parse_equals("JUMP @test_1", Jump(Label("test_1"))) parse_equals("JUMP-WHEN @test_1 ro[0]", JumpWhen(Label("test_1"), MemoryReference("ro", 0))) parse_equals("JUMP-UNLESS @test_1 ro[1]", JumpUnless(Label("test_1"), MemoryReference("ro", 1)))
def _get_label(placeholder, label_mapping, label_i): """Helper function to either get the appropriate label for a given placeholder or generate a new label and update the mapping. See :py:func:`instantiate_labels` for usage. """ if placeholder in label_mapping: return label_mapping[placeholder], label_mapping, label_i new_target = Label("{}{}".format(placeholder.prefix, label_i)) label_i += 1 label_mapping[placeholder] = new_target return new_target, label_mapping, label_i
def test_jumps(): parse_equals("LABEL @test_1", JumpTarget(Label("test_1"))) parse_equals("JUMP @test_1", Jump(Label("test_1"))) parse_equals("JUMP-WHEN @test_1 ro[0]", JumpWhen(Label("test_1"), Addr(0))) parse_equals("JUMP-UNLESS @test_1 ro[1]", JumpUnless(Label("test_1"), Addr(1)))
def _label(label): # type: (QuilParser.LabelContext) -> Label return Label(label.IDENTIFIER().getText())
def test_jumps(): _test("LABEL @test_1", JumpTarget(Label("test_1"))) _test("JUMP @test_1", Jump(Label("test_1"))) _test("JUMP-WHEN @test_1 [0]", JumpWhen(Label("test_1"), Addr(0))) _test("JUMP-UNLESS @test_1 [1]", JumpUnless(Label("test_1"), Addr(1)))