mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-26 01:01:35 +01:00
Introduce "pre" and "post" asserts.
This commit is contained in:
1 parent
dd06f67f7a
commit
1d3ae23418
7 files changed
+120
-44
No files matched your search
@@ -79,6 +79,7 @@ var phases = [...]struct {
|
||||
{a.KUse, (*Checker).checkUse},
|
||||
{a.KStruct, (*Checker).checkStruct},
|
||||
{a.KFunc, (*Checker).checkFuncSignature},
|
||||
{a.KFunc, (*Checker).checkFuncContract},
|
||||
{a.KFunc, (*Checker).checkFuncBody},
|
||||
}
|
||||
|
||||
@@ -168,6 +169,23 @@ func (c *Checker) checkFuncSignature(n *a.Node) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Checker) checkFuncContract(n *a.Node) error {
|
||||
as := n.Func().Asserts()
|
||||
if len(as) == 0 {
|
||||
return nil
|
||||
}
|
||||
tc := &typeChecker{
|
||||
c: c,
|
||||
idMap: c.idMap,
|
||||
}
|
||||
for _, a := range as {
|
||||
if err := tc.checkAssert(a.Assert()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Checker) checkFuncBody(n *a.Node) error {
|
||||
f := n.Func()
|
||||
tc := &typeChecker{
|
||||
|
||||
Reference in new issue
Block a user