diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-03-02 16:14:57 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-03-05 12:10:27 +0100 |
| commit | 002cecf2022de3ab01c87f905477aa3b063d73fc (patch) | |
| tree | 674ee06d247de287e04017600f7fc52dc7ba58ec /pkg/compiler | |
| parent | 5ef8dbdf5a63ccf7e069527dbb2493dc2ef0c319 (diff) | |
pkg/compiler: allow specifying static size for filename's
Sometimes filenames are embed into structs and need to take fixed space.
Diffstat (limited to 'pkg/compiler')
| -rw-r--r-- | pkg/compiler/types.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pkg/compiler/types.go b/pkg/compiler/types.go index a7734262a..f5ec1221e 100644 --- a/pkg/compiler/types.go +++ b/pkg/compiler/types.go @@ -264,11 +264,19 @@ var typeArgFlags = &typeArg{ var typeFilename = &typeDesc{ Names: []string{"filename"}, CantBeOpt: true, + OptArgs: 1, + Args: []namedArg{{"size", typeArgInt}}, Varlen: func(comp *compiler, t *ast.Type, args []*ast.Type) bool { + if len(args) >= 1 { + return false + } return true }, Gen: func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon) prog.Type { base.TypeSize = 0 + if len(args) >= 1 { + base.TypeSize = args[0].Value + } return &prog.BufferType{ TypeCommon: base.TypeCommon, Kind: prog.BufferFilename, |
