MCPcopy
hub / github.com/google/mangle / BoundsCheck

Method BoundsCheck

analysis/validation.go:1025–1046  ·  view source on GitHub ↗

BoundsCheck checks whether the rules respect the bounds.

()

Source from the content-addressed store, hash-verified

1023
1024// BoundsCheck checks whether the rules respect the bounds.
1025func (bc *BoundsAnalyzer) BoundsCheck() error {
1026 predMap := make(map[string]ast.PredicateSym)
1027 for pred := range bc.programInfo.IdbPredicates {
1028 predMap[pred.Symbol] = pred
1029 }
1030 for pred := range bc.initialFactMap {
1031 predMap[pred.Symbol] = pred // overwrite ok
1032 }
1033 preds := make([]ast.PredicateSym, 0, len(predMap))
1034 for _, v := range predMap {
1035 preds = append(preds, v)
1036 }
1037 // Fix the order in which we do our checks.
1038 sort.Slice(preds, func(i, j int) bool { return preds[i].Symbol < preds[j].Symbol })
1039 for _, pred := range preds {
1040 if err := bc.inferAndCheckBounds(pred); err != nil {
1041 return err
1042 }
1043 }
1044
1045 return nil
1046}
1047
1048// Entry point for bounds checking.
1049func (bc *BoundsAnalyzer) inferAndCheckBounds(pred ast.PredicateSym) error {

Callers 6

TestBoundsAnalyzerFunction · 0.80
AnalyzeMethod · 0.80

Calls 1

inferAndCheckBoundsMethod · 0.95