Exemple #1
0
        public void VisitAccess(AccessNode node)
        {
            IAddressableNode addressableLhs = (IAddressableNode)node.Lhs;

            addressableLhs.AcceptAddressableVisitor(this);

            StructType   structType = (StructType)_module.ExpressionResultTypes[node.Lhs];
            StructLayout layout     = _structLayoutManager.GetLayout(structType);

            if (!layout.MemberOffsets.TryGetValue(node.Rhs, out int offset))
            {
                throw new InvalidOperationException();
            }

            AbsoluteStackAddress += offset;
        }
        public void VisitAccess(AccessNode node)
        {
            node.Lhs.AcceptExpressionVisitor(this);

            StructType   structType = (StructType)_module.ExpressionResultTypes[node.Lhs];
            StructLayout layout     = _structLayoutManager.GetLayout(structType);

            if (!layout.MemberOffsets.TryGetValue(node.Rhs, out int offset))
            {
                throw new InvalidOperationException();
            }

            int structSize = _typeSizeManager.GetSize(structType);
            int fieldSize  = _typeSizeManager.GetSize(((TypeSpecifierNode)node.Rhs.Type).Type);

            int trim = structSize - offset - fieldSize;

            _functionBuilder.AddInstruction(OpCode.POP, 0, trim);
            _functionBuilder.AddInstruction(OpCode.ACCESS, offset, offset + fieldSize);
        }