Skip to content

Commit

Permalink
types: Cleanup of test cases. Updates #8.
Browse files Browse the repository at this point in the history
  • Loading branch information
mewmew committed Feb 5, 2015
1 parent 627ad4d commit a8e3df4
Show file tree
Hide file tree
Showing 3 changed files with 361 additions and 124 deletions.
4 changes: 2 additions & 2 deletions types/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (t *Int) Equal(u Type) bool {
// String returns a string representation of the integer type.
func (t *Int) String() string {
// i32
return fmt.Sprintf("i%d", t.size)
return fmt.Sprintf("i%d", t.Size())
}

// Float represents a floating point type.
Expand Down Expand Up @@ -114,7 +114,7 @@ func (t *Float) Equal(u Type) bool {
// String returns a string representation of the floating point type.
func (t *Float) String() string {
// double
return t.kind.String()
return t.Kind().String()
}

// FloatKind specifies the kind of a floating point type.
Expand Down
18 changes: 9 additions & 9 deletions types/derived.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,20 @@ func (t *Func) String() string {
// void ()
// i32 (i8*, ...)
buf := new(bytes.Buffer)
for i, param := range t.params {
for i, param := range t.Params() {
if i > 0 {
buf.WriteString(", ")
}
buf.WriteString(param.String())
}
if t.variadic {
if len(t.params) > 0 {
if t.IsVariadic() {
if len(t.Params()) > 0 {
buf.WriteString(", ")
}
buf.WriteString("...")
}

return fmt.Sprintf("%s (%s)", t.result, buf)
return fmt.Sprintf("%s (%s)", t.Result(), buf)
}

// Pointer represents a pointer type.
Expand Down Expand Up @@ -152,7 +152,7 @@ func (t *Pointer) Equal(u Type) bool {
// String returns a string representation of the pointer type.
func (t *Pointer) String() string {
// i32*
return fmt.Sprintf("%v*", t.elem)
return fmt.Sprintf("%v*", t.Elem())
}

// Vector represents a vector type.
Expand Down Expand Up @@ -213,7 +213,7 @@ func (t *Vector) Equal(u Type) bool {
// String returns a string representation of the vector type.
func (t *Vector) String() string {
// <2 x i32>
return fmt.Sprintf("<%d x %v>", t.n, t.elem)
return fmt.Sprintf("<%d x %v>", t.Len(), t.Elem())
}

// Array represents an array type.
Expand Down Expand Up @@ -274,7 +274,7 @@ func (t *Array) Equal(u Type) bool {
// String returns a string representation of the array type.
func (t *Array) String() string {
// [2 x float]
return fmt.Sprintf("[%d x %v]", t.n, t.elem)
return fmt.Sprintf("[%d x %v]", t.Len(), t.Elem())
}

// Struct represents a structure type.
Expand Down Expand Up @@ -383,14 +383,14 @@ func (t *Struct) String() string {
// {float, i32, i32}
// <{i32, i8}>
buf := new(bytes.Buffer)
for i, field := range t.fields {
for i, field := range t.Fields() {
if i > 0 {
buf.WriteString(", ")
}
buf.WriteString(field.String())
}

if t.packed {
if t.IsPacked() {
return fmt.Sprintf("<{%s}>", buf)
}
return fmt.Sprintf("{%s}", buf)
Expand Down
Loading

0 comments on commit a8e3df4

Please sign in to comment.