from awlsim.common.cython_support cimport *
from awlsim.core.cpu cimport *
from awlsim.core.blocks cimport *
from awlsim.core.datablocks cimport *
from awlsim.core.lstack cimport *
from awlsim.core.memory cimport *
from awlsim.core.parameters cimport *
from awlsim.core.parenstack cimport *
from awlsim.core.operators cimport *

cdef class CallStackElem(object):
	cdef public CallStackElem prevCse
	cdef public S7CPU cpu
	cdef public ParenStack parenStack
	cdef public uint32_t ip
	cdef public CodeBlock block
	cdef public list insns
	cdef public uint32_t nrInsns
	cdef public _Bool isRawCall
	cdef public DB instanceDB
	cdef public DB prevDbRegister
	cdef public DB prevDiRegister
	cdef public uint32_t prevAR2value
	cdef public AwlMemory localdata
	cdef public list _outboundParams
	cdef public dict _interfRefs

	cpdef AwlOperator getInterfIdxOper(self, uint32_t interfaceFieldIndex)

	cdef uint64_t _FB_trans_dbpointer(self, AwlParamAssign param, AwlOperator rvalueOp)
	cdef AwlOperator _FC_trans_direct(self, AwlParamAssign param, AwlOperator rvalueOp)
	cdef AwlOperator _FC_trans_copyToVL(self, AwlParamAssign param, AwlOperator rvalueOp)
	cdef AwlOperator _FC_trans_dbpointerInVL(self, AwlParamAssign param, AwlOperator rvalueOp)
	cdef AwlOperator _FC_trans_copyToVLWithDBPtr(self, AwlParamAssign param, AwlOperator rvalueOp)
	cdef AwlOperator _FC_trans_MEM_L(self, AwlParamAssign param, AwlOperator rvalueOp)
	cdef AwlOperator _FC_trans_MEM_DB(self, AwlParamAssign param, AwlOperator rvalueOp, _Bool copyToVL=*)
	cdef AwlOperator _FC_trans_MEM_DI(self, AwlParamAssign param, AwlOperator rvalueOp)
	cdef AwlOperator _FC_trans_NAMED_LOCAL(self, AwlParamAssign param, AwlOperator rvalueOp)
	cdef AwlOperator _translateFCParam(self, AwlParamAssign param, AwlOperator rvalueOp)

	cdef handleBlockExit(self)

cdef CallStackElem make_CallStackElem(S7CPU cpu,
				       CodeBlock block,
				       DB instanceDB,
				       AwlOffset instanceBaseOffset,
				       tuple parameters,
				       _Bool isRawCall)
