Commit 8f6bfc4f authored by Michael Büsch's avatar Michael Büsch

Improve callstack code readability

Signed-off-by: Michael Büsch's avatarMichael Buesch <[email protected]>
parent 21891c06
......@@ -50,31 +50,18 @@ class CallStackElem(object):
# parameters -> An iterable of AwlParamAssign instances
# representing the parameter assignments in CALL insn.
# isRawCall -> True, if the calling instruction was UC or CC.
(self.cpu,
self.parenStack,
self.ip,
self.lalloc,
self.block,
self.insns,
self.labels,
self.isRawCall,
self.instanceDB,
self.prevDbRegister,
self.prevDiRegister) = (
cpu,
[],
0,
self.lallocCache.get(cpu),
block,
block.insns,
block.labels,
isRawCall,
instanceDB,
cpu.dbRegister,
cpu.diRegister,
)
self.localdata = self.lalloc.localdata
self.cpu = cpu
self.parenStack = []
self.ip = 0
self.block = block
self.insns = block.insns
self.isRawCall = isRawCall
self.instanceDB = instanceDB
self.prevDbRegister = cpu.dbRegister
self.prevDiRegister = cpu.diRegister
self.lalloc = self.lallocCache.get(cpu)
self.lalloc.allocation = block.interface.tempAllocation
self.localdata = self.lalloc.localdata
# Handle parameters
self.__outboundParams = []
......
......@@ -812,12 +812,10 @@ class S7CPU(object):
return None
def labelIdxToRelJump(self, labelIndex):
# Translate a label index into a relative IP offset.
cse = self.callStackTop
label = cse.labels[labelIndex]
referencedInsn = label.getInsn()
referencedIp = referencedInsn.getIP()
assert(referencedIp < len(cse.insns))
return referencedIp - cse.ip
label = cse.block.labels[labelIndex]
return label.getInsn().getIP() - cse.ip
def jumpToLabel(self, labelIndex):
self.relativeJump = self.labelIdxToRelJump(labelIndex)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment