aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorPaul Chaignon <paul.chaignon@orange.com>2019-10-26 15:31:00 +0200
committerDmitry Vyukov <dvyukov@google.com>2019-11-01 19:14:49 +0100
commit997ccc675b3dc049ad3ce922580397bd546956ea (patch)
tree969f40091b078b608f41d6668218724a732d2276 /pkg
parentf922d4435a79739a2abfdd4100f3eec10a5ef41b (diff)
pkg/compiler: define fileoff template
Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/compiler/testdata/errors.txt4
-rw-r--r--pkg/compiler/types.go16
2 files changed, 4 insertions, 16 deletions
diff --git a/pkg/compiler/testdata/errors.txt b/pkg/compiler/testdata/errors.txt
index 961de44b1..e0b003481 100644
--- a/pkg/compiler/testdata/errors.txt
+++ b/pkg/compiler/testdata/errors.txt
@@ -69,7 +69,7 @@ resource r6[int64be] ### int64be can't be resource base (int types can)
resource r9["foo"] ### unexpected string "foo", expect type
foo$7(a r0, a1 r2[opt])
-foo$8(a fileoff[a, b, c]) ### wrong number of arguments for type fileoff, expect no arguments
+foo$8(a fileoff[a, b, int8]) ### template fileoff needs 0 arguments instead of 3
foo$9(a buffer[inout])
foo$10(a buffer[intout]) ### unexpected value intout for direction argument of ptr type, expect [in out inout]
foo$11(a buffer["in"]) ### unexpected string "in" for direction argument of ptr type, expect [in out inout]
@@ -95,7 +95,7 @@ foo$33(a int8, b ptr[in, csum[a, pseudo, 1, int32]])
foo$34(a int32["foo"]) ### unexpected string "foo" for range argument of int32 type, expect int
foo$35(a ptr[in, s3[opt]]) ### s3 can't be marked as opt
foo$36(a const[1:2]) ### unexpected ':'
-foo$39(a fileoff:1) ### unexpected ':'
+foo$39(a fileoff:1) ### type alias fileoff with ':'
foo$40(a len["a"]) ### unexpected string "a" for len target argument of len type, expect identifier
foo$41(a vma[C1:C2])
foo$43(a ptr[in, string[1]]) ### unexpected int 1, string arg must be a string literal or string flags
diff --git a/pkg/compiler/types.go b/pkg/compiler/types.go
index 5bed71324..903c0957e 100644
--- a/pkg/compiler/types.go
+++ b/pkg/compiler/types.go
@@ -348,19 +348,6 @@ var typeArgFlags = &typeArg{
},
}
-var typeFileoff = &typeDesc{
- Names: []string{"fileoff"},
- CanBeArgRet: canBeArg,
- CantBeOpt: true,
- NeedBase: true,
- Gen: func(comp *compiler, t *ast.Type, args []*ast.Type, base prog.IntTypeCommon) prog.Type {
- return &prog.IntType{
- IntTypeCommon: base,
- Kind: prog.IntFileoff,
- }
- },
-}
-
var typeVMA = &typeDesc{
Names: []string{"vma", "vma64"},
CanBeArgRet: canBeArg,
@@ -915,6 +902,8 @@ type bool32 int32[0:1]
type bool64 int64[0:1]
type boolptr intptr[0:1]
+type fileoff[BASE] BASE
+
type filename string[filename]
filename = "", "."
@@ -935,7 +924,6 @@ func init() {
typeLen,
typeConst,
typeFlags,
- typeFileoff,
typeVMA,
typeCsum,
typeProc,