mirror of https://github.com/aamine/cbc
* 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:
parent
132e4cbbb2
commit
a023940537
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,4 +40,11 @@ public class ArrayTypeRef extends TypeRef {
|
|||
public boolean isLengthUndefined() {
|
||||
return (length == undefined);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return baseType.toString()
|
||||
+ "["
|
||||
+ (length == undefined ? "" : "" + length)
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,4 +23,8 @@ public class PointerTypeRef extends TypeRef {
|
|||
public int hashCode() {
|
||||
return (1 << 11) & baseType.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return baseType.toString() + "*";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,4 +15,8 @@ public class SignedCharRef extends TypeRef {
|
|||
public int hashCode() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "char";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,4 +15,8 @@ public class SignedIntRef extends TypeRef {
|
|||
public int hashCode() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "int";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,4 +15,8 @@ public class SignedLongRef extends TypeRef {
|
|||
public int hashCode() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "long";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,4 +15,8 @@ public class SignedShortRef extends TypeRef {
|
|||
public int hashCode() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "short";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,4 +23,8 @@ public class StructTypeRef extends TypeRef {
|
|||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "struct " + name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,4 +23,8 @@ public class UnionTypeRef extends TypeRef {
|
|||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "union " + name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,4 +15,8 @@ public class UnsignedCharRef extends TypeRef {
|
|||
public int hashCode() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "unsigned char";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,4 +15,8 @@ public class UnsignedIntRef extends TypeRef {
|
|||
public int hashCode() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "unsigned int";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,4 +15,8 @@ public class UnsignedLongRef extends TypeRef {
|
|||
public int hashCode() {
|
||||
return 7;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "unsigned long";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,4 +15,8 @@ public class UnsignedShortRef extends TypeRef {
|
|||
public int hashCode() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "unsigned short";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,4 +23,8 @@ public class UserTypeRef extends TypeRef {
|
|||
public int hashCode() {
|
||||
return (1 << 12) & name.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,4 +15,8 @@ public class VoidTypeRef extends TypeRef {
|
|||
public int hashCode() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "void";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue