diff options
author | Miguel de Icaza <miguel@gnome.org> | 2001-10-11 22:02:55 +0400 |
---|---|---|
committer | Miguel de Icaza <miguel@gnome.org> | 2001-10-11 22:02:55 +0400 |
commit | 8dd59fa1033716ccf032192d75df8b0975e39e08 (patch) | |
tree | 0be4fbc7ae6dba08f2352719cc3e6b56289a3ab2 /mcs/tests/test-22.cs | |
parent | f88519f59d933182a31a1b09856b425acb1a3582 (diff) |
2001-10-11 Miguel de Icaza <miguel@ximian.com>
* expression.cs (Invocation::Emit): Deal with invocation of
methods on value types. We need to pass the address to structure
methods rather than the object itself. (The equivalent code to
emit "this" for structures leaves the entire structure on the
stack instead of a pointer to it).
(ParameterReference::DoResolve): Compute the real index for the
argument based on whether the method takes or not a `this' pointer
(ie, the method is static).
* codegen.cs (EmitContext::GetTemporaryStorage): Used to store
value types returned from functions when we need to invoke a
method on the sturcture.
svn path=/trunk/mcs/; revision=1147
Diffstat (limited to 'mcs/tests/test-22.cs')
-rw-r--r-- | mcs/tests/test-22.cs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/mcs/tests/test-22.cs b/mcs/tests/test-22.cs new file mode 100644 index 00000000000..2e662494ddd --- /dev/null +++ b/mcs/tests/test-22.cs @@ -0,0 +1,46 @@ +// +// This test excercises invocations of methods in structures. +// +// Unlike classes, we can not just leave the result of a computed +// structure in the IL stack as a result. The reason is that the +// result is the whole structure, not a pointer to it. +// +// This program excercises invocations to methods on structures +// + +struct T { + public int a, b; +} + +struct S { + T t; + + public T GetT () + { + return t; + } + + public void Init () + { + t.a = 1; + t.b = 2; + } +} + +class M { + static int Main () + { + S s = new S (); + + s.Init (); + + if (s.GetT ().a != 1) + return 1; + + if (s.GetT ().b != 2) + return 2; + + return 0; + } +} + |