Add a "deref" unary operator.

This commit is contained in:
Nigel Tao committed 2017-10-20 15:44:30 +11:00
1 parent 51bd52239b
commit 2cd6ebed8e
8 files changed
+55 -53

No files matched your search

+6 -11
View File
@@ -362,14 +362,7 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
}
func (g *gen) writeExprUnaryOp(b *buffer, n *a.Expr, rp replacementPolicy, pp parenthesesPolicy, depth uint32) error {
switch n.ID0().Key() {
case t.KeyXUnaryPlus:
b.writeb('+')
case t.KeyXUnaryMinus:
b.writeb('-')
case t.KeyXUnaryNot:
b.writeb('!')
}
b.writes(cOpNames[0xFF&n.ID0().Key()])
return g.writeExpr(b, n.RHS().Expr(), rp, parenthesesMandatory, depth)
}
@@ -528,9 +521,11 @@ var cOpNames = [256]string{
t.KeyPercentEq: " %= ",
t.KeyTildePlusEq: " += ",
t.KeyXUnaryPlus: "+",
t.KeyXUnaryMinus: "-",
t.KeyXUnaryNot: "!",
t.KeyXUnaryPlus: " + ",
t.KeyXUnaryMinus: " - ",
t.KeyXUnaryNot: " ! ",
t.KeyXUnaryRef: " & ",
t.KeyXUnaryDeref: " * ",
t.KeyXBinaryPlus: " + ",
t.KeyXBinaryMinus: " - ",