aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/ast/ast.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-07-09 20:47:07 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-07-09 20:47:07 +0200
commit710eefe85a976c438da255499fbefd1a6c989ef6 (patch)
tree3467ac95a3c574bdf41105e012df2e4c540ed859 /pkg/ast/ast.go
parentf25e57704183544b0d540ef0035acfa6fb9071d7 (diff)
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.
Diffstat (limited to 'pkg/ast/ast.go')
-rw-r--r--pkg/ast/ast.go15
1 files changed, 8 insertions, 7 deletions
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
}