/* test if VES uses correct sizes for value type write to static field */ public static int test_0_static_nullable_bool() { s_struct1 = new AStruct(0x1337dead); s_nullb = true; /* make sure that the write to s_nullb didn't smash the value after it */ if (s_struct1.i != 0x1337dead) { return(2); } return(0); }
public object vtypes1(AStruct s, AStruct[] arr) { if (arr != null) { return(this); } else { return(null); } }
public object vtypes1(AStruct s, AStruct[] arr, TypedReference typedref) { if (arr != null) { return(this); } else { return(null); } }
internal override void doExpand(TreeNode myNode, EbxDataContainers ebx, TreeSettings settings) { foreach (var container in containers) { AStruct dataRoot = settings.flattened ? ebx.getFlattenedDataFor(container.guid) : container.data; var fieldName = settings.showGuids ? container.guid : ""; var tnode = processField(fieldName, dataRoot, ebx, settings); myNode.Nodes.Add(tnode); guidToTreeNode.Add(container.guid, tnode); } }
public static void Main(string[] args) { AStruct a = new AStruct(); modify(ref a); Console.WriteLine(a.x); //Êä³ö1 BClass b = new BClass(); modify(ref b); Console.WriteLine(b.x); //Êä³ö0 }
public void CallMethodOnStruct() { var param = Expression.Parameter(typeof(AStruct), "s"); var compiled = Expression.Lambda <Func <AStruct, string> > ( Expression.Call(param, typeof(AStruct).GetMethod(nameof(AStruct.GetValue))), param ).Compile(); var s = new AStruct("foo"); Assert.AreEqual("foo", compiled(s)); }
public void Do() { var a = AClass.StaticValue; var b = AStaticClass.StaticValue; var classInstance = new AClass("Class"); Console.WriteLine($"Class value: {classInstance.Value}"); var structInstance = new AStruct("Struct"); Console.WriteLine($"Struct value: {structInstance.Value}"); }
public void SetProperty_StructInstance_StructProperty() { var pi = typeof(AStruct).GetProperty(nameof(AStruct.AStructVal)); var setter = pi.DelegateForSetProperty(); var inst = new AStruct(); var setVal = new StructVal { IntVal = 55, ObjVal = "yo" }; inst = (AStruct)setter(inst, setVal); Assert.Equal(setVal, inst.AStructVal); }
public static void locals() { string s = null; var astruct = new AStruct() { i = 42 }; locals1(null); locals2 <string> (null, 5, "ABC", ref s, ref astruct); locals3(); locals6(); locals7 <int> (22); }
public static int Main () { for (int i = 0; i < 100; ++i) { AStruct a; a = new AStruct (5); if (a.foo != null) return 1; a.foo = i + 1; } System.Console.WriteLine ("ok"); return 0; }
static void Main() { int n = int.Parse(Console.ReadLine()); AStruct[] list = new AStruct[n]; for (int i = 0; i < n; ++i) { string[] words = Console.ReadLine().Split(' '); list[i] = new AStruct { integer = int.Parse(words[0]), character = words[1][0] }; } Example(n, list); }
private void TestStruct() { Watch.Restart(); for (var i = 0; i < 10; i++) { var list = new AStruct[OneMillion]; for (var j = 0; j < OneMillion; j++) { list[i] = new AStruct(i); } } Watch.Stop(); _results.Add(new BenchWarmerResult { Name = "Struct", ElapsedMiliseconds = Watch.ElapsedMilliseconds / 10 }); }
public static int Main() { for (int i = 0; i < 100; ++i) { AStruct a; a = new AStruct(5); if (a.foo != null) { return(1); } a.foo = i + 1; } System.Console.WriteLine("ok"); return(0); }
public static void locals2 <T> (string[] args, int arg, T t, ref string rs, ref AStruct astruct) { long i = 42; string s = "AB"; for (int j = 0; j < 10; ++j) { if (s != null) { i++; } if (t != null) { i++; } astruct = new AStruct(); } rs = "A"; }
public static int test_0_large_arg() { var arg = new AStruct(); arg.a1 = 1; arg.a2 = 2; arg.a3 = 3; arg.a20 = 20; var res = typeof(Tests).GetMethod("return_t").MakeGenericMethod(new Type [] { typeof(AStruct) }).Invoke(null, new object [] { arg }); var arg2 = (AStruct)res; if (arg2.a20 == 20) { return(0); } else { return(1); } }
private void TestUnamanaged() { unsafe { var ptrs = new AStruct *[10]; Watch.Restart(); for (var j = 0; j < 10; j++) { var buffer = stackalloc AStruct[TwoHundredThousand]; ptrs[j] = buffer; for (int i = 0; i < TwoHundredThousand; i++) { buffer[i] = new AStruct { Property = i }; } } Watch.Stop(); Console.WriteLine($"{nameof(TestUnamanaged)}"); foreach (var ptr in ptrs) { Console.WriteLine(((IntPtr)ptr).ToString()); } Console.WriteLine($"{ptrs[0]->Property} {ptrs[1]->Property} {ptrs[2]->Property} {ptrs[3]->Property} {ptrs[4]->Property} {ptrs[5]->Property} {ptrs[6]->Property} {ptrs[7]->Property} {ptrs[8]->Property} {ptrs[9]->Property}"); AStruct *memPtr = ptrs[0]; var varThatIWant = 9999; var aPtr = memPtr + varThatIWant; Console.WriteLine($"{aPtr->Property} exp: 9999"); Console.WriteLine($"{sizeof(AStruct)} bytes"); } _results.Add(new BenchWarmerResult { Name = "Unmanaged", ElapsedMiliseconds = Watch.ElapsedMilliseconds / 10 }); }
public static int test_0_exit() { var astruct = new AStruct() { i = 1 }; var astruct2 = JitClass.exit_vtype(astruct); if (astruct2.i != 1) { return(1); } var ginst = new List <string> (); var ginst2 = JitClass.exit_ginst(ginst); if (ginst != ginst2) { return(2); } var gstruct = new GStruct <string> () { i = 1 }; var gstruct2 = JitClass.exit_ginst_vtype(gstruct); if (gstruct2.i != 1) { return(3); } var anint = 1; JitClass.exit_byref(ref anint); if (anint != 2) { return(4); } return(0); }
public static void vtypes() { Tests t = new Tests() { field_struct = new AStruct() { i = 42, s = "S", k = 43 }, generic_field_struct = new GStruct <int> () { i = 42 }, field_boxed_struct = new AStruct() { i = 42 }, boxed_struct_field = new KeyValuePair <int, object> (1, (long)42) }; AStruct s = new AStruct { i = 44, s = "T", k = 45 }; AStruct[] arr = new AStruct[] { new AStruct() { i = 1, s = "S1" }, new AStruct() { i = 2, s = "S2" } }; TypedReference typedref = __makeref(s); t.vtypes1(s, arr, typedref); vtypes2(s); vtypes3(s); vtypes4(); }
public static void vtypes3(AStruct s) { AStruct.static_foo(5); }
public static void vtypes2(AStruct s) { s.foo(5); }
public static int entry() { InterpClass.entry_void_0(); InterpClass.entry_void_0(); int res = InterpClass.entry_int_int(1); if (res != 2) { return(1); } var c = new InterpClass(); res = c.entry_int_this_int(1); if (res != 2) { return(2); } var s = InterpClass.entry_string_string("A", "B"); if (s != "AB") { return(3); } var astruct = new AStruct() { i = 1 }; var astruct2 = InterpClass.entry_struct_struct(astruct); if (astruct2.i != 1) { return(4); } var l = new List <string> (); var l2 = InterpClass.entry_ginst_ginst(l); if (l != l2) { return(5); } var gstruct = new GStruct <string> () { i = 1 }; var gstruct2 = InterpClass.entry_ginst_ginst_vtype(gstruct); if (gstruct2.i != 1) { return(6); } int val = 1; InterpClass.entry_void_byref_int(ref val); if (val != 2) { return(7); } res = InterpClass.entry_8_int_args(1, 2, 3, 4, 5, 6, 7, 8); if (res != 36) { return(8); } res = InterpClass.entry_9_int_args(1, 2, 3, 4, 5, 6, 7, 8, 9); if (res != 45) { return(9); } var ptr = new IntPtr(32); var ptr2 = InterpClass.entry_intptr_intptr(ptr); if (ptr != ptr2) { return(10); } return(0); }
public static AStruct entry_struct_struct(AStruct l) { return(l); }
public static AStruct exit_vtype(AStruct s) { return(s); }
//Rest of ctors.... public A(AStruct s) { Value = s.value; }
public static int test_0_partial_constrained_call_llvmonly () { var builder = new AStruct (); var awaiter = new TaskAwaiter<bool> (); var res = builder.Caller (ref awaiter); return res == typeof (bool) ? 0 : 1; }
public static void TakesStruct(AStruct s) { Console.WriteLine(s); }
public static void StructRef(ref AStruct s) { Console.WriteLine(s); }
public TNStructTag(AStruct astruct) { this.astruct = astruct; }
public static unsafe string ti2(string[] s2, int[] s3, int[,] s4, ref int ri, int *ptr, int i, AStruct s, Tests t, Tests2 t2, GClass <int> g, AnEnum ae) { return(s2 [0] + s3 [0] + s4 [0, 0]); }
// Test that vtypes are unboxed during a virtual call public static int test_44_unbox_trampoline () { AStruct s = new AStruct (44); object o = s; return o.GetHashCode (); }
public void invoke1(Tests2 t, AStruct s, GStruct <int> g) { invoke2(); }
public static void modify(out AStruct a) { a = new AStruct(); a.x++; }