Beispiel #1
0
 public void Visit(IndirectEntry entry)
 {
     Print($"IND {entry.Offset}");
     _indent++;
     entry.Op1.Accept(this);
     _indent--;
 }
        public void Import(Instruction instruction, ImportContext context, IILImporterProxy importer)
        {
            var type = GetWellKnownType(instruction.OpCode.Code);
            var addr = importer.PopExpression();
            // TODO: Can this be optimised for I1 & I2??
            var node = new IndirectEntry(addr, StackValueKind.Int32, null); // type.GetWellKnownTypeSize());

            importer.PushExpression(node);
        }
Beispiel #3
0
        public void Import(Instruction instruction, ImportContext context, IILImporterProxy importer)
        {
            var fieldDefOrRef = instruction.Operand as IField;
            var fieldDef      = fieldDefOrRef.ResolveFieldDef();

            // Ensure fields have all offsets calculated
            if (fieldDef.FieldOffset == null)
            {
                fieldDef.DeclaringType.ToTypeSig().GetExactSize();
            }

            var fieldOffset = fieldDef.FieldOffset ?? 0;

            var obj = importer.PopExpression();

            if (obj.Kind == StackValueKind.ValueType)
            {
                if (obj is LocalVariableEntry)
                {
                    obj = new LocalVariableAddressEntry((obj.As <LocalVariableEntry>()).LocalNumber);
                }
                else if (obj is IndirectEntry)
                {
                    // If the object is itself an IndirectEntry e.g. resulting from a Ldfld
                    // then we should merge the Ldfld's together

                    // e.g. Ldfld SimpleVector::N
                    //      Ldfld Nested::Length
                    // will get converted into a single IndirectEntry node with the field offset
                    // being the combination of the field offsets for N and Length

                    var previousIndirect = obj.As <IndirectEntry>();
                    fieldOffset = previousIndirect.Offset + fieldOffset;
                    obj         = previousIndirect.Op1;
                }
            }

            if (obj.Kind != StackValueKind.ObjRef && obj.Kind != StackValueKind.ByRef && obj.Kind != StackValueKind.NativeInt)
            {
                throw new NotImplementedException($"LoadFieldImporter does not support {obj.Kind}");
            }

            var kind = fieldDef.FieldType.GetStackValueKind();
            var node = new IndirectEntry(obj, kind, fieldDef.FieldType.GetExactSize(), fieldOffset);

            importer.PushExpression(node);
        }
Beispiel #4
0
 public void Visit(IndirectEntry entry)
 {
     _sb.AppendLine($"       ┌──▌  t{entry.Op1.TreeID}");
     _sb.AppendLine($"       ind ${entry.Offset}");
 }
 public void Visit(IndirectEntry entry)
 {
     _genericStackEntryVisitor.Visit <IndirectEntry>(entry);
 }
Beispiel #6
0
 public void Visit(IndirectEntry entry)
 {
     entry.Op1.Accept(this);
     SetNext(entry);
 }