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
Andrew Cagney wrote:
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.
Hmm, if the below works, then wouldn't passing in the middle part vis:
toPrint(String middle)
be sufficient:
CompositeType: member.type.toPrint("foo");
PointerType: pointerTarget.type.toPrint("*" +middle); // *foo
ArrayType returns "(" + middle + ")" + "[...]" // (*foo)[...]
Andrew
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