#!/usr/bin/env python2
# I, Danny Milosavljevic, hereby place this file into the public domain.
import memory

class ROM(memory.Memory):
    def __init__(self, value, B_active = True):
        self.B_active = B_active
        self.memory = []
        for i in range(len(value)): # for some reason, in ShedSkin "for c in value: self.memory.append(ord(c))" doesn't work.
            c = value[i]
            v = ord(c)
            self.memory.append(v)

        #self.memory = [ord(c) for c in value]
        self.B_can_write = False # in the instance because of ShedSkin

    def read_memory(self, address, size = 1):
        if size == 1:
            return self.memory[address]
        return memory.one_big_value(self.memory[address : address + size])

    def write_memory(self, address, value, size):
        raise NotImplementedError("cannot write to ROM")
