aboutsummaryrefslogtreecommitdiffstats
path: root/sysgen
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2016-09-21 16:52:55 +0200
committerAndrey Konovalov <andreyknvl@google.com>2016-10-04 18:49:57 +0200
commitc99cbdbe58f7817a2ee6064e72db25fc1d067b41 (patch)
treeaa1bc1092c27601f9531d87b2b2a25e5d1063d7b /sysgen
parente73ddfcb3ac418fc690b982f70da15b898096fa5 (diff)
Emit BufferBlob for array[int8]
Diffstat (limited to 'sysgen')
-rw-r--r--sysgen/sysgen.go34
1 files changed, 23 insertions, 11 deletions
diff --git a/sysgen/sysgen.go b/sysgen/sysgen.go
index c27e413c3..c09a7cd7e 100644
--- a/sysgen/sysgen.go
+++ b/sysgen/sysgen.go
@@ -345,7 +345,7 @@ func generateArg(
}
commonHdr := common()
opt = false
- fmt.Fprintf(out, "PtrType{%v, Dir: %v, Type: BufferType{%v, Kind: BufferBlob}}", commonHdr, fmtDir(a[0]), common())
+ fmt.Fprintf(out, "PtrType{%v, Dir: %v, Type: BufferType{%v, Kind: BufferBlobRand}}", commonHdr, fmtDir(a[0]), common())
case "string":
canBeArg = true
if want := 0; len(a) != want {
@@ -490,22 +490,34 @@ func generateArg(
opt = false
fmt.Fprintf(out, "PtrType{%v, Dir: DirIn, Type: FilenameType{%v}}", commonHdr, common())
case "array":
- switch len(a) {
- case 1:
- fmt.Fprintf(out, "ArrayType{%v, Type: %v, Kind: ArrayRandLen}", common(), generateType(a[0], desc, consts))
- case 2:
+ if len(a) != 1 && len(a) != 2 {
+ failf("wrong number of arguments for %v arg %v, want 1 or 2, got %v", typ, name, len(a))
+ }
+ if len(a) == 1 {
+ if a[0] == "int8" {
+ fmt.Fprintf(out, "BufferType{%v, Kind: BufferBlobRand}", common())
+ } else {
+ fmt.Fprintf(out, "ArrayType{%v, Type: %v, Kind: ArrayRandLen}", common(), generateType(a[0], desc, consts))
+ }
+ } else {
var begin, end uintptr
- sz := a[1]
- if _, err := fmt.Sscanf(sz, "%d:%d", &begin, &end); err != nil {
+ var beginStr, endStr string
+ if _, err := fmt.Sscanf(a[1], "%d:%d", &begin, &end); err == nil {
+ beginStr = fmt.Sprint(begin)
+ endStr = fmt.Sprint(end)
+ } else {
+ sz := a[1]
if v, ok := consts[sz]; ok {
sz = fmt.Sprint(v)
}
- fmt.Fprintf(out, "ArrayType{%v, Type: %v, Kind: ArrayRangeLen, RangeBegin: %v, RangeEnd: %v}", common(), generateType(a[0], desc, consts), sz, sz)
+ beginStr = sz
+ endStr = sz
+ }
+ if a[0] == "int8" {
+ fmt.Fprintf(out, "BufferType{%v, Kind: BufferBlobRange, RangeBegin: %v, RangeEnd: %v}", common(), beginStr, endStr)
} else {
- fmt.Fprintf(out, "ArrayType{%v, Type: %v, Kind: ArrayRangeLen, RangeBegin: %v, RangeEnd: %v}", common(), generateType(a[0], desc, consts), begin, end)
+ fmt.Fprintf(out, "ArrayType{%v, Type: %v, Kind: ArrayRangeLen, RangeBegin: %v, RangeEnd: %v}", common(), generateType(a[0], desc, consts), beginStr, endStr)
}
- default:
- failf("wrong number of arguments for %v arg %v, want 1 or 2, got %v", typ, name, len(a))
}
case "ptr":
canBeArg = true