public override void Resolve() { EnumDef target = _baseField.StructDef.StructFile.GetEnumByName(_targetName); if (target == null) { throw new ParseException("Unknown enum " + _targetName, _position, _targetName.Length); } _baseField.SetAttributeValue(_attrName, target); }
private void InitBaseEnum() { if (_baseEnum == null) { _baseEnum = _structFile.GetEnumByName(_inherit); if (_baseEnum == null) { throw new LoadDataException("Base enum " + _inherit + " not found"); } } }
private void LoadEnum(StructLexer lexer, List <Attribute> attrs) { string name = lexer.GetNextToken(StructTokenType.String); EnumDef enumDef = new EnumDef(_curStructFile, name); LoadAttributes(lexer, attrs); foreach (Attribute attr in attrs) { enumDef.SetAttribute(attr.Key, attr.Value); } lexer.GetNextToken(StructTokenType.OpenCurly); uint lastValue = UInt32.MaxValue; while (!lexer.CheckNextToken(StructTokenType.CloseCurly)) { string constName = lexer.GetNextToken(StructTokenType.String); if (lexer.CheckNextToken(StructTokenType.Equals)) { string constValue = lexer.GetNextToken(StructTokenType.String); lastValue = (uint)ExpressionParser.Parse(constValue).EvaluateInt(null); } else { lastValue++; } enumDef.AddValue(constName, lastValue); if (!lexer.CheckNextToken(StructTokenType.Comma)) { if (lexer.PeekNextToken() != StructTokenType.CloseCurly) { throw new Exception("Unexpected token in enum: " + lexer.PeekNextToken()); } } } _curStructFile.Add(enumDef); }
public EnumEvaluateContext(IEvaluateContext context, EnumDef def, bool set) : base(context) { _def = def; _set = set; }
public void Add(EnumDef def) { _enumDefs.Add(def); }
private void InitBaseEnum() { if (_baseEnum == null) { _baseEnum = _structFile.GetEnumByName(_inherit); if (_baseEnum == null) throw new LoadDataException("Base enum " + _inherit + " not found"); } }
public EnumEvaluateContext(IEvaluateContext context, EnumDef def, bool set) : base(context) { _def = def; _set = set; }
private void LoadEnum(StructLexer lexer, List<Attribute> attrs) { string name = lexer.GetNextToken(StructTokenType.String); EnumDef enumDef = new EnumDef(_curStructFile, name); LoadAttributes(lexer, attrs); foreach (Attribute attr in attrs) enumDef.SetAttribute(attr.Key, attr.Value); lexer.GetNextToken(StructTokenType.OpenCurly); uint lastValue = UInt32.MaxValue; while(!lexer.CheckNextToken(StructTokenType.CloseCurly)) { string constName = lexer.GetNextToken(StructTokenType.String); if (lexer.CheckNextToken(StructTokenType.Equals)) { string constValue = lexer.GetNextToken(StructTokenType.String); lastValue = (uint) ExpressionParser.Parse(constValue).EvaluateInt(null); } else lastValue++; enumDef.AddValue(constName, lastValue); if (!lexer.CheckNextToken(StructTokenType.Comma)) { if (lexer.PeekNextToken() != StructTokenType.CloseCurly) throw new Exception("Unexpected token in enum: " + lexer.PeekNextToken()); } } _curStructFile.Add(enumDef); }