From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15826 invoked by alias); 15 Oct 2007 19:13:35 -0000 Received: (qmail 15815 invoked by uid 22791); 15 Oct 2007 19:13:33 -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; Mon, 15 Oct 2007 19:13:29 +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 l9FJDQit013960 for ; Mon, 15 Oct 2007 15:13:27 -0400 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 l9FJDQCN025282 for ; Mon, 15 Oct 2007 15:13:26 -0400 Received: from [172.16.57.153] (multics.rdu.redhat.com [172.16.57.153]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l9FJDQmY031154; Mon, 15 Oct 2007 15:13:26 -0400 Subject: Re: generating type tests From: Stan Cox To: Andrew Cagney Cc: Frysk List In-Reply-To: <47139B3A.3000101@redhat.com> References: <1192223570.2947.145.camel@multics.rdu.redhat.com> <47139B3A.3000101@redhat.com> Content-Type: multipart/mixed; boundary="=-pkteoQYNEjjB3Yz7WL2P" Date: Mon, 15 Oct 2007 19:13:00 -0000 Message-Id: <1192475232.2947.164.camel@multics.rdu.redhat.com> Mime-Version: 1.0 X-Mailer: Evolution 2.10.3 (2.10.3-2.fc7) X-Virus-Checked: Checked by ClamAV on sourceware.org 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/msg00054.txt.bz2 --=-pkteoQYNEjjB3Yz7WL2P Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 426 On Mon, 2007-10-15 at 12:54 -0400, Andrew Cagney wrote: > Can you post the patch? (Note: this is a "make it work" patch.) ArrayType: Handle 'int (*x) [N]' Actually we probably want to display it as 'int (*) [N}' (minus the name) PointerType: Handle 'int (*x) []' CompositeType: Handle 'struct {struct {..}}' and 'int (*x) []' TypeDecorator: Handle 'const int * x' versus 'int * const x' --=-pkteoQYNEjjB3Yz7WL2P Content-Disposition: attachment; filename=",cvsdiff" Content-Type: text/plain; name=",cvsdiff"; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 5889 =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/value/ArrayType.java,v retrieving revision 1.37 diff -u -p -r1.37 ArrayType.java --- value/ArrayType.java 6 Sep 2007 14:26:09 -0000 1.37 +++ value/ArrayType.java 12 Oct 2007 20:37:02 -0000 @@ -204,14 +204,17 @@ public class ArrayType } } - public void toPrint(PrintWriter writer) { + public void toPrint(String s, PrintWriter writer) { type.toPrint(writer); - writer.print(" ["); + writer.print(" " + s); for(int i = 0; i < this.dimension.length; i++) { - if (i > 0) - writer.print(","); + writer.print("["); writer.print(dimension[i]); + writer.print("]"); } - writer.print("]"); + } + + public void toPrint(PrintWriter writer) { + this.toPrint("", writer); } } Index: value/CompositeType.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/value/CompositeType.java,v retrieving revision 1.2 diff -u -p -r1.2 CompositeType.java --- value/CompositeType.java 6 Sep 2007 20:48:09 -0000 1.2 +++ value/CompositeType.java 12 Oct 2007 20:37:02 -0000 @@ -259,16 +261,21 @@ abstract class CompositeType writer.print("}"); } - public void toPrint(PrintWriter writer) { + public void toPrint(int indentation, PrintWriter writer) { // FIXME: going away. if (this.isTypedef() && this.getName() != null - && this.getName().length() > 0) { + && this.getName().length() > 0) { writer.print(this.getName()); return; } + + String indentPrefix = ""; + for (int indent = 1; indent <= indentation; indent++) + indentPrefix = indentPrefix + " "; + // {class,union,struct} NAME writer.print(getPrefix()); - if (getName() != null) { + if (getName() != null && getName().length() > 0) { writer.print(" "); writer.print(getName()); } @@ -278,7 +285,7 @@ abstract class CompositeType Iterator i = members.iterator(); // Types this inherits come first; print them out. while (i.hasNext()) { - member = (Member)i.next(); + member = (Member) i.next(); if (!member.inheritance) break; if (first) { @@ -289,7 +296,6 @@ abstract class CompositeType } if (member.access != null) { writer.print(member.access.toPrint()); - writer.print(" "); } writer.print(member.type.getName()); member = null; @@ -297,7 +303,9 @@ abstract class CompositeType // { content ... } Access previousAccess = null; writer.print(" {\n"); + while (member != null) { + boolean printName = true; if (member.access != previousAccess) { previousAccess = member.access; if (member.access != null) { @@ -306,12 +314,25 @@ abstract class CompositeType writer.print(":\n"); } } - writer.print(" "); - if (member.type.isTypedef()) + writer.print(indentPrefix); + + if (member.type instanceof TypeDef) writer.print(member.type.getName()); + else if (member.type instanceof CompositeType) + ((CompositeType) member.type).toPrint(indentation + 2, writer); + else if (member.type instanceof ArrayType) { + printName = false; + ((ArrayType) member.type).toPrint(member.name, writer); + } + else if (member.type instanceof PointerType) { + printName = false; + ((PointerType) member.type).toPrint(" " + member.name, writer); + } else member.type.toPrint(writer); - if (!(member.type instanceof frysk.value.FunctionType)) { + if (member.type instanceof frysk.value.FunctionType) + printName = false; + if (printName) { writer.print(" "); writer.print(member.name); } @@ -322,10 +343,16 @@ abstract class CompositeType writer.print(";\n"); // Advance if (i.hasNext()) - member = (Member)i.next(); + member = (Member) i.next(); else member = null; } + for (int indent = 1; indent <= indentation - 2; indent++) + writer.print(" "); writer.print("}"); } + + public void toPrint(PrintWriter writer) { + this.toPrint(2, writer); + } } Index: value/PointerType.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/value/PointerType.java,v retrieving revision 1.23 diff -u -p -r1.23 PointerType.java --- value/PointerType.java 21 Sep 2007 20:21:07 -0000 1.23 +++ value/PointerType.java 12 Oct 2007 20:37:02 -0000 @@ -93,11 +93,20 @@ public class PointerType } } - public void toPrint(PrintWriter writer) { - type.toPrint(writer); - writer.print(" *"); + public void toPrint(String s, PrintWriter writer) { + if (type instanceof ArrayType) { + ((ArrayType)type).toPrint("(*" + s + ")", writer); + } + else { + type.toPrint(writer); + writer.print(" *" + s); + } } + public void toPrint(PrintWriter writer) { + this.toPrint("", writer); + } + protected Type clone(IntegerType accessor) { return new PointerType(getName(), order(), getSize(), type, accessor); } Index: value/TypeDecorator.java =================================================================== RCS file: /cvs/frysk/frysk-core/frysk/value/TypeDecorator.java,v retrieving revision 1.5 diff -u -p -r1.5 TypeDecorator.java --- value/TypeDecorator.java 6 Sep 2007 03:19:07 -0000 1.5 +++ value/TypeDecorator.java 12 Oct 2007 20:37:02 -0000 @@ -77,9 +77,14 @@ abstract class TypeDecorator extends Typ * A guess; sub classes should override. */ public void toPrint(PrintWriter writer) { - writer.print(getName()); - writer.print(" "); - decorated.toPrint(writer); + if (getUltimateType() instanceof PointerType) { + decorated.toPrint(writer); + writer.print(" " + getName()); + } + else { + writer.print(getName() + " "); + decorated.toPrint(writer); + } } public Value add(Value var1, Value var2) { return decorated.add(var1, var2); --=-pkteoQYNEjjB3Yz7WL2P--