From 16c881ad8573b0bb87e8bfb0c71cba90b701e9a9 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 13 May 2019 18:52:46 +0200 Subject: pkg/compiler: generate complex len targets Change the generated format for len type to support multiple path elements. --- pkg/compiler/types.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/compiler/types.go b/pkg/compiler/types.go index d2d3380a6..6d9211686 100644 --- a/pkg/compiler/types.go +++ b/pkg/compiler/types.go @@ -220,9 +220,13 @@ var typeLen = &typeDesc{ case "bitsize": bitSize = 1 } + path := []string{args[0].Ident} + for _, col := range args[0].Colon { + path = append(path, col.Ident) + } return &prog.LenType{ IntTypeCommon: base, - Buf: args[0].Ident, + Path: path, BitSize: bitSize, } }, @@ -346,6 +350,9 @@ var typeCsum = &typeDesc{ if len(args) > 2 && genCsumKind(args[1]) != prog.CsumPseudo { comp.error(args[2].Pos, "only pseudo csum can have proto") } + if len(args[0].Colon) != 0 { + comp.error(args[0].Colon[0].Pos, "path expressions are not implemented for csum") + } }, Gen: func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon) prog.Type { var proto uint64 -- cgit mrf-deployment