Index: classes/sub.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/sub.pmc,v
retrieving revision 1.5
diff -u -r1.5 sub.pmc
--- classes/sub.pmc	4 Aug 2002 22:55:03 -0000	1.5
+++ classes/sub.pmc	18 Oct 2002 18:02:34 -0000
@@ -32,6 +32,25 @@
        SELF->flags |= PMC_active_destroy_FLAG;
    }
 
+   void init_pmc (PMC* initializer) {
+       /* initializer should be an array like ["address", N] */
+       PMC* address = NULL;
+       INTVAL expected_length = 2;
+       PMC* key = key_new_integer(INTERP, 1);
+
+       SELF->vtable->init(INTERP, SELF);
+       if (initializer->vtable->get_integer(INTERP, initializer) != expected_length) {
+           /* really a compiler error I suppose */
+           internal_exception(OUT_OF_BOUNDS, "wrong initializer length\n");
+           return;
+       }
+       
+       /* TODO: check that initializer[0] == "address" ...*/
+
+       address = initializer->vtable->get_pmc_keyed(INTERP, initializer, key);
+       SELF->vtable->set_integer(INTERP, SELF, address);
+   }
+
    void destroy () {
        mem_sys_free(SELF->data);
    }
Index: t/pmc/sub.t
===================================================================
RCS file: /cvs/public/parrot/t/pmc/sub.t,v
retrieving revision 1.2
diff -u -r1.2 sub.t
--- t/pmc/sub.t	6 Aug 2002 22:43:08 -0000	1.2
+++ t/pmc/sub.t	18 Oct 2002 18:02:34 -0000
@@ -1,6 +1,6 @@
 #! perl -w
 
-use Parrot::Test tests => 3;
+use Parrot::Test tests => 4;
 use Test::More;
 
 output_is(<<'CODE', <<'OUTPUT', "PASM subs");
@@ -47,6 +47,37 @@
 0
 1 done
 done 2
+OUTPUT
+
+output_is(<<'CODE', <<'OUTPUT', "Sub init");
+  #
+  # build initializer
+  #
+  new P10, .Array
+  set P10, 2
+
+  new P11, .PerlString
+  set P11, "address"
+
+  new P12, .PerlInt
+  set_addr I0, subroutine
+  set P12, I0
+
+  set P10[0], P11
+  set P10[1], P12
+
+  #
+  # construct Sub using initializer
+  #
+  new P0, .Sub, P10
+  invoke
+  end
+
+subroutine:
+  print "in sub routine\n"
+  ret
+CODE
+in sub routine
 OUTPUT
 
 output_is(<<'CODE', <<'OUTPUT', "Continuations");
