public VarEnum(AstUserDefinedTypeName type) : base(type) { // Set our enum definition EnumDefinition = AstParser.GetNode <AstEnumDefinition>(type.ReferencedDeclaration); // Determine how many bytes is needed to address the enum. The enum size is // dependent on the amount of bytes needed to index all enum options. int enumSize = 0; int highestMemberIndex = EnumDefinition.Members.Length - 1; while (highestMemberIndex > 0) { // Add one to our byte count, and shift over. highestMemberIndex >>= 8; enumSize++; } // Initialize our bounds InitializeBounds(1, enumSize); }
public VarStruct(AstUserDefinedTypeName type, VarLocation location) : base(type) { // Set our struct definition StructDefinition = AstParser.GetNode <AstStructDefinition>(type.ReferencedDeclaration); // Obtain our struct members. Members = StructDefinition.Members.Select(x => new StateVariable(x)).ToArray(); // Resolve all of the storage locations for these state variables. StorageLocation endLocation = StorageManager.ResolveStorageSlots(Members); // Obtain our next free slot based off of our end location. int nextFreeSlot = (int)endLocation.SlotKeyInteger; if (endLocation.DataOffset > 0) { nextFreeSlot++; } // Our next free slot signifies our used storage entry count to that point. // Initialize our bounds InitializeBounds(nextFreeSlot, UInt256.SIZE, location); }