Beispiel #1
0
        public override bool IsComplete(Assembler aAssembler)
        {
            if (RawAsm != null)
            {
                return(true);
            }

            if (UntypedDefaultValue != null && UntypedDefaultValue.Length > 0)
            {
                foreach (var xReference in (from item in UntypedDefaultValue
                                            let xRef = item as ElementReference
                                                       where xRef != null
                                                       select xRef))
                {
                    var xRef = aAssembler.TryResolveReference(xReference);

                    if (xRef == null)
                    {
                        return(false);
                    }

                    if (!xRef.IsComplete(aAssembler))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Beispiel #2
0
 public override void WriteData(Assembler aAssembler, Stream aOutput)
 {
     if (UntypedDefaultValue != null && UntypedDefaultValue.Length > 0)
     {
         for (int i = 0; i < UntypedDefaultValue.Length; i++)
         {
             var xRef = UntypedDefaultValue[i] as ElementReference;
             if (xRef != null)
             {
                 var xTheRef = aAssembler.TryResolveReference(xRef);
                 if (xTheRef == null)
                 {
                     throw new Exception("Reference not found!");
                 }
                 if (!xTheRef.ActualAddress.HasValue)
                 {
                     Console.Write("");
                 }
                 aOutput.Write(BitConverter.GetBytes(xTheRef.ActualAddress.Value), 0, 4);
             }
             else
             {
                 if (UntypedDefaultValue[i] is int)
                 {
                     aOutput.Write(BitConverter.GetBytes((int)UntypedDefaultValue[i]), 0, 4);
                 }
                 else
                 {
                     if (UntypedDefaultValue[i] is uint)
                     {
                         aOutput.Write(BitConverter.GetBytes((uint)UntypedDefaultValue[i]), 0, 4);
                     }
                     else
                     {
                         throw new Exception("Invalid value inside UntypedDefaultValue");
                     }
                 }
             }
         }
     }
     else
     {
         aOutput.Write(RawDefaultValue, 0, RawDefaultValue.Length);
     }
 }