diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2021-04-25 00:14:35 +0200 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2021-04-25 00:14:35 +0200 |
commit | e1c3cdc1dc70c7b085e7e030fdc519dc82452ee0 (patch) | |
tree | 786d19cd3e8d6874acc9ea3211056cf5d408dfdb /pysc-v/InstructionSets/instructions.py | |
parent | 6424e20409608dcc083f2dadaf381e101649313f (diff) |
Register instructions in InstructionSet
Diffstat (limited to 'pysc-v/InstructionSets/instructions.py')
-rw-r--r-- | pysc-v/InstructionSets/instructions.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/pysc-v/InstructionSets/instructions.py b/pysc-v/InstructionSets/instructions.py index 5587f2e..625226a 100644 --- a/pysc-v/InstructionSets/instructions.py +++ b/pysc-v/InstructionSets/instructions.py @@ -16,12 +16,18 @@ class Instruction: return class InstructionSet: + def __init__(self, init=None): - self.data = dict() + self.instructions = dict() + + def instruction(self, ins): + if ins.name not in self.instructions: + self.instructions[ins.name] = ins + return ins - def add_instruction(self, ins): - if ins.name not in self.data: - self.data[ins.name] = ins + # NOTE: We don't need to treat pseudoinstructions in an special way yet, + # but we separate the decorator for clarity + pseudoinstruction = instruction if __name__ == "__main__": |