* net/loveruby/cflat/ast/Dumper.java: specialize TypeNode printing.

* net/loveruby/cflat/ast/Params.java: show parameter list.
* net/loveruby/cflat/type/*TypeRef.java: define #toString.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3788 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
Minero Aoki 2008-01-03 23:30:58 +00:00
parent 132e4cbbb2
commit a023940537
18 changed files with 90 additions and 2 deletions

View File

@ -1,3 +1,12 @@
Fri Jan 4 08:30:55 2008 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/ast/Dumper.java: specialize TypeNode
printing.
* net/loveruby/cflat/ast/Params.java: show parameter list.
* net/loveruby/cflat/type/*TypeRef.java: define #toString.
Fri Jan 4 08:01:31 2008 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/compiler/Compiler.java: implement command

View File

@ -67,6 +67,11 @@ public class Dumper {
stream.println(name + ": " + value);
}
public void printMember(String name, TypeNode n) {
printIndent();
stream.println(name + ": " + n.typeRef());
}
public void printMember(String name, Node n) {
printIndent();
if (n == null) {

View File

@ -16,7 +16,6 @@ abstract public class Params extends Node {
abstract public Params typeRefs();
protected void _dump(Dumper d) {
// FIXME
d.printMember("parameters", "FIXME");
d.printNodeList("parameters", parameters());
}
}

View File

@ -40,4 +40,11 @@ public class ArrayTypeRef extends TypeRef {
public boolean isLengthUndefined() {
return (length == undefined);
}
public String toString() {
return baseType.toString()
+ "["
+ (length == undefined ? "" : "" + length)
+ "]";
}
}

View File

@ -33,4 +33,20 @@ public class FunctionTypeRef extends TypeRef {
public Params params() {
return params;
}
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append(returnType.toString());
buf.append(" (");
Iterator params = this.params.parameters();
String sep = "";
while (params.hasNext()) {
TypeRef ref = (TypeRef)params.next();
buf.append(sep);
buf.append(ref.toString());
sep = ", ";
}
buf.append(")");
return buf.toString();
}
}

View File

@ -23,4 +23,8 @@ public class PointerTypeRef extends TypeRef {
public int hashCode() {
return (1 << 11) & baseType.hashCode();
}
public String toString() {
return baseType.toString() + "*";
}
}

View File

@ -15,4 +15,8 @@ public class SignedCharRef extends TypeRef {
public int hashCode() {
return 0;
}
public String toString() {
return "char";
}
}

View File

@ -15,4 +15,8 @@ public class SignedIntRef extends TypeRef {
public int hashCode() {
return 2;
}
public String toString() {
return "int";
}
}

View File

@ -15,4 +15,8 @@ public class SignedLongRef extends TypeRef {
public int hashCode() {
return 3;
}
public String toString() {
return "long";
}
}

View File

@ -15,4 +15,8 @@ public class SignedShortRef extends TypeRef {
public int hashCode() {
return 1;
}
public String toString() {
return "short";
}
}

View File

@ -23,4 +23,8 @@ public class StructTypeRef extends TypeRef {
public String name() {
return name;
}
public String toString() {
return "struct " + name;
}
}

View File

@ -23,4 +23,8 @@ public class UnionTypeRef extends TypeRef {
public String name() {
return name;
}
public String toString() {
return "union " + name;
}
}

View File

@ -15,4 +15,8 @@ public class UnsignedCharRef extends TypeRef {
public int hashCode() {
return 4;
}
public String toString() {
return "unsigned char";
}
}

View File

@ -15,4 +15,8 @@ public class UnsignedIntRef extends TypeRef {
public int hashCode() {
return 6;
}
public String toString() {
return "unsigned int";
}
}

View File

@ -15,4 +15,8 @@ public class UnsignedLongRef extends TypeRef {
public int hashCode() {
return 7;
}
public String toString() {
return "unsigned long";
}
}

View File

@ -15,4 +15,8 @@ public class UnsignedShortRef extends TypeRef {
public int hashCode() {
return 5;
}
public String toString() {
return "unsigned short";
}
}

View File

@ -23,4 +23,8 @@ public class UserTypeRef extends TypeRef {
public int hashCode() {
return (1 << 12) & name.hashCode();
}
public String toString() {
return name;
}
}

View File

@ -15,4 +15,8 @@ public class VoidTypeRef extends TypeRef {
public int hashCode() {
return -1;
}
public String toString() {
return "void";
}
}