[svn:parrot] r46386 - branches/codestring/src/pmc
coke at svn.parrot.org
coke at svn.parrot.org
Fri May 7 14:41:50 UTC 2010
Author: coke
Date: Fri May 7 14:41:50 2010
New Revision: 46386
URL: https://trac.parrot.org/parrot/changeset/46386
Log:
Make CodeString ISA StringBuilder instead of HAS-A.
The CS is nearly always used as a builder (via .emit()); also avoids a bunch
of VTABLES used solely to dispatch to the has-a SB, and an extra PMC per
codestring.
Modified:
branches/codestring/src/pmc/codestring.pmc
Modified: branches/codestring/src/pmc/codestring.pmc
==============================================================================
--- branches/codestring/src/pmc/codestring.pmc Fri May 7 14:39:42 2010 (r46385)
+++ branches/codestring/src/pmc/codestring.pmc Fri May 7 14:41:50 2010 (r46386)
@@ -33,9 +33,8 @@
/* HEADERIZER BEGIN: static */
/* HEADERIZER END: static */
-pmclass CodeString extends String provides string auto_attrs {
+pmclass CodeString extends StringBuilder provides string auto_attrs {
ATTR PMC *linepos; /* start of line positions */
- ATTR PMC *stringbuilder;
/*
@@ -48,13 +47,9 @@
*/
VTABLE void init() {
+ SUPER();
SET_ATTR_linepos(INTERP, SELF, PMCNULL);
-
- SET_ATTR_stringbuilder(INTERP, SELF,
- Parrot_pmc_new(INTERP, enum_class_StringBuilder));
-
PObj_custom_mark_SET(SELF);
-
}
/*
@@ -68,14 +63,12 @@
*/
VTABLE void mark() {
+ SUPER();
if (PMC_data(SELF)) {
- PMC *linepos, *stringbuilder;
+ PMC *linepos;
GET_ATTR_linepos(INTERP, SELF, linepos);
Parrot_gc_mark_PMC_alive(INTERP, linepos);
-
- GET_ATTR_stringbuilder(INTERP, SELF, stringbuilder);
- Parrot_gc_mark_PMC_alive(INTERP, stringbuilder);
}
}
@@ -111,12 +104,10 @@
STRING * const comma_space = CONST_STRING(INTERP, ", ");
STRING * const newline = CONST_STRING(INTERP, "\n");
STRING *key;
- PMC *stringbuilder;
+ PMC *stringbuilder = SELF;
INTVAL percentPos;
INTVAL pos = 0;
- GET_ATTR_stringbuilder(INTERP, SELF, stringbuilder);
-
/* Loop over the format string, splitting it into chunks
* for the string builder. */
while (pos >= 0) {
@@ -404,38 +395,6 @@
RETURN(STRING *out);
}
- /* Dispatch these VTABLE entries to our StringBuilder. */
-
- VTABLE STRING *get_string() {
- PMC *stringbuilder;
- STRING *result;
-
- GET_ATTR_stringbuilder(INTERP, SELF, stringbuilder);
- return VTABLE_get_string(INTERP, stringbuilder);
- }
-
- VTABLE void set_string_native(STRING *value) {
- PMC *stringbuilder;
-
- GET_ATTR_stringbuilder(INTERP, SELF, stringbuilder);
- VTABLE_set_string_native(INTERP, stringbuilder, value);
- }
-
-
- VTABLE void i_concatenate_str(STRING *value) {
- PMC *stringbuilder;
- GET_ATTR_stringbuilder(INTERP, SELF, stringbuilder);
-
- VTABLE_push_string(INTERP, stringbuilder, value);
- }
-
- VTABLE void i_concatenate(PMC *value) {
- PMC *stringbuilder;
- GET_ATTR_stringbuilder(INTERP, SELF, stringbuilder);
-
- VTABLE_push_pmc(INTERP, stringbuilder, value);
- }
-
/*
=back
More information about the parrot-commits
mailing list