|
@@ -614,6 +614,10 @@ class LoadIndexInstruction(Instruction):
|
|
|
"""Tells if this instruction requires a definition."""
|
|
|
return False
|
|
|
|
|
|
+ def simplify(self):
|
|
|
+ return LoadIndexInstruction(
|
|
|
+ self.indexed.simplify(), self.key.simplify())
|
|
|
+
|
|
|
def generate_python_use(self, code_generator):
|
|
|
"""Generates a Python expression that retrieves this instruction's
|
|
|
result. The expression is returned as a string."""
|
|
@@ -627,6 +631,31 @@ class LoadIndexInstruction(Instruction):
|
|
|
self.indexed.generate_python_use(code_generator),
|
|
|
self.key.generate_python_use(code_generator))
|
|
|
|
|
|
+class LoadMemberInstruction(Instruction):
|
|
|
+ """An instruction that produces a value by loading a member from a container."""
|
|
|
+ def __init__(self, container, member_name):
|
|
|
+ Instruction.__init__(self)
|
|
|
+ self.container = container
|
|
|
+ self.member_name = member_name
|
|
|
+
|
|
|
+ def has_definition(self):
|
|
|
+ """Tells if this instruction requires a definition."""
|
|
|
+ return False
|
|
|
+
|
|
|
+ def simplify(self):
|
|
|
+ return LoadMemberInstruction(
|
|
|
+ self.container.simplify(), self.member_name)
|
|
|
+
|
|
|
+ def generate_python_use(self, code_generator):
|
|
|
+ """Generates a Python expression that retrieves this instruction's
|
|
|
+ result. The expression is returned as a string."""
|
|
|
+ if self.container.has_definition():
|
|
|
+ self.container.generate_python_def(code_generator)
|
|
|
+
|
|
|
+ return "%s.%s" % (
|
|
|
+ self.container.generate_python_use(code_generator),
|
|
|
+ self.member_name)
|
|
|
+
|
|
|
class NopInstruction(Instruction):
|
|
|
"""A nop instruction, which allows for the kernel's thread of execution to be interrupted."""
|
|
|
|