IFPSTools.NET/LibIFPSCC/ABT/Utils.cs
zc e16c00799d ifpscc: initial commit
libifpscc: initial commit
readme: document ifpscc/libifpscc
license: add credits for ifpscc/libifpscc (derived from code also MIT licensed)
libifps: make additional fields/types public for libifpscc
libifps: fix field documentation for some opcodes
libifps: fix loading functions that are not exported
libifps: allow saving a nonexistant primitive type if the same primitive type was added already
libifps: fix parsing Extended constants
libifps: fix ushort/short being mapped to the wrong types in one table
csproj: set Prefer32Bit=false for release builds
2023-03-28 17:24:19 +01:00

40 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
namespace ABT {
public class Utils {
// class StoreEntry
// ================
// the inner storage of entries
//
public class StoreEntry {
public StoreEntry(String name, ExprType type, Int32 offset, bool arg = false) {
this.name = name;
this.type = type;
this.offset = offset;
isArg = arg;
}
public readonly String name;
public readonly ExprType type;
public readonly Int32 offset;
public readonly bool isArg;
}
public static Int32 RoundUp(Int32 value, Int32 alignment) {
return (value + alignment - 1) & ~(alignment- 1);
}
public static Tuple<Int32, IReadOnlyList<Int32>> PackArguments(IReadOnlyList<ExprType> types) {
List<Int32> offsets = new List<Int32>();
Int32 offset = 0;
foreach (ExprType type in types) {
offsets.Add(offset);
offset++;
}
return new Tuple<Int32, IReadOnlyList<Int32>>(offset, offsets);
}
}
}