[svn:parrot] r38290 - in branches/pmc_pct/compilers/pmc: src/parser t t/data

bacek at svn.parrot.org bacek at svn.parrot.org
Fri Apr 24 12:17:16 UTC 2009


Author: bacek
Date: Fri Apr 24 12:17:15 2009
New Revision: 38290
URL: https://trac.parrot.org/parrot/changeset/38290

Log:
Add "class_init" as valid method.

Added:
   branches/pmc_pct/compilers/pmc/t/data/class14.pmc
Modified:
   branches/pmc_pct/compilers/pmc/src/parser/grammar.pg
   branches/pmc_pct/compilers/pmc/t/01-parse.t

Modified: branches/pmc_pct/compilers/pmc/src/parser/grammar.pg
==============================================================================
--- branches/pmc_pct/compilers/pmc/src/parser/grammar.pg	Fri Apr 24 12:16:44 2009	(r38289)
+++ branches/pmc_pct/compilers/pmc/src/parser/grammar.pg	Fri Apr 24 12:17:15 2009	(r38290)
@@ -52,7 +52,13 @@
 
 # Body of PMC class. 
 rule body {
-    [ <vtable> | <method> | <multi> ]* 
+    [ <class_init> | <vtable> | <method> | <multi> ]* 
+    {*}
+}
+
+# PMC can have class_init function.
+rule class_init {
+    'void' 'class_init' '(' ')' <c_body>
     {*}
 }
 

Modified: branches/pmc_pct/compilers/pmc/t/01-parse.t
==============================================================================
--- branches/pmc_pct/compilers/pmc/t/01-parse.t	Fri Apr 24 12:16:44 2009	(r38289)
+++ branches/pmc_pct/compilers/pmc/t/01-parse.t	Fri Apr 24 12:17:15 2009	(r38290)
@@ -5,7 +5,7 @@
 .include 'test_more.pir'
 load_bytecode 'compilers/pmc/pmc.pbc'
     .local int total
-    total = 14
+    total = 15
 
     plan(total)
     test_parse(total)

Added: branches/pmc_pct/compilers/pmc/t/data/class14.pmc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/pmc_pct/compilers/pmc/t/data/class14.pmc	Fri Apr 24 12:17:15 2009	(r38290)
@@ -0,0 +1,13 @@
+pmclass Foo {
+    void class_init() {
+        /* class_init_code; called for side effects */
+        Small_Object_Pool *List_chunks =
+            get_bufferlike_pool(INTERP, sizeof (List_chunk));
+        Small_Object_Pool *Lists       =
+            get_bufferlike_pool(INTERP, sizeof (List));
+
+        /* XXX until there's a function to allocate a pool in an arena */
+        UNUSED(List_chunks);
+        UNUSED(Lists);
+    }
+}


More information about the parrot-commits mailing list