Created
April 1, 2011 21:04
-
-
Save gregglind/898856 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Instruction(object): | |
def __init__(**kwargs): | |
for k,v in kwargs.items(): | |
self.k = v | |
def __repr__(self): | |
return "%s %r" % (self.__class__, self.__dict__) | |
def __call__(self,memory): | |
# do whatever it is that this thing does, returning (a copy of) the memory | |
return memory | |
class Store(Instruction): | |
def __init__(self,....): | |
# if you want to get fancy here with params, do so | |
def __call__(self,memory): | |
# do whatever store does | |
set_word(memory,self.position, self.value) # or whatever! | |
return memory | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment