1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.Collections.Generic; 6 7 using ILCompiler.DependencyAnalysisFramework; 8 9 using Debug = System.Diagnostics.Debug; 10 11 namespace ILCompiler.DependencyAnalysis 12 { 13 public abstract class EmbeddedObjectNode : SortableDependencyNode 14 { 15 private const int InvalidOffset = int.MinValue; 16 17 private int _offset; 18 private int _index; 19 20 public IHasStartSymbol ContainingNode { get; set; } 21 EmbeddedObjectNode()22 public EmbeddedObjectNode() 23 { 24 _offset = InvalidOffset; 25 _index = InvalidOffset; 26 } 27 28 public int OffsetFromBeginningOfArray 29 { 30 get 31 { 32 Debug.Assert(_offset != InvalidOffset); 33 return _offset; 34 } 35 } 36 37 public int IndexFromBeginningOfArray 38 { 39 get 40 { 41 Debug.Assert(_index != InvalidOffset); 42 return _index; 43 } 44 } 45 InitializeOffsetFromBeginningOfArray(int offset)46 internal void InitializeOffsetFromBeginningOfArray(int offset) 47 { 48 Debug.Assert(_offset == InvalidOffset || _offset == offset); 49 _offset = offset; 50 } 51 InitializeIndexFromBeginningOfArray(int index)52 internal void InitializeIndexFromBeginningOfArray(int index) 53 { 54 Debug.Assert(_index == InvalidOffset || _index == index); 55 _index = index; 56 } 57 58 public virtual bool IsShareable => false; 59 public virtual bool RepresentsIndirectionCell => false; 60 61 public override bool InterestingForDynamicDependencyAnalysis => false; 62 public override bool HasDynamicDependencies => false; 63 public override bool HasConditionalStaticDependencies => false; 64 65 public override IEnumerable<CombinedDependencyListEntry> GetConditionalStaticDependencies(NodeFactory factory) => null; SearchDynamicDependencies(List<DependencyNodeCore<NodeFactory>> markedNodes, int firstNode, NodeFactory factory)66 public override IEnumerable<CombinedDependencyListEntry> SearchDynamicDependencies(List<DependencyNodeCore<NodeFactory>> markedNodes, int firstNode, NodeFactory factory) => null; 67 EncodeData(ref ObjectDataBuilder dataBuilder, NodeFactory factory, bool relocsOnly)68 public abstract void EncodeData(ref ObjectDataBuilder dataBuilder, NodeFactory factory, bool relocsOnly); 69 } 70 } 71