From 002cecf2022de3ab01c87f905477aa3b063d73fc Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 2 Mar 2018 16:14:57 +0100 Subject: pkg/compiler: allow specifying static size for filename's Sometimes filenames are embed into structs and need to take fixed space. --- pkg/compiler/types.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pkg') 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, -- cgit mrf-deployment