Esempio n. 1
0
        public void VisitDeclaration(DeclarationNode node)
        {
            _variables.Add(node, _currentOffset);
            IType type = ((TypeSpecifierNode)node.Type).Type;

            _currentOffset += _typeSizeManager.GetSize(type);
        }
Esempio n. 2
0
        public StructLayout Generate(StructType structType, StructLayoutManager manager)
        {
            Dictionary <DeclarationNode, int> offsets = new Dictionary <DeclarationNode, int>();
            int nextOffset = 0;

            foreach (DeclarationNode declaration in structType.Struct.Members)
            {
                offsets.Add(declaration, nextOffset);
                nextOffset += _typeSizeManager.GetSize(((TypeSpecifierNode)declaration.Type).Type);
            }

            return(new StructLayout(offsets, nextOffset));
        }