This is the mail archive of the
frysk@sourceware.org
mailing list for the frysk project.
Re: Use StringBuilder instead of PrintWriter for type display
- From: Andrew Cagney <cagney at redhat dot com>
- To: Stan Cox <scox at redhat dot com>
- Cc: Frysk List <frysk at sourceware dot org>
- Date: Fri, 07 Dec 2007 18:11:57 -0500
- Subject: Re: Use StringBuilder instead of PrintWriter for type display
- References: <1197063360.10805.165.camel@multics.rdu.redhat.com>
Stan Cox wrote:
This changes type display so it builds in a StringBuilder
instead of displaying a piece at a time. Most of the changes are
changing writer.print to stringBuilder.append. A printf style %s token
is used to support types like
"int (*ptr_arr) [4]" where (in this instance) the name and pointer
info have to be inserted a printf %s string is used. For instance
ArrayType would construct "int %s [4]" and then PointerType would
massage that to "int (*%s) [4] and if it is member of a struct
CompositeType would massage it to "int (*ptr_arr) [4]" (otherwise "int
(*) [4]). This allows removal of some instanceof checks and some
specialized code.
Yes, the result is much better.
Would a specialized class help: instead of a SingleString buffer, it
would contain the prefix and postfix strings, and methods to edit them.
For instance, given:
struct s {
(*foo)[10];
}
ArrayType would .append("[10]");
called by PointerType would .insert("(*", ")");
called by CompositeType would .insert("foo");
Andrew