Remove token ID/Key distinction, part 2 of N

This commit is contained in:
Nigel Tao committed 2018-04-15 10:58:53 +10:00
1 parent afd7429e9a
commit 7007682182
6 files changed
+67 -61

No files matched your search

+8 -9
View File
@@ -755,20 +755,19 @@ func (q *checker) bcheckExpr1(n *a.Expr, depth uint32) (*big.Int, *big.Int, erro
if cv := n.ConstValue(); cv != nil {
return cv, cv, nil
}
switch n.Operator().Flags() & (t.FlagsUnaryOp | t.FlagsBinaryOp | t.FlagsAssociativeOp) {
case 0:
return q.bcheckExprOther(n, depth)
case t.FlagsUnaryOp:
switch op := n.Operator(); {
case op.IsXUnaryOp():
return q.bcheckExprUnaryOp(n, depth)
case t.FlagsBinaryOp:
if n.Operator().Key() == t.KeyXBinaryAs {
case op.IsXBinaryOp():
if op.Key() == t.KeyXBinaryAs {
return q.bcheckExpr(n.LHS().Expr(), depth)
}
return q.bcheckExprBinaryOp(n.Operator().Key(), n.LHS().Expr(), n.RHS().Expr(), depth)
case t.FlagsAssociativeOp:
return q.bcheckExprBinaryOp(op.Key(), n.LHS().Expr(), n.RHS().Expr(), depth)
case op.IsXAssociativeOp():
return q.bcheckExprAssociativeOp(n, depth)
}
return nil, nil, fmt.Errorf("check: unrecognized token.Key (0x%X) for bcheckExpr", n.Operator().Key())
return q.bcheckExprOther(n, depth)
}
func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int, error) {
+7 -9
View File
@@ -349,25 +349,23 @@ func (q *checker) tcheckExpr(n *a.Expr, depth uint32) error {
}
depth++
switch n.Operator().Flags() & (t.FlagsUnaryOp | t.FlagsBinaryOp | t.FlagsAssociativeOp) {
case 0:
if err := q.tcheckExprOther(n, depth); err != nil {
return err
}
case t.FlagsUnaryOp:
switch op := n.Operator(); {
case op.IsXUnaryOp():
if err := q.tcheckExprUnaryOp(n, depth); err != nil {
return err
}
case t.FlagsBinaryOp:
case op.IsXBinaryOp():
if err := q.tcheckExprBinaryOp(n, depth); err != nil {
return err
}
case t.FlagsAssociativeOp:
case op.IsXAssociativeOp():
if err := q.tcheckExprAssociativeOp(n, depth); err != nil {
return err
}
default:
return fmt.Errorf("check: unrecognized token.Key (0x%X) for tcheckExpr", n.Operator().Key())
if err := q.tcheckExprOther(n, depth); err != nil {
return err
}
}
n.Node().SetTypeChecked()
return nil