public void Add(EnumVal value) { if (Values.Add(value.Name, value)) { throw new Exception("enum value already exists"); } }
private int ParseEnumValDecl(int offset, string schemaStr, EnumDef enumDef, bool isUnion) { string identifier; string constantValue = null; offset = ParseIdentifier(offset, schemaStr, out identifier); offset = SkipWhitespace(offset, schemaStr); if (schemaStr[offset] == '=') { offset++; offset = ParseConstant(offset, schemaStr, out constantValue); } var enumVal = new EnumVal(); enumVal.Name = identifier; if (constantValue != null) { enumVal.Value = long.Parse(constantValue); } if (isUnion && enumVal.Value.Value != 0) { enumVal.StructDef = TypeBuilder.LookupOrCreateStruct(identifier); } enumDef.Add(enumVal); return(offset); }