#!/usr/local/bin/rune -x # # Demonstrate basic arrays. # import "sys"; import ; public void test(string_p str, ...) { int *v = (int *)self.__vardata[0]; stdio.stdout->show("XXXXXXX", v); } int g = 5; public int main(int ac, string_p *av) { int *array[4]; int a = 2; int b = 4; int c = 6; int d = 8; global int x = 1; int f1[4]; int f2[4]; f2[3] = 5; f1 = f2; /* XXX should disallow this */ stdio.stdout->show("f2(5):", f1[3]); pass_array(array); stdio.stdout->show("f2(5):", f1[3]); array[0] = &a; array[1] = &b; array[2] = &c; array[3] = &d; stdio.stdout->show("Array:", array[0], array[1], array[2], array[3]); # stdio.stdout->show("Array:", &a); # stdio.stdout->show("XXX need auto array teardown"); # stdio.stdout->show("XXX deref args on return"); # test("xyua", &a); # array[0] = NULL; # XXX teardown # array[1] = NULL; # array[2] = NULL; # array[3] = NULL; return(0); } # should be pass-by-copy so our modification here should not have # affected the results. # int pass_array(int *array[4]) { array[3] = &g; }