From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15907 invoked by alias); 8 Dec 2007 00:53:38 -0000 Received: (qmail 15891 invoked by uid 22791); 8 Dec 2007 00:53:37 -0000 X-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 08 Dec 2007 00:53:33 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.1) with ESMTP id lB80rVje027005 for ; Fri, 7 Dec 2007 19:53:31 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id lB80rVrP008263 for ; Fri, 7 Dec 2007 19:53:31 -0500 Received: from [127.0.0.1] (sebastian-int.corp.redhat.com [172.16.52.221]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id lB80rTVj026442; Fri, 7 Dec 2007 19:53:29 -0500 Message-ID: <4759EB1B.7040007@redhat.com> Date: Sat, 08 Dec 2007 00:53:00 -0000 From: Andrew Cagney User-Agent: Thunderbird 1.5.0.12 (X11/20070530) MIME-Version: 1.0 To: Stan Cox CC: Frysk List Subject: Re: Use StringBuilder instead of PrintWriter for type display References: <1197063360.10805.165.camel@multics.rdu.redhat.com> <4759D33D.5050206@redhat.com> In-Reply-To: <4759D33D.5050206@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact frysk-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-owner@sourceware.org X-SW-Source: 2007-q4/txt/msg00214.txt.bz2 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 >