Example #1
0
        public void StackReturn(DataType dt)
        {
            var stg = new StackArgumentStorage(stackOffset, dt);

            stackOffset += Align(dt.Size, stackAlignment);
            this.Return  = stg;
        }
Example #2
0
        public void StackParam(DataType dt)
        {
            var stg = new StackArgumentStorage(stackOffset, dt);

            stackOffset += Align(dt.Size, stackAlignment);
            Parameters.Add(stg);
        }
Example #3
0
        public override bool Equals(object obj)
        {
            StackArgumentStorage sas = obj as StackArgumentStorage;

            if (sas == null)
            {
                return(false);
            }
            return(StackOffset == sas.StackOffset);
        }
Example #4
0
 public Identifier FindStackArgument(int offset, int size)
 {
     foreach (Identifier id in identifiers)
     {
         StackArgumentStorage s = id.Storage as StackArgumentStorage;
         if (s != null && s.StackOffset == offset && id.DataType.Size == size)
         {
             return(id);
         }
     }
     return(null);
 }
Example #5
0
 public Expression VisitStackArgumentStorage(StackArgumentStorage stack)
 {
     if (ensureVariables)
     {
         return(frame.EnsureStackVariable(
                    stack.StackOffset - (site.StackDepthOnEntry + sigCallee.ReturnAddressOnStack),
                    stack.DataType));
     }
     else
     {
         return(arch.CreateStackAccess(frame, stack.StackOffset, stack.DataType));
     }
 }
Example #6
0
        public override int OffsetOf(Storage stgSub)
        {
            StackArgumentStorage arg = stgSub as StackArgumentStorage;

            if (arg == null)
            {
                return(-1);
            }
            if (arg.StackOffset >= StackOffset && arg.StackOffset + arg.DataType.Size <= StackOffset + DataType.Size)
            {
                return((arg.StackOffset - StackOffset) * DataType.BitsPerByte);
            }
            return(-1);
        }
Example #7
0
        /// <summary>
        /// Returns the number of bytes the stack arguments consume on the stack.
        /// </summary>
        /// <returns></returns>
        public int GetStackArgumentSpace()
        {
            int cbMax = 0;

            foreach (Identifier id in identifiers)
            {
                StackArgumentStorage sa = id.Storage as StackArgumentStorage;
                if (sa == null)
                {
                    continue;
                }
                cbMax = Math.Max(cbMax, sa.StackOffset + sa.DataType.Size);
            }
            return(cbMax);
        }
Example #8
0
 public Expression VisitStackArgumentStorage(StackArgumentStorage stack)
 {
     if (ensureVariables)
     {
         return(binder.EnsureStackVariable(
                    stack.StackOffset - site.StackDepthOnEntry,
                    stack.DataType));
     }
     else
     {
         return(arch.CreateStackAccess(
                    binder,
                    stack.StackOffset - site.SizeOfReturnAddressOnStack,
                    stack.DataType));
     }
 }
Example #9
0
        /// <summary>
        /// The offset of a variable from the return address, as seen from a caller.
        /// </summary>
        /// <param name="var"></param>
        /// <returns></returns>
        public int ExternalOffset(Identifier id)
        {
            if (id == null)
            {
                return(0);
            }
            StackArgumentStorage stVar = id.Storage as StackArgumentStorage;

            if (stVar != null)
            {
                return(stVar.StackOffset);
            }
            FpuStackStorage fstVar = id.Storage as FpuStackStorage;

            if (fstVar != null)
            {
                return(fstVar.FpuStackOffset);
            }

            throw new ArgumentOutOfRangeException("var", "Variable must be an argument.");
        }
Example #10
0
 Identifier StorageVisitor <Identifier> .VisitStackArgumentStorage(StackArgumentStorage stack)
 {
     throw new NotImplementedException();
 }