From 710eefe85a976c438da255499fbefd1a6c989ef6 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 9 Jul 2018 20:47:07 +0200 Subject: pkg/compiler: support negative integers Currently we have to use 0xffffffffffffffff to represent -1, and we can't express e.g. -20:20 int range. Support negative consts to fix both problems. --- pkg/ast/ast.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'pkg/ast/ast.go') diff --git a/pkg/ast/ast.go b/pkg/ast/ast.go index 610d22f30..1e1e97221 100644 --- a/pkg/ast/ast.go +++ b/pkg/ast/ast.go @@ -169,19 +169,20 @@ func (n *String) Info() (Pos, string, string) { return n.Pos, tok2str[tokString], "" } -type intFmt int +type IntFmt int const ( - intFmtDec intFmt = iota - intFmtHex - intFmtChar + IntFmtDec IntFmt = iota + IntFmtNeg + IntFmtHex + IntFmtChar ) type Int struct { Pos Pos // Only one of Value, Ident, CExpr is filled. Value uint64 - valueFmt intFmt + ValueFmt IntFmt Ident string CExpr string } @@ -194,7 +195,7 @@ type Type struct { Pos Pos // Only one of Value, Ident, String is filled. Value uint64 - valueFmt intFmt + ValueFmt IntFmt Ident string String string HasString bool @@ -202,7 +203,7 @@ type Type struct { HasColon bool Pos2 Pos Value2 uint64 - value2Fmt intFmt + Value2Fmt IntFmt Ident2 string Args []*Type } -- cgit mrf-deployment