Ejemplo n.º 1
0
        private IADomain RecAssignTransfer(RecAssignStmt recAssignStmt, IADomain domain)
        {
            var newDomain = CopyDomain(domain);

            if (domain.IsBottom())
            {
                return(newDomain);
            }

            for (int i = 0; i < recAssignStmt.Left.Children.Count; i++)
            {
                var ident = recAssignStmt.Left.Children[i];
                var expr  = recAssignStmt.Right[i];

                var newInterval = IAUtil.Arithmetic(expr, domain);
                if (newInterval.IsBottom)
                {
                    return(Bottom().GetDomain());
                }

                newDomain[ident] = newInterval.ToIntervalK(_program);
            }

            return(newDomain);
        }
Ejemplo n.º 2
0
        private IADomain ReadTransfer(ReadStmt readStmt, IADomain domain)
        {
            var newDomain = CopyDomain(domain);

            if (domain.IsBottom())
            {
                return(newDomain);
            }

            var ident = readStmt.Left switch
            {
                VarAccess varAccess => varAccess.Left,
                ArrayAccess arrayAccess => arrayAccess.Left,
                RecordAccess recordAccess => recordAccess.Right,
            };

            if (readStmt.Left is ArrayAccess)
            {
                var ra            = readStmt.Left as ArrayAccess;
                var indexInterval = IAUtil.Arithmetic(ra.Right, domain);
                if (indexInterval.IsBottom)
                {
                    return(Bottom().GetDomain());
                }
            }

            newDomain[ident] = new Interval(ExtendedZ.NegativeInfinity(), ExtendedZ.PositiveInfinity()).ToIntervalK(_program);
            return(newDomain);
        }
Ejemplo n.º 3
0
        private IADomain AssignTransfer(AssignStmt assignStmt, IADomain domain)
        {
            var newDomain = CopyDomain(domain);

            if (domain.IsBottom())
            {
                return(newDomain);
            }

            var ident = assignStmt.Left switch
            {
                VarAccess varAccess => varAccess.Left,
                ArrayAccess arrayAccess => arrayAccess.Left,
                RecordAccess recordAccess => recordAccess.Right,
            };

            var newValue = assignStmt.Left switch
            {
                VarAccess varAccess => IAUtil.Arithmetic(assignStmt.Right, domain),
                RecordAccess recordAccess => IAUtil.Arithmetic(assignStmt.Right, domain),
                ArrayAccess arrayAccess => IAUtil.Arithmetic(assignStmt.Right, domain)
                .Join(domain[ident]),
                //.Join(IAUtil.Arithmetic(arrayAccess.Right, domain)),
            };

            if (assignStmt.Left is ArrayAccess)
            {
                var ra            = assignStmt.Left as ArrayAccess;
                var indexInterval = IAUtil.Arithmetic(ra.Right, domain);
                if (indexInterval.IsBottom)
                {
                    return(Bottom().GetDomain());
                }

                var arrayIndices = new Interval(new ExtendedZ(0), new ExtendedZ(ra.Left.Size - 1));
                var meet         = indexInterval.Meet(arrayIndices);
                if (indexInterval.Meet(arrayIndices).IsBottom)
                {
                    return(Bottom().GetDomain());
                }
            }

            if (newValue.IsBottom)
            {
                return(Bottom().GetDomain());
            }

            newDomain[ident] = newValue.ToIntervalK(_program);
            return(newDomain);
        }