mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 00:52:18 +01:00
Add checker.bcheckExprOther.
This commit is contained in:
1 parent
d323440511
commit
c736c1c509
1 file changed
+45
-6
+45
-6
@@ -214,17 +214,17 @@ func (q *checker) bcheckExpr(n *a.Expr, depth uint32) (*big.Int, *big.Int, error
|
|||||||
|
|
||||||
switch n.ID0().Flags() & (t.FlagsUnaryOp | t.FlagsBinaryOp | t.FlagsAssociativeOp) {
|
switch n.ID0().Flags() & (t.FlagsUnaryOp | t.FlagsBinaryOp | t.FlagsAssociativeOp) {
|
||||||
case 0:
|
case 0:
|
||||||
nMin, nMax, err := q.bcheckTypeExpr(n.MType())
|
return q.bcheckExprOther(n, depth)
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
nMin, nMax = q.facts.refine(n, nMin, nMax)
|
|
||||||
return nMin, nMax, nil
|
|
||||||
case t.FlagsUnaryOp:
|
case t.FlagsUnaryOp:
|
||||||
return q.bcheckExprUnaryOp(n, depth)
|
return q.bcheckExprUnaryOp(n, depth)
|
||||||
case t.FlagsBinaryOp:
|
case t.FlagsBinaryOp:
|
||||||
if n.ID0().Key() == t.KeyXBinaryAs {
|
if n.ID0().Key() == t.KeyXBinaryAs {
|
||||||
|
lMin, lMax, err := q.bcheckExpr(n.LHS().Expr(), depth)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
// TODO.
|
// TODO.
|
||||||
|
_, _ = lMin, lMax
|
||||||
return zero, zero, nil
|
return zero, zero, nil
|
||||||
}
|
}
|
||||||
return q.bcheckExprBinaryOp(n.LHS().Expr(), n.ID0().Key(), n.RHS().Expr(), depth)
|
return q.bcheckExprBinaryOp(n.LHS().Expr(), n.ID0().Key(), n.RHS().Expr(), depth)
|
||||||
@@ -234,6 +234,40 @@ func (q *checker) bcheckExpr(n *a.Expr, depth uint32) (*big.Int, *big.Int, error
|
|||||||
return nil, nil, fmt.Errorf("check: unrecognized token.Key (0x%X) for bcheckExpr", n.ID0().Key())
|
return nil, nil, fmt.Errorf("check: unrecognized token.Key (0x%X) for bcheckExpr", n.ID0().Key())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int, error) {
|
||||||
|
switch n.ID0().Key() {
|
||||||
|
case 0:
|
||||||
|
// No-op.
|
||||||
|
|
||||||
|
case t.KeyOpenParen:
|
||||||
|
// TODO.
|
||||||
|
return nil, nil, fmt.Errorf("check: unrecognized token.Key (0x%X) for bcheckExprOther", n.ID0().Key())
|
||||||
|
|
||||||
|
case t.KeyOpenBracket:
|
||||||
|
// TODO.
|
||||||
|
return nil, nil, fmt.Errorf("check: unrecognized token.Key (0x%X) for bcheckExprOther", n.ID0().Key())
|
||||||
|
|
||||||
|
case t.KeyColon:
|
||||||
|
// TODO.
|
||||||
|
return nil, nil, fmt.Errorf("check: unrecognized token.Key (0x%X) for bcheckExprOther", n.ID0().Key())
|
||||||
|
|
||||||
|
case t.KeyDot:
|
||||||
|
if _, _, err := q.bcheckExpr(n.LHS().Expr(), depth); err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return nil, nil, fmt.Errorf("check: unrecognized token.Key (0x%X) for bcheckExprOther", n.ID0().Key())
|
||||||
|
}
|
||||||
|
|
||||||
|
nMin, nMax, err := q.bcheckTypeExpr(n.MType())
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
nMin, nMax = q.facts.refine(n, nMin, nMax)
|
||||||
|
return nMin, nMax, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (q *checker) bcheckExprUnaryOp(n *a.Expr, depth uint32) (*big.Int, *big.Int, error) {
|
func (q *checker) bcheckExprUnaryOp(n *a.Expr, depth uint32) (*big.Int, *big.Int, error) {
|
||||||
rMin, rMax, err := q.bcheckExpr(n.RHS().Expr(), depth)
|
rMin, rMax, err := q.bcheckExpr(n.RHS().Expr(), depth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -297,6 +331,11 @@ func (q *checker) bcheckExprAssociativeOp(n *a.Expr, depth uint32) (*big.Int, *b
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (q *checker) bcheckTypeExpr(n *a.TypeExpr) (*big.Int, *big.Int, error) {
|
func (q *checker) bcheckTypeExpr(n *a.TypeExpr) (*big.Int, *big.Int, error) {
|
||||||
|
switch n.PackageOrDecorator().Key() {
|
||||||
|
case t.KeyPtr, t.KeyOpenBracket:
|
||||||
|
return nil, nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
b := [2]*big.Int{}
|
b := [2]*big.Int{}
|
||||||
if key := n.Name().Key(); key < t.Key(len(numTypeBounds)) {
|
if key := n.Name().Key(); key < t.Key(len(numTypeBounds)) {
|
||||||
b = numTypeBounds[key]
|
b = numTypeBounds[key]
|
||||||
|
|||||||
Reference in new issue
Block a user