mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 00:47:28 +01:00
Add a TypeExpr type expression
This commit is contained in:
1 parent
295cbbccae
commit
731ca8841b
5 files changed
+39
-29
No files matched your search
+12
-8
@@ -682,17 +682,21 @@ func allTypeChecked(tm *t.Map, n *a.Node) error {
|
||||
return fmt.Errorf("check: internal error: unchecked %s", nodeDebugString(tm, o))
|
||||
}
|
||||
|
||||
typOK := false
|
||||
switch o.Kind() {
|
||||
default:
|
||||
if typ != typeExprPlaceholder {
|
||||
return fmt.Errorf("check: internal error: %s does not have placeholder type", nodeDebugString(tm, o))
|
||||
}
|
||||
|
||||
case a.KExpr:
|
||||
if typ == typeExprPlaceholder {
|
||||
return fmt.Errorf("check: internal error: %s has placeholder type", nodeDebugString(tm, o))
|
||||
}
|
||||
typOK = typ != typeExprPlaceholder && typ != typeExprTypeExpr
|
||||
case a.KTypeExpr:
|
||||
typOK = typ == typeExprTypeExpr
|
||||
default:
|
||||
typOK = typ == typeExprPlaceholder
|
||||
}
|
||||
if !typOK {
|
||||
return fmt.Errorf("check: internal error: %s has incorrect type, %s",
|
||||
nodeDebugString(tm, o), typ.Str(tm))
|
||||
}
|
||||
|
||||
if o.Kind() == a.KExpr {
|
||||
o := o.AsExpr()
|
||||
if typ.IsIdeal() && o.ConstValue() == nil {
|
||||
return fmt.Errorf("check: internal error: expression %q has ideal number type "+
|
||||
|
||||
@@ -36,9 +36,10 @@ var (
|
||||
var (
|
||||
typeExprGeneric1 = a.NewTypeExpr(0, t.IDBase, t.IDDagger1, nil, nil, nil)
|
||||
typeExprGeneric2 = a.NewTypeExpr(0, t.IDBase, t.IDDagger2, nil, nil, nil)
|
||||
typeExprIdeal = a.NewTypeExpr(0, t.IDBase, t.IDDoubleZ, nil, nil, nil)
|
||||
typeExprIdeal = a.NewTypeExpr(0, t.IDBase, t.IDQIdeal, nil, nil, nil)
|
||||
typeExprList = a.NewTypeExpr(0, t.IDBase, t.IDDollar, nil, nil, nil)
|
||||
typeExprPlaceholder = a.NewTypeExpr(0, t.IDBase, t.IDPilcrow, nil, nil, nil)
|
||||
typeExprPlaceholder = a.NewTypeExpr(0, t.IDBase, t.IDQPlaceholder, nil, nil, nil)
|
||||
typeExprTypeExpr = a.NewTypeExpr(0, t.IDBase, t.IDQTypeExpr, nil, nil, nil)
|
||||
|
||||
typeExprU8 = a.NewTypeExpr(0, t.IDBase, t.IDU8, nil, nil, nil)
|
||||
typeExprU16 = a.NewTypeExpr(0, t.IDBase, t.IDU16, nil, nil, nil)
|
||||
|
||||
+1
-1
@@ -1001,7 +1001,7 @@ swtch:
|
||||
default:
|
||||
return fmt.Errorf("check: %q is not a type", typ.Str(q.tm))
|
||||
}
|
||||
setPlaceholderMBoundsMType(typ.AsNode())
|
||||
typ.AsNode().SetMType(typeExprTypeExpr)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user