[svn:parrot] r46147 - in trunk: . src/pmc t/native_pbc

NotFound at svn.parrot.org NotFound at svn.parrot.org
Thu Apr 29 19:32:54 UTC 2010


Author: NotFound
Date: Thu Apr 29 19:32:53 2010
New Revision: 46147
URL: https://trac.parrot.org/parrot/changeset/46147

Log:
new PMC packfiledebug, update PBC_COMPAT, realclean recommended

Added:
   trunk/src/pmc/packfiledebug.pmc
Modified:
   trunk/PBC_COMPAT
   trunk/src/pmc/packfiledirectory.pmc
   trunk/t/native_pbc/annotations.pbc
   trunk/t/native_pbc/integer_1.pbc
   trunk/t/native_pbc/number_1.pbc
   trunk/t/native_pbc/string_1.pbc

Modified: trunk/PBC_COMPAT
==============================================================================
--- trunk/PBC_COMPAT	Thu Apr 29 16:42:58 2010	(r46146)
+++ trunk/PBC_COMPAT	Thu Apr 29 19:32:53 2010	(r46147)
@@ -27,6 +27,7 @@
 
 # please insert tab separated entries at the top of the list
 
+6.10	2010.04.29	NotFound	packfiledebug.pmc
 6.9	2010.04.27	bacek	remove deprecated in-place string ops (bitwise, charset, case change)
 6.8	2010.04.27	bacek	remove deprecated in-place substr ops
 6.7	2010.04.22	coke	remove RetContinuation PMC

Added: trunk/src/pmc/packfiledebug.pmc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/src/pmc/packfiledebug.pmc	Thu Apr 29 19:32:53 2010	(r46147)
@@ -0,0 +1,210 @@
+/*
+Copyright (C) 2001-2010, Parrot Foundation.
+$Id: $
+
+=head1 NAME
+
+src/pmc/packfiledebug.pmc - Packfile Debug Segment PMC
+
+=head1 DESCRIPTION
+
+This class implements a PackfileDebug object, a segment of the .pbc
+data file used for storing pir debug information.
+
+See packfile.pmc for the toplevel Packfile interface, see packfilesegment.pmc
+for the list of common methods every packfile segment pmc must implement; see
+PDD13 for the design spec.
+
+Initial and experimental version, using some vtables as a quick way of testing.
+
+=head2 Vtable functions
+
+=over 4
+
+=cut
+
+*/
+
+/* HEADERIZER HFILE: none */
+/* HEADERIZER BEGIN: static */
+/* HEADERIZER END: static */
+
+pmclass PackfileDebug auto_attrs extends PackfileRawSegment {
+    /* Number of file mappings */
+    ATTR INTVAL num_mappings;
+    /* File name mapping */
+    ATTR PMC *mapping_offset;
+    ATTR PMC *mapping_filename;
+
+/*
+
+=item C<init>
+
+Create empty PackfileDebug.
+
+=cut
+
+*/
+
+    VTABLE void init() {
+        SUPER();
+        SET_ATTR_type(INTERP, SELF, PF_DEBUG_SEG);
+    }
+
+/*
+
+=item C<void mark()>
+
+Marks the object as live.
+
+=cut
+
+*/
+
+    VTABLE void mark() {
+        PMC *mapping_offset;
+        PMC *mapping_filename;
+	GET_ATTR_mapping_offset(INTERP, SELF, mapping_offset);
+	GET_ATTR_mapping_filename(INTERP, SELF, mapping_filename);
+	Parrot_gc_mark_PMC_alive(INTERP, mapping_offset);
+	Parrot_gc_mark_PMC_alive(INTERP, mapping_filename);
+
+        SUPER();
+    }
+
+
+/*
+
+=item C<set_pointer>
+
+Set pointer to underlying PackFile_ConstTable
+
+=cut
+
+*/
+
+    VTABLE void set_pointer(void * pointer) {
+        PackFile_Debug *p = (PackFile_Debug *) pointer;
+	INTVAL num_mappings = p->num_mappings;
+	PMC *mapping_offset = Parrot_pmc_new_init_int(INTERP, enum_class_FixedIntegerArray, num_mappings);
+	PMC *mapping_filename = Parrot_pmc_new_init_int(INTERP, enum_class_FixedIntegerArray, num_mappings);
+	INTVAL i;
+        STRING *t = CONST_STRING(INTERP, "test");
+
+        SUPER(pointer);
+	for (i = 0; i < num_mappings; ++i) {
+	    VTABLE_set_integer_keyed_int(INTERP, mapping_offset, i,
+	            p->mappings[i].offset);
+	    VTABLE_set_integer_keyed_int(INTERP, mapping_filename, i,
+	            p->mappings[i].filename);
+        }
+        SET_ATTR_num_mappings(INTERP, SELF, p->num_mappings);
+        SET_ATTR_mapping_offset(INTERP, SELF, mapping_offset);
+        SET_ATTR_mapping_filename(INTERP, SELF, mapping_filename);
+    }
+
+/*
+
+=item C<void *get_pointer()>
+=cut
+
+*/
+
+    VTABLE void *get_pointer() {
+        PackFile_Debug *p = (PackFile_Debug *) mem_gc_realloc_n_typed(INTERP,
+	        SUPER(), sizeof(PackFile_Debug), char);
+        INTVAL num_mappings;
+	PMC *mapping_offset;
+	PMC *mapping_filename;
+	INTVAL i;
+	GET_ATTR_num_mappings(INTERP, SELF, num_mappings);
+        GET_ATTR_mapping_offset(INTERP, SELF, mapping_offset);
+        GET_ATTR_mapping_filename(INTERP, SELF, mapping_filename);
+        p->num_mappings = num_mappings;
+	p->mappings = mem_gc_allocate_n_typed(INTERP, num_mappings, PackFile_DebugFilenameMapping);
+	for (i = 0; i < num_mappings; ++i) {
+            p->mappings[i].offset = VTABLE_get_integer_keyed_int(INTERP, mapping_offset, i);
+            p->mappings[i].filename = VTABLE_get_integer_keyed_int(INTERP, mapping_filename, i);
+        }
+        return p;
+    }
+
+/*
+
+=item C<INTVAL get_integer()>
+
+Get the number of filename mappings.
+
+=cut
+
+*/
+
+    VTABLE INTVAL get_integer() {
+        INTVAL num_mappings;
+        GET_ATTR_num_mappings(INTERP, SELF, num_mappings);
+        return num_mappings;
+    }
+
+/*
+
+=item C<INTVAL get_string_keyed_int(INTVAL n)>
+
+Get the filename mapping n.
+
+=cut
+
+*/
+
+    VTABLE PMC *get_pmc_keyed_int(INTVAL n) {
+        INTVAL num_mappings;
+        GET_ATTR_num_mappings(INTERP, SELF, num_mappings);
+	if (n < num_mappings) {
+	    PMC *mapping_offset;
+	    INTVAL offset;
+	    PMC *result;
+	    GET_ATTR_mapping_offset(INTERP, SELF, mapping_offset);
+            offset = VTABLE_get_integer_keyed_int(INTERP, mapping_offset, n);
+	    result = Parrot_pmc_new(INTERP, enum_class_Integer);
+	    VTABLE_set_integer_native(INTERP, result, offset);
+            return result;
+	}
+	    else return PMCNULL;
+    }
+
+/*
+
+=item C<INTVAL get_string_keyed_int(INTVAL n)>
+
+Get the filename mapping n.
+
+=cut
+
+*/
+
+    VTABLE STRING *get_string_keyed_int(INTVAL n) {
+        INTVAL num_mappings;
+        GET_ATTR_num_mappings(INTERP, SELF, num_mappings);
+	if (n < num_mappings) {
+	    PMC *mapping_filename;
+	    GET_ATTR_mapping_filename(INTERP, SELF, mapping_filename);
+            return VTABLE_get_string_keyed_int(INTERP, mapping_filename, n);
+	}
+	    else return STRINGNULL;
+    }
+
+}
+
+/*
+
+=back
+
+=cut
+
+*/
+
+/*
+ * Local variables:
+ *   c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */

Modified: trunk/src/pmc/packfiledirectory.pmc
==============================================================================
--- trunk/src/pmc/packfiledirectory.pmc	Thu Apr 29 16:42:58 2010	(r46146)
+++ trunk/src/pmc/packfiledirectory.pmc	Thu Apr 29 19:32:53 2010	(r46147)
@@ -106,9 +106,11 @@
               case PF_ANNOTATIONS_SEG:
                 pmc_type = enum_class_PackfileAnnotations;
                 break;
+              case PF_DEBUG_SEG:
+                pmc_type = enum_class_PackfileDebug;
+                break;
               case PF_BYTEC_SEG:
               case PF_UNKNOWN_SEG:
-              case PF_DEBUG_SEG:
               default:
                 pmc_type = enum_class_PackfileRawSegment;
                 break;

Modified: trunk/t/native_pbc/annotations.pbc
==============================================================================
Binary file (source and/or target). No diff available.

Modified: trunk/t/native_pbc/integer_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.

Modified: trunk/t/native_pbc/number_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.

Modified: trunk/t/native_pbc/string_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.


More information about the parrot-commits mailing list