Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 private void InitBaseEnum()
 {
     if (_baseEnum == null)
     {
         _baseEnum = _structFile.GetEnumByName(_inherit);
         if (_baseEnum == null)
         {
             throw new LoadDataException("Base enum " + _inherit + " not found");
         }
     }
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public EnumEvaluateContext(IEvaluateContext context, EnumDef def, bool set)
     : base(context)
 {
     _def = def;
     _set = set;
 }
Exemplo n.º 5
0
 public void Add(EnumDef def)
 {
     _enumDefs.Add(def);
 }
Exemplo n.º 6
0
 private void InitBaseEnum()
 {
     if (_baseEnum == null)
     {
         _baseEnum = _structFile.GetEnumByName(_inherit);
         if (_baseEnum == null)
             throw new LoadDataException("Base enum " + _inherit + " not found");
     }
 }
Exemplo n.º 7
0
 public EnumEvaluateContext(IEvaluateContext context, EnumDef def, bool set) : base(context)
 {
     _def = def;
     _set = set;
 }
Exemplo n.º 8
0
        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);
        }