ABT.Utils.PackArguments C# (CSharp) Метод

PackArguments() публичный статический Метод

public static PackArguments ( IReadOnlyList types ) : IReadOnlyList>.Tuple
types IReadOnlyList
Результат IReadOnlyList>.Tuple
        public static Tuple<Int32, IReadOnlyList<Int32>> PackArguments(IReadOnlyList<ExprType> types) {
            Int32 alignment = ExprType.SIZEOF_LONG;
            List<Int32> offsets = new List<Int32>();
            Int32 offset = 0;
            foreach (ExprType type in types) {
                alignment = Math.Max(type.Alignment, alignment);
                offset = RoundUp(offset, alignment);
                offsets.Add(offset);
                offset += type.SizeOf;
            }
            offset = RoundUp(offset, alignment);
            return new Tuple<Int32, IReadOnlyList<Int32>>(offset, offsets);
        }

Usage Example

Пример #1
0
        public static FunctionType Create(ExprType ret_type, List <Tuple <String, ExprType> > args, Boolean is_varargs)
        {
            Tuple <Int32, IReadOnlyList <Int32> > r_pack = Utils.PackArguments(args.ConvertAll(_ => _.Item2));
            IReadOnlyList <Int32> offsets = r_pack.Item2;

            if (ret_type is StructOrUnionType)
            {
                offsets = offsets.Select(_ => _ + 3 * SIZEOF_POINTER).ToList();
            }
            else
            {
                offsets = offsets.Select(_ => _ + 2 * SIZEOF_POINTER).ToList();
            }
            return(new FunctionType(
                       ret_type,
                       args.Zip(offsets,
                                (name_type, offset) => new Utils.StoreEntry(name_type.Item1, name_type.Item2, offset)
                                ).ToList(),
                       is_varargs
                       ));
        }
All Usage Examples Of ABT.Utils::PackArguments