示例#1
0
def relative_links(num):
    data_begin = find.attribute(num, "data_begin")
    data_end = find.attribute(num, "segment_end")
    index = data_begin
    while index < data_end:
        obj_type, obj_value = read.entity(index)
        if obj_type == "link":
            write.entity(index, "link", data_begin + obj_value)
            index += memory_control.determine_object_size(obj_type, obj_value)
        elif obj_type == "chars":
            index += memory_control.determine_object_size(obj_type, obj_value)
        else:
            index += 2
示例#2
0
def string_segment(data):
    data_size = memory_control.determine_object_size("char_list", data)
    seg_size = memory_control.determine_segment_size("string_segment",
                                                     data_size)
    num = add.string_segment(self_length=seg_size)
    put.string_segment(num, "char_list", data)
    return num
示例#3
0
文件: put.py 项目: gitter-badger/Yo
def stack(num, obj_type, value):
    check_type("stack", obj_type)
    obj_size = memory_control.determine_object_size(obj_type, value)
    top = find.attribute(num, "first_empty_cell")
    place = check_free_place(num, obj_size)
    check_stack_overflow(num, place)
    write.entity(top, obj_type, value)
    change_stack(num, top + obj_size, top, place)
示例#4
0
def program_code(num):
    data_begin = find.attribute(num, "data_begin")
    index = data_begin
    obj_type, command = read.entity(index)
    while obj_type != "none":
        display.command_with_args(index)
        com_name, args = read.command_with_args(index)
        index += memory_control.determine_object_size("command_with_args", args)
        obj_type, command = read.entity(index)
示例#5
0
def command_with_args(num):
    print(num, end=" ")
    entity(num)
    args = []
    obj_type, command_name = read.entity(num)
    index = num + 2
    for i in range(commands_args_number[commands_abbreviation[command_name]]):
        obj_type, value = read.entity(index)
        print("\t", end="")
        entity(index)
        index += memory_control.determine_object_size(obj_type, value)
示例#6
0
def segment_body(num):
    data_begin, data_end = data_range(num)
    top = find.attribute(num, "first_empty_cell")
    index = data_begin
    obj_type, obj_value = read.entity(index)
    while index < top:
        print(index, end=" ")
        display.entity(index)
        index += memory_control.determine_object_size(obj_type, obj_value)
        if index < data_end:
            obj_type, obj_value = read.entity(index)
    print()
示例#7
0
文件: read.py 项目: gitter-badger/Yo
def command_with_args(num):
    args = []
    obj_type, command_name = entity(num)
    if obj_type != "command":
        raise LowerCommandError(f"Ячейка #{num} содержит не команду, а "
                                f"{obj_type}")
    index = num + 2
    for i in range(commands_args_number[commands_abbreviation[command_name]]):
        obj_type, value = entity(index)
        args += [[obj_type, value]]
        index += memory_control.determine_object_size(obj_type, value)
    return command_name, args
示例#8
0
文件: write.py 项目: gitter-badger/Yo
def command_with_args(num, command_name, args):
    if len(args) != commands_args_number[command_name]:
        raise LowerCommandError(f"Неправильное число аргументов команды "
                                f"{command_name}: {len(args)} вместо "
                                f"{commands_args_number[command_name]}")
    entity(num, "command", command_name)
    index = num + 2
    for arg in args:
        obj_type = arg["type"]
        obj_value = arg["value"]
        entity(index, obj_type, obj_value)
        index += memory_control.determine_object_size(obj_type, obj_value)
示例#9
0
文件: put.py 项目: gitter-badger/Yo
def string_segment(num, obj_type, value):
    check_type("string", obj_type)
    last_num = get_last(num)
    obj_size = memory_control.determine_object_size(obj_type, value)
    top = find.attribute(last_num, "first_empty_cell")
    place = check_free_place(last_num, obj_size)
    if place >= 0:
        write.char_list(top, value)
        change_data(last_num, top + obj_size, place)
    else:
        part_1, part_2 = split_cells(obj_size, place, value)
        write.char_list(top, part_1)
        fill_segment(last_num)
        new_num = extend.string_segment(last_num)
        string_segment(num, obj_type, part_2)
示例#10
0
文件: put.py 项目: gitter-badger/Yo
def data_segment(num, obj_type, value):
    top = find.attribute(num, "first_empty_cell")
    obj_size = memory_control.determine_object_size(obj_type, value)
    place = check_free_place(num, obj_size)
    if place >= 0:
        write.entity(top, obj_type, value)
        change_data(num, top + obj_size, place)
        index = top
    else:
        if not find.is_last(num):
            next_num = find.attribute(num, "next_segment")
            index = data_segment(next_num, obj_type, value)
        else:
            new_num = extend.data_segment(num)
            index = data_segment(new_num, obj_type, value)
    return index
示例#11
0
def list_segment(data):
    data_size = memory_control.determine_object_size("link_list", data)
    seg_size = memory_control.determine_segment_size("list_segment", data_size)
    num = add.list_segment(self_length=seg_size)
    put.list_segment(num, "link_list", data)
    return num
示例#12
0
def target_cell(cell, args):
    command_size = memory_control.determine_object_size(
        "command_with_args", args)
    cell += command_size
    attribute(seg_links["system"], "target_cell", cell)