Beispiel #1
0
        public override void SetupByOffset()
        {
            for (int i = 0; i < Selectors.Length; i++)
            {
                ShortElement c   = (ShortElement)Selectors[i];
                var          val = c.Value;

                var target = _script.GetElement(val);
                if (target != null && target is StringConst) //  || (target is StringPart)
                {
                    var r = new RefToElement(_script, c.Address, c.Value)
                    {
                        Source = this
                    };
                    c.ReplaceBy(r);
                    Selectors[i] = r;
                    r.SetupByOffset();
                }
            }

            {
                if (Selectors[3] is ShortElement s)
                {
                    StringPart p = _script.GetStringPart(s.Value);
                    if (p != null)
                    {
                        _script.Register(p);
                        var r = new RefToElement(_script, s.Address, s.Value)
                        {
                            Source = this
                        };
                        s.ReplaceBy(r);
                        Selectors[3] = r;
                        r.SetupByOffset();
                    }
                }
            }

            var nameRef = (Selectors[3] as RefToElement)?.Reference;

            if (nameRef != null)
            {
                if (nameRef is StringConst s)
                {
                    Name          = s.Value;
                    s.IsClassName = true;
                }
                else if (nameRef is StringPart p)
                {
                    Name = p.String;
                    p.OrigString.IsClassName = true;
                }
            }

            foreach (var r in FuncCode)
            {
                r.SetupByOffset();
            }
        }
        public override void Read(byte[] data, ushort offset, int length)
        {
            int cnt = ReadShortBE(data, ref offset);

            Refs = new RefToElement[cnt];

            offset += 2;
            for (int i = 0; i < cnt; i++)
            {
                var    addr = offset;
                ushort val  = ReadShortBE(data, ref offset);
                Refs[i] = new RefToElement(_script, addr, val)
                {
                    Source = this
                };
            }
        }
 public override void SetupByOffset()
 {
     for (int i = 0; i < Vars.Length; i++)
     {
         ushort val = (ushort)Vars[i];
         var    el  = _script.GetElement(val);
         if (el is StringConst)
         {
             var r = new RefToElement(_script, (ushort)(Address + i * 2), val)
             {
                 Source = this
             };
             r.SetupByOffset();
             Vars[i] = r;
         }
     }
 }