Example #1
0
        public bool AddClass(DcClass dclass)
        {
            if (dclass.Name != string.Empty)
            {
                if (!_thingsByName.TryAdd(dclass.Name, dclass))
                {
                    return(false);
                }
            }

            if (!dclass.IsStruct)
            {
                _classesById[NumClasses] = dclass;
                dclass.Number            = NumClasses;
            }

            _classes.Add(dclass);

            if (dclass.Bogus)
            {
                _allObjectsValid = false;
            }

            if (!dclass.Bogus)
            {
                _declarations.Add(dclass);
            }
            else
            {
                _thingsToDelete.Add(dclass);
            }

            return(true);
        }
Example #2
0
        public override void EnterClass_declaration(DcParser.Class_declarationContext context)
        {
            _currentClass = new DcClass(_dcFile, context.name.Text, false, false);

            // Add all our parents
            var parents = context.parents;

            while (parents != null)
            {
                if (!_dcFile.TryGetClassByName(parents.name.Text, out var parent))
                {
                    throw new Exception($"Unknown parent: {parents.name.Text}");
                }

                _currentClass.AddParent(parent);
                parents = parents.next;
            }
        }
Example #3
0
        public DcField(string name, DcClass dclass) : base(name)
        {
            KeywordList = new DcKeywordList();
            Class       = dclass;

            Number            = -1;
            HasDefaultValue   = false;
            DefaultValueStale = true;

            Bogus = false;

            HasNestedFields = true;
            NumNestedFields = 0;
            PackType        = DcPackType.Field;

            HasFixedByteSize  = true;
            FixedByteSize     = 0;
            HasFixedStructure = true;
        }
        public DcClassParameter(DcClass dcClass) : base()
        {
            _dclass       = dcClass;
            _nestedFields = new List <DcPackerInterface>();
            Name          = _dclass.Name;

            var numFields = _dclass.NumInheritedFields;

            if (_dclass.Constructor != null)
            {
                _nestedFields.Add(_dclass.Constructor);
                HasDefaultValue = HasDefaultValue || _dclass.Constructor.HasDefaultValue;
            }

            for (var i = 0; i < numFields; i++)
            {
                var field = _dclass.GetInheritedField(i);
                if (!(field is DcMolecularField))
                {
                    _nestedFields.Add(field);
                    HasDefaultValue = HasDefaultValue || field.HasDefaultValue;
                }
            }

            NumNestedFields = _nestedFields.Count;

            HasFixedByteSize  = true;
            FixedByteSize     = 0;
            HasFixedStructure = true;
            for (var i = 0; i < NumNestedFields; i++)
            {
                var field = _nestedFields[i];

                HasFixedByteSize  = HasFixedByteSize && field.HasFixedByteSize;
                FixedByteSize    += field.FixedByteSize;
                HasFixedStructure = HasFixedStructure && field.HasFixedStructure;
                HasRangeLimits    = HasRangeLimits || field.HasRangeLimits;
            }
        }
Example #5
0
 public override void ExitStruct_declaration(DcParser.Struct_declarationContext context)
 {
     _dcFile.AddClass(_currentClass);
     _currentClass = null;
 }
Example #6
0
 public override void EnterStruct_declaration(DcParser.Struct_declarationContext context)
 {
     _currentClass = new DcClass(_dcFile, context.name.Text, true, false);
 }
Example #7
0
 public bool TryGetClassById(int id, out DcClass dclass)
 {
     dclass = GetClassById(id);
     return(dclass != null);
 }
Example #8
0
 public bool TryGetClassByName(string name, out DcClass dclass)
 {
     dclass = GetClassByName(name);
     return(dclass != null);
 }
Example #9
0
 /// <summary>
 /// Adds a parent <c>DcClass</c> to the <c>DcClass</c>
 /// </summary>
 /// <param name="parent">The parent</param>
 public void AddParent(DcClass parent)
 {
     _parents.Add(parent);
     File?.MarkInheritedFieldsStale();
 }
Example #10
0
 public DcAtomicField(string name, DcClass dclass, bool isBogus) : base(name, dclass)
 {
     _elements = new List <DcParameter>();
     Bogus     = isBogus;
 }
Example #11
0
 public DcMolecularField(string name, DcClass dclass) : base(name, dclass)
 {
     _fields = new List <DcAtomicField>();
 }