Example #1
0
        public void MultiClassInheritance2()
        {
            Variable d = DefaultModule.GetVariable("multiClassInheritanceTest2");

            Assert.Equal(42, (double)d.GetField("d"));
            Assert.Equal(42, (int)d.GetField("b"));
            Assert.Equal(42, (float)d.GetField("a"));
            Variable a = d.GetBaseClass("MultiClassInheritanceA");

            Assert.Equal(42, (float)a.GetField("a"));
            Variable b = d.GetBaseClass("MultiClassInheritanceB");

            Assert.Equal(42, (int)b.GetField("b"));
            Assert.Equal(d.GetPointerAddress(), a.DowncastInterface().GetPointerAddress());
            Assert.Equal(d.GetPointerAddress(), b.DowncastInterface().GetPointerAddress());

            if (ExecuteCodeGen)
            {
                InterpretInteractive($@"
Variable global = Process.Current.GetGlobal(""{DefaultModuleName}!multiClassInheritanceTest2"");
var d = new MultiClassInheritanceD(global);
var a = d.BaseClass_MultiClassInheritanceA;
var b = d.BaseClass_MultiClassInheritanceB;
AreEqual(42, d.d);
AreEqual(42, a.a);
AreEqual(42, b.b);
IsTrue(a.GetDowncast() is MultiClassInheritanceD);
IsTrue(b.GetDowncast() is MultiClassInheritanceD);
AreEqual(42, a.As<MultiClassInheritanceB>().b);
                    ");
            }
        }
Example #2
0
                /// <summary>
                /// Initializes a new instance of the <see cref="item" /> class.
                /// </summary>
                /// <param name="variable">The variable.</param>
                /// <param name="pairCodeType">The key value pair code type.</param>
                public item(Variable variable, CodeType pairCodeType)
                {
                    left = UserMember.Create(() =>
                    {
                        Variable field = variable.GetField("_M_left");

                        return(field.IsNullPointer() ? null : new item(field, pairCodeType));
                    });
                    right = UserMember.Create(() =>
                    {
                        Variable field = variable.GetField("_M_right");

                        return(field.IsNullPointer() ? null : new item(field, pairCodeType));
                    });
                    parent = UserMember.Create(() =>
                    {
                        Variable field = variable.GetField("_M_parent");

                        return(field.IsNullPointer() ? null : new item(field, pairCodeType));
                    });
                    pair = UserMember.Create(() =>
                    {
                        // Since we cannot get field with address to key value pair, do pointer arithmetic to find address
                        ulong pairAddress = variable.GetPointerAddress() + variable.GetCodeType().ElementType.Size;

                        return(new pair <TKey, TValue>(Variable.Create(pairCodeType, pairAddress)));
                    });
                }
Example #3
0
            /// <summary>
            /// Initializes a new instance of the <see cref="LibStdCpp6"/> class.
            /// </summary>
            /// <param name="variable">The variable.</param>
            public LibStdCpp6(Variable variable)
            {
                // Initialize members
                pointer                 = UserMember.Create(() => variable.GetField("_M_ptr"));
                element                 = UserMember.Create(() => pointer.Value.DereferencePointer().CastAs <T>());
                sharedCount             = UserMember.Create(() => (int)variable.GetField("_M_refcount").GetField("_M_pi").GetField("_M_use_count"));
                weakCount               = UserMember.Create(() => (int)variable.GetField("_M_refcount").GetField("_M_pi").GetField("_M_weak_count"));
                isCreatedWithMakeShared = UserMember.Create(() =>
                {
                    CodeType codeType = variable.GetField("_M_refcount").GetField("_M_pi").DowncastInterface().GetCodeType();

                    if (codeType.Name.StartsWith("std::_Sp_counted_ptr_inplace<"))
                    {
                        return(true);
                    }

                    if (!codeType.Name.StartsWith("std::_Sp_counted_deleter<"))
                    {
                        return(false);
                    }

                    try
                    {
                        codeType = (CodeType)codeType.TemplateArguments[1];
                        return(codeType.Name.StartsWith("std::__shared_ptr<") && codeType.Name.Contains("::_Deleter<"));
                    }
                    catch
                    {
                        return(false);
                    }
                });
            }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LibStdCpp6"/> class.
 /// </summary>
 /// <param name="variable">The variable.</param>
 public LibStdCpp6(Variable variable)
 {
     length      = UserMember.Create(() => (int)variable.GetField("_M_string_length"));
     text        = UserMember.Create(() => variable.GetField("_M_dataplus").GetField("_M_p"));
     localBuffer = UserMember.Create(() => variable.GetField("_M_local_buf"));
     capacity    = UserMember.Create(() => (int)variable.GetField("_M_allocated_capacity"));
 }
Example #5
0
        public void SimpleMultiClassInheritance()
        {
            Variable c = DefaultModule.GetVariable("simpleMultiClassInheritanceTest");

            Assert.Equal(42.0f, (float)c.GetField("c"));
            Assert.Equal(42.0, (double)c.GetField("b"));
            Assert.Equal(42, (byte)c.GetField("a"));
            Variable a = c.GetBaseClass("SimpleMultiClassInheritanceA");

            Assert.Equal(42, (byte)a.GetField("a"));
            Variable b = c.GetBaseClass("SimpleMultiClassInheritanceB");

            Assert.Equal(42.0, (double)b.GetField("b"));

            if (ExecuteCodeGen)
            {
                InterpretInteractive($@"
Variable global = Process.Current.GetGlobal(""{DefaultModuleName}!simpleMultiClassInheritanceTest"");
var c = new SimpleMultiClassInheritanceC(global);
AreEqual(42.0f, c.c);
AreEqual(42, c.BaseClass_SimpleMultiClassInheritanceA.a);
AreEqual(42.0, c.BaseClass_SimpleMultiClassInheritanceB.b);
                    ");
            }
        }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="item"/> class.
 /// </summary>
 /// <param name="variable">The variable.</param>
 public item(Variable variable)
 {
     isnil  = UserMember.Create(() => (bool)variable.GetField("_Isnil"));
     left   = UserMember.Create(() => new item(variable.GetField("_Left")));
     right  = UserMember.Create(() => new item(variable.GetField("_Right")));
     parent = UserMember.Create(() => new item(variable.GetField("_Parent")));
     pair   = UserMember.Create(() => new pair <TKey, TValue>(variable.GetField("_Myval")));
 }
Example #7
0
        public void VirtualMultiClassInheritance2()
        {
            Variable e = DefaultModule.GetVariable("virtualMultiClassInheritanceTest2");

            Assert.Equal(42, (int)e.GetField("e"));
            Assert.Equal(42, (double)e.GetField("b"));
            Assert.Equal(42, (float)e.GetField("c"));
            Assert.Equal(42, (sbyte)e.GetField("a"));
            Variable a = e.GetBaseClass("VirtualMultiClassInheritanceA");

            Assert.Equal(42, (sbyte)a.GetField("a"));
            Variable b = e.GetBaseClass("VirtualMultiClassInheritanceB");

            Assert.Equal(42, (double)b.GetField("b"));
            Variable ba = b.GetBaseClass("VirtualMultiClassInheritanceA");

            Assert.Equal(42, (sbyte)ba.GetField("a"));
            Variable c = e.GetBaseClass("VirtualMultiClassInheritanceC");

            Assert.Equal(42, (float)c.GetField("c"));
            Variable ca = c.GetBaseClass("VirtualMultiClassInheritanceA");

            Assert.Equal(42, (sbyte)ca.GetField("a"));
            Assert.Equal(a.GetPointerAddress(), ba.GetPointerAddress());
            Assert.Equal(ca.GetPointerAddress(), ba.GetPointerAddress());
            Assert.Equal(e.GetPointerAddress(), b.DowncastInterface().GetPointerAddress());
            Assert.Equal(ba.GetPointerAddress(), ba.DowncastInterface().GetPointerAddress());
            Assert.Equal(e.GetPointerAddress(), c.DowncastInterface().GetPointerAddress());
            Assert.Equal(ca.GetPointerAddress(), ca.DowncastInterface().GetPointerAddress());

            if (ExecuteCodeGen)
            {
                InterpretInteractive($@"
Variable global = Process.Current.GetGlobal(""{DefaultModuleName}!virtualMultiClassInheritanceTest2"");
var e = new VirtualMultiClassInheritanceE(global);
var a = e.BaseClass_VirtualMultiClassInheritanceA;
var b = e.BaseClass_VirtualMultiClassInheritanceB;
var ba = b.BaseClass;
var c = e.BaseClass_VirtualMultiClassInheritanceC;
var ca = c.BaseClass;
AreEqual(42, e.e);
AreEqual(42, a.a);
AreEqual(42, b.b);
AreEqual(42, ba.a);
AreEqual(42, c.c);
AreEqual(42, ca.a);
IsTrue(a.GetDowncast() is VirtualMultiClassInheritanceE);
IsTrue(b.GetDowncast() is VirtualMultiClassInheritanceE);
IsTrue(ba.GetDowncast() is VirtualMultiClassInheritanceE);
IsTrue(c.GetDowncast() is VirtualMultiClassInheritanceE);
IsTrue(ca.GetDowncast() is VirtualMultiClassInheritanceE);
AreEqual(42, b.As<VirtualMultiClassInheritanceC>().c);
AreEqual(42, a.As<VirtualMultiClassInheritanceB>().b);
AreEqual(42, ba.As<VirtualMultiClassInheritanceC>().c);
AreEqual(42, ca.As<VirtualMultiClassInheritanceB>().b);
                    ");
            }
        }
Example #8
0
            /// <summary>
            /// Initializes a new instance of the <see cref="LibStdCpp6"/> class.
            /// </summary>
            /// <param name="variable">The variable.</param>
            public LibStdCpp6(Variable variable)
            {
                CodeType codeType         = variable.GetCodeType();
                CodeType templateCodeType = (CodeType)codeType.TemplateArguments[0];
                CodeType intCodeType      = (CodeType)codeType.GetFieldType("_M_impl").GetFieldType("_M_node").GetFieldType("_M_storage").TemplateArguments[0];

                count = UserMember.Create(() => new list <int> .LibStdCpp6.item(variable.GetField("_M_impl").GetField("_M_node"), intCodeType).Value);
                head  = UserMember.Create(() => new item(variable.GetField("_M_impl").GetField("_M_node"), templateCodeType).Next);
            }
Example #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClangLibCpp"/> class.
 /// </summary>
 /// <param name="variable">The variable.</param>
 public ClangLibCpp(Variable variable)
 {
     // Initialize members
     pointer                 = UserMember.Create(() => variable.GetField("__ptr_"));
     element                 = UserMember.Create(() => pointer.Value.DereferencePointer().CastAs <T>());
     sharedCount             = UserMember.Create(() => (int)variable.GetField("__cntrl_").GetField("__shared_owners_") + 1);
     weakCount               = UserMember.Create(() => (int)variable.GetField("__cntrl_").GetField("__shared_weak_owners_") + 1);
     isCreatedWithMakeShared = UserMember.Create(() => variable.GetField("__cntrl_").DowncastInterface().GetCodeType().Name.StartsWith("std::__1::__shared_ptr_emplace<"));
 }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VisualStudio"/> class.
 /// </summary>
 /// <param name="variable">The variable.</param>
 public LibStdCpp6(Variable variable)
 {
     // Initialize members
     pointer                 = UserMember.Create(() => variable.GetField("_M_ptr"));
     element                 = UserMember.Create(() => pointer.Value.DereferencePointer().CastAs <T>());
     sharedCount             = UserMember.Create(() => (int)variable.GetField("_M_refcount").GetField("_M_pi").GetField("_M_use_count"));
     weakCount               = UserMember.Create(() => (int)variable.GetField("_M_refcount").GetField("_M_pi").GetField("_M_weak_count"));
     isCreatedWithMakeShared = UserMember.Create(() => variable.GetField("_M_refcount").GetField("_M_pi").DowncastInterface().GetCodeType().Name.StartsWith("std::_Sp_counted_ptr_inplace<"));
 }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VisualStudio"/> class.
 /// </summary>
 /// <param name="variable">The variable.</param>
 public VisualStudio(Variable variable)
 {
     // Initialize members
     pointer                 = UserMember.Create(() => variable.GetField("_Ptr"));
     element                 = UserMember.Create(() => pointer.Value.DereferencePointer().CastAs <T>());
     sharedCount             = UserMember.Create(() => (int)variable.GetField("_Rep").GetField("_Uses"));
     weakCount               = UserMember.Create(() => (int)variable.GetField("_Rep").GetField("_Weaks"));
     isCreatedWithMakeShared = UserMember.Create(() => variable.GetField("_Rep").DowncastInterface().GetCodeType().Name.StartsWith("std::_Ref_count_obj<"));
 }
Example #12
0
        public void NullValueOkTest()
        {
            IClrThread clrThread = Thread.Current.ClrThread;
            StackFrame frame     = clrThread.ClrStackTrace.Frames.Where(f => f.FunctionNameWithoutModule.StartsWith("Program.Main(")).Single();
            Variable   fooObject = frame.Locals["containsnullref"];

            Assert.Equal(42, (int)fooObject.GetField("SetValue").GetField("i"));
            Assert.True(fooObject.GetField("NullValue").IsNull());
            Assert.Contains(fooObject, clrThread.EnumerateStackObjects());
        }
Example #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="pair{TFirst, TSecond}"/> class.
        /// </summary>
        /// <param name="variable">The variable.</param>
        /// <exception cref="WrongCodeTypeException">std::pair</exception>
        public pair(Variable variable)
        {
            // Verify code type
            if (!VerifyCodeType(variable.GetCodeType()))
            {
                throw new WrongCodeTypeException(variable, nameof(variable), "std::pair");
            }

            // Initialize members
            first  = UserMember.Create(() => variable.GetField("first").CastAs <TFirst>());
            second = UserMember.Create(() => variable.GetField("second").CastAs <TSecond>());
        }
Example #14
0
        public void ReadingFloatPointTypes()
        {
            Variable doubleTest = DefaultModule.GetVariable("doubleTest");

            Assert.AreEqual(3.5, (double)doubleTest.GetField("d"));
            Assert.AreEqual(2.5, (float)doubleTest.GetField("f"));
            Assert.AreEqual(5, (int)doubleTest.GetField("i"));

            Variable doubleTest2 = Process.Current.GetGlobal($"{DefaultModuleName}!doubleTest");

            Assert.AreEqual(doubleTest.GetPointerAddress(), doubleTest2.GetPointerAddress());
            Assert.AreEqual(doubleTest.GetCodeType(), doubleTest2.GetCodeType());
        }
Example #15
0
        public void GetFieldTests()
        {
            IClrThread clrThread = Thread.Current.ClrThread;
            StackFrame frame     = clrThread.ClrStackTrace.Frames.Where(f => f.FunctionNameWithoutModule.StartsWith("Program.Main(")).Single();
            Variable   foo       = frame.Locals["foo"];

            Assert.Equal("Foo", foo.GetCodeType().Name);
            Assert.True((bool)foo.GetField("b"));

            Variable inner = foo.GetField("st").GetField("middle").GetField("inner");

            Assert.True((bool)inner.GetField("b"));
        }
Example #16
0
        public void FieldNameAndValueTests()
        {
            IClrHeap heap        = Process.Current.ClrRuntimes.Single().Heap;
            Module   typesModule = Module.All.Single(m => m.Name == "Types");
            CodeType fooType     = CodeType.Create("Foo", typesModule);
            Variable s_foo       = typesModule.GetVariable("Types.s_foo");

            Assert.Equal(fooType, s_foo.GetCodeType());
            Assert.Equal(42, (int)s_foo.GetField("i"));
            Assert.Equal("string", new ClrString(s_foo.GetField("s")).Text);
            Assert.True((bool)s_foo.GetField("b"));
            Assert.Equal(4.2f, (float)s_foo.GetField("f"));
            Assert.Equal(8.4, (double)s_foo.GetField("d"));
            Assert.Contains(s_foo, heap.EnumerateObjects());
        }
Example #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="shared_ptr{T}"/> class.
        /// </summary>
        /// <param name="variable">The variable.</param>
        public shared_ptr(Variable variable)
        {
            // Verify code type
            if (!VerifyCodeType(variable.GetCodeType()))
            {
                throw new WrongCodeTypeException(variable, nameof(variable), "std::shared_ptr");
            }

            // Initialize members
            pointer                 = UserMember.Create(() => variable.GetField("_Ptr"));
            element                 = UserMember.Create(() => pointer.Value.DereferencePointer().CastAs <T>());
            sharedCount             = UserMember.Create(() => (int)variable.GetField("_Rep").GetField("_Uses"));
            weakCount               = UserMember.Create(() => (int)variable.GetField("_Rep").GetField("_Weaks"));
            isCreatedWithMakeShared = UserMember.Create(() => variable.GetField("_Rep").DowncastInterface().GetCodeType().Name.StartsWith("std::_Ref_count_obj<"));
        }
Example #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LibStdCpp6" /> class.
 /// </summary>
 /// <param name="variable">The variable.</param>
 public LibStdCpp6(Variable variable)
 {
     value = UserMember.Create(() => variable.GetField("_M_impl"));
     first = UserMember.Create(() => Value.GetField("_M_start"));
     last  = UserMember.Create(() => Value.GetField("_M_finish"));
     end   = UserMember.Create(() => Value.GetField("_M_end_of_storage"));
 }
Example #19
0
        /// <summary>
        /// Extracts fields of the object that will be visualized in [Expanded] group.
        /// </summary>
        /// <returns></returns>
        private IEnumerable <IResultVisualizer> ExtractFields()
        {
            CodeType codeType = variable.GetCodeType();

            if (extractUsingClasses)
            {
                foreach (string baseClass in codeType.InheritedClasses.Keys)
                {
                    object   baseClassValue    = GetValue(() => variable.GetBaseClass(baseClass));
                    Variable baseClassVariable = baseClassValue as Variable;

                    if (baseClassVariable != null)
                    {
                        yield return(new VariableResultVisualizer(baseClassVariable, typeof(Variable), $"[{baseClass}]", CompletionDataType.Class, interactiveResultVisualizer));
                    }
                    else
                    {
                        yield return(Create(baseClassValue, typeof(Variable), $"[{baseClass}]", CompletionDataType.Class, interactiveResultVisualizer));
                    }
                }

                foreach (string fieldName in codeType.ClassFieldNames)
                {
                    yield return(Create(GetValue(() => variable.GetClassField(fieldName)), typeof(Variable), fieldName, CompletionDataType.Variable, interactiveResultVisualizer));
                }
            }
            else
            {
                foreach (string fieldName in codeType.FieldNames)
                {
                    yield return(Create(GetValue(() => variable.GetField(fieldName)), typeof(Variable), fieldName, CompletionDataType.Variable, interactiveResultVisualizer));
                }
            }
        }
Example #20
0
        public void InteriorStructTest()
        {
            IClrThread clrThread = Thread.Current.ClrThread;
            StackFrame frame     = clrThread.ClrStackTrace.Frames.Where(f => f.FunctionNameWithoutModule.StartsWith("Program.Main(")).Single();
            Variable   s         = frame.Locals["s"];

            Assert.Equal("Struct", s.GetCodeType().Name);
            CheckStruct(s);

            s = s.GetField("middle");
            Assert.Equal("MiddleStruct", s.GetCodeType().Name);
            CheckStruct(s);

            s = s.GetField("inner");
            Assert.Equal("InnerStruct", s.GetCodeType().Name);
            CheckStruct(s);
        }
Example #21
0
            /// <summary>
            /// Initializes a new instance of the <see cref="LibStdCpp6_NoAbi"/> class.
            /// </summary>
            /// <param name="variable">The variable.</param>
            public LibStdCpp6_NoAbi(Variable variable)
            {
                CodeType codeType = variable.GetCodeType();
                CodeType _Rep     = CodeType.Create($"{codeType.Name}::_Rep", codeType.Module);

                header   = UserMember.Create(() => text.Value.AdjustPointer(-(int)_Rep.Size).CastAs(_Rep));
                length   = UserMember.Create(() => (int)header.Value.GetField("_M_length"));
                text     = UserMember.Create(() => variable.GetField("_M_dataplus").GetField("_M_p"));
                capacity = UserMember.Create(() => (int)header.Value.GetField("_M_capacity"));
            }
Example #22
0
        public void ObjectArgumentAndLocalTest()
        {
            ClrThread  clrThread = Thread.Current.FindClrThread();
            StackFrame frame     = clrThread.ClrStackTrace.Frames.Where(f => f.FunctionNameWithoutModule.StartsWith("Program.Main(")).Single();
            Variable   args      = frame.Arguments.Single();

            Assert.IsNotNull(args);
            Assert.AreEqual("System.String[]", args.GetCodeType().Name);
            Assert.AreEqual("args", args.GetName());

            Variable foo = frame.Locals.Single();

            Assert.IsNotNull(foo);
            Assert.IsFalse(foo.IsNullPointer());
            Assert.AreEqual("Foo", foo.GetCodeType().Name);
            Assert.AreEqual("foo", foo.GetName());

            Assert.AreEqual(8.4, (double)foo.GetField("d"));
            Assert.AreEqual("Foo string", new ClrString(foo.GetField("FooString")).Text);
        }
Example #23
0
            /// <summary>
            /// Initializes a new instance of the <see cref="LibStdCpp6"/> class.
            /// </summary>
            /// <param name="variable">The variable.</param>
            public LibStdCpp6(Variable variable)
            {
                buckets = UserMember.Create(() =>
                {
                    Variable h = variable.GetField("_M_h");
                    Variable b = h.GetField("_M_buckets");
                    int count  = (int)h.GetField("_M_bucket_count");

                    elementCodeType = (CodeType)h.GetCodeType().TemplateArguments[1];
                    return(new CodeArray <Variable>(b, count));
                });
                beforeBegin = UserMember.Create(() =>
                {
                    Variable h = variable.GetField("_M_h");

                    elementCodeType = (CodeType)h.GetCodeType().TemplateArguments[1];
                    return(h.GetField("_M_before_begin"));
                });
                elementCount = UserMember.Create(() => (int)variable.GetField("_M_h").GetField("_M_element_count"));
            }
Example #24
0
            /// <summary>
            /// Initializes a new instance of the <see cref="LibStdCpp6"/> class.
            /// </summary>
            /// <param name="variable">The variable.</param>
            public LibStdCpp6(Variable variable)
            {
                value = UserMember.Create(() =>
                {
                    Variable t = variable.GetField("_M_t");

                    pairCodeType = (CodeType)t.GetCodeType().TemplateArguments[1];
                    return(t.GetField("_M_impl"));
                });
                size = UserMember.Create(() => (int)Value.GetField("_M_node_count"));
                root = UserMember.Create(() => new item(Value.GetField("_M_header"), pairCodeType).Parent);
            }
Example #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="list{T}"/> class.
        /// </summary>
        /// <param name="variable">The variable.</param>
        public list(Variable variable)
        {
            // Verify code type
            if (!VerifyCodeType(variable.GetCodeType()))
            {
                throw new Exception("Wrong code type of passed variable " + variable.GetCodeType().Name);
            }

            // Initialize members
            value  = UserMember.Create(() => variable.GetField("_Mypair").GetField("_Myval2"));
            length = UserMember.Create(() => (int)Value.GetField("_Mysize"));
            head   = UserMember.Create(() => new item(Value.GetField("_Myhead")));
        }
Example #26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="basic_string"/> class.
        /// </summary>
        /// <param name="variable">The variable.</param>
        public basic_string(Variable variable)
        {
            // Verify code type
            if (!VerifyCodeType(variable.GetCodeType()))
            {
                throw new Exception("Wrong code type of passed variable " + variable.GetCodeType().Name);
            }

            // Initialize members
            value    = UserMember.Create(() => variable.GetField("_Mypair").GetField("_Myval2"));
            length   = UserMember.Create(() => (int)Value.GetField("_Mysize"));
            reserved = UserMember.Create(() => (int)Value.GetField("_Myres"));
            text     = UserMember.Create(GetText);
        }
Example #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="vector{T}"/> class.
        /// </summary>
        /// <param name="variable">The variable.</param>
        public vector(Variable variable)
        {
            // Verify code type
            if (!VerifyCodeType(variable.GetCodeType()))
            {
                throw new Exception("Wrong code type of passed variable " + variable.GetCodeType().Name);
            }

            // Initialize members
            value = UserMember.Create(() => variable.GetField("_Mypair").GetField("_Myval2"));
            first = UserMember.Create(() => Value.GetField("_Myfirst"));
            last  = UserMember.Create(() => Value.GetField("_Mylast"));
            end   = UserMember.Create(() => Value.GetField("_Myend"));
        }
Example #28
0
 private static void CheckStruct(Variable s)
 {
     Assert.Equal(42, (int)s.GetField("i"));
     Assert.Equal("string", new ClrString(s.GetField("s")).Text);
     Assert.True((bool)s.GetField("b"));
     Assert.Equal(4.2f, (float)s.GetField("f"));
     Assert.Equal(8.4, (double)s.GetField("d"));
     Assert.Equal("System.Object", s.GetField("o").GetCodeType().Name);
 }
Example #29
0
            /// <summary>
            /// Enumerates this unordered_map.
            /// </summary>
            private IEnumerable <KeyValuePair <TKey, TValue> > Enumerate()
            {
                //foreach (Variable bucket in buckets.Value)
                Variable bucket = beforeBegin.Value;
                {
                    Variable element = bucket;

                    while (element != null && !element.IsNullPointer())
                    {
                        if (element.GetPointerAddress() != beforeBegin.Value.GetPointerAddress())
                        {
                            ulong itemAddress        = element.GetPointerAddress() + element.GetCodeType().ElementType.Size;
                            pair <TKey, TValue> item = new pair <TKey, TValue>(Variable.Create(elementCodeType, itemAddress));

                            yield return(new KeyValuePair <TKey, TValue>(item.First, item.Second));
                        }
                        element = element.GetField("_M_nxt");
                    }
                }
            }
Example #30
0
            /// <summary>
            /// Initializes a new instance of the <see cref="LibStdCpp6_NoAbi"/> class.
            /// </summary>
            /// <param name="variable">The variable.</param>
            public LibStdCpp6_NoAbi(Variable variable)
            {
                CodeType codeType         = variable.GetCodeType();
                CodeType templateCodeType = (CodeType)codeType.TemplateArguments[0];
                CodeType listNodeCodeType = GetListNodeCodeType(codeType);

                count = UserMember.Create(() =>
                {
                    int count      = 0;
                    Variable start = anchor.Value;
                    Variable next  = start.GetField("_M_next");

                    while (next.GetPointerAddress() != start.GetPointerAddress())
                    {
                        next = next.GetField("_M_next");
                        count++;
                    }
                    return(count);
                });
                anchor = UserMember.Create(() => variable.GetField("_M_impl").GetField("_M_node"));
                head   = UserMember.Create(() => new item(anchor.Value.GetField("_M_next").CastAs(listNodeCodeType), templateCodeType));
            }
Example #31
0
 private static void CheckStruct(Variable s)
 {
     Assert.AreEqual(42, (int)s.GetField("i"));
     Assert.AreEqual("string", new ClrString(s.GetField("s")).Text);
     Assert.AreEqual(true, (bool)s.GetField("b"));
     Assert.AreEqual(4.2f, (float)s.GetField("f"));
     Assert.AreEqual(8.4, (double)s.GetField("d"));
     Assert.AreEqual("System.Object", s.GetField("o").GetCodeType().Name);
 }
Example #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VisualStudio2015"/> class.
 /// </summary>
 /// <param name="variable">The variable.</param>
 public VisualStudio2015(Variable variable)
     : base(UserMember.Create(() => variable.GetField("_Mypair").GetField("_Myval2")))
 {
 }