Exemple #1
0
                private SimpleArrayPropertiesAbstractDomain <BoxedVariable <Variable>, BoxedExpression> AdaptPartition(
                    BoxedVariable <Variable> array,
                    SimpleArrayPropertiesAbstractDomain <BoxedVariable <Variable>, BoxedExpression> dataContents,
                    IPartitionAbstraction <BoxedVariable <Variable>, BoxedExpression> fromPartition,
                    IPartitionAbstraction <BoxedVariable <Variable>, BoxedExpression> toPartition)
                {
                    // Assumption: fromPartition is not top
                    if (fromPartition.IsTop)
                    {
                        throw new AbstractInterpretationException();
                    }

                    var transformMap = fromPartition.TransformationMapFor(toPartition);

                    dataContents.TransformArray(array, transformMap);

                    return(dataContents);
                }
Exemple #2
0
                private SimpleArrayPropertiesAbstractDomain <BoxedVariable <Variable>, BoxedExpression> Normalize(
                    BoxedVariable <Variable> array,
                    SimpleArrayPropertiesAbstractDomain <BoxedVariable <Variable>,
                                                         BoxedExpression> dataContents,
                    INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression> dataIndexes,
                    IPartitionAbstraction <BoxedVariable <Variable>, BoxedExpression> partition)
                {
                    if (dataIndexes.IsBottom)
                    {
                        // TODO
                    }

                    var knowledge = dataIndexes.To <BoxedExpression>(new BoxedExpressionFactory <Local, Parameter, Method, Field, Property, Type, Attribute, Assembly>(this.DecoderForMetaData));

                    var emptyDimensions = partition.EmptyDimensionsInContext(knowledge);

                    dataContents.SimplifyArray(array, emptyDimensions);

                    return(dataContents);
                }
Exemple #3
0
                private SimpleArrayPropertiesAbstractDomain <BoxedVariable <Variable>, BoxedExpression> HandleAllocations(APC pc, Type type, Variable dest, Variable len, SimpleArrayPropertiesAbstractDomain <BoxedVariable <Variable>, BoxedExpression> contentsData)
                {
                    //SimplePartitionAbstractDomain<BoxedVariable<Variable>, BoxedExpression> prevPartitions;

                    //if (this.partitions.TryPartitionAt(pc, out prevPartitions))
                    //{
                    //  var destAsExp = BoxedExpression.For(this.Context.Refine(pc, dest), this.Decoder.Outdecoder);
                    //  IPartitionAbstraction<BoxedVariable<Variable>, BoxedExpression> prevPartition;

                    //  if (prevPartitions.TryGetValue(destAsExp, out prevPartition))
                    //  {
                    //    throw new AbstractInterpretationException(); // TODO : avoid above code, assuming that there is no partition before
                    //  }
                    //  else
                    //  {

                    SimplePartitionAbstractDomain <BoxedVariable <Variable>, BoxedExpression> postPartitions;

                    if (this.partitions.TryPartitionAt(this.Context.Post(pc), out postPartitions))
                    {
                        // var destAsExp = BoxedExpression.For(this.Context.Refine(pc, dest), this.Decoder.Outdecoder);

                        var destB = new BoxedVariable <Variable>(dest);

                        IPartitionAbstraction <BoxedVariable <Variable>, BoxedExpression> postPartition;

                        if (postPartitions.TryGetValue(destB, out postPartition))
                        {
                            var lenAsExp = BoxedExpression.For(this.Context.Refine(pc, len), this.Decoder.Outdecoder);
                            lenAsExp = this.Decoder.Stripped(lenAsExp);

                            var sliceRep = postPartition.Representative();

                            var lowerConstraint = this.Encoder.CompoundExpressionFor(ExpressionType.Bool,
                                                                                     ExpressionOperator.GreaterEqualThan,
                                                                                     this.Encoder.VariableFor(sliceRep),
                                                                                     this.Encoder.ConstantFor(0));

                            var greaterConstraint = this.Encoder.CompoundExpressionFor(ExpressionType.Bool,
                                                                                       ExpressionOperator.LessThan,
                                                                                       this.Encoder.VariableFor(sliceRep),
                                                                                       lenAsExp);

                            var bodyConstraint = this.Encoder.CompoundExpressionFor(ExpressionType.Bool, ExpressionOperator.And, lowerConstraint, greaterConstraint);

                            var touchedDimensions = postPartition.DimensionsTouchedBy(bodyConstraint, new Set <BoxedVariable <Variable> >());

                            touchedDimensions = touchedDimensions.FindAll(e => e.Two == TouchKind.Strong);

                            if (touchedDimensions.Count == 1)
                            {
                                var             touchedDimension = touchedDimensions.PickAnElement();
                                var             bodyDimension    = touchedDimension.One;
                                BoxedExpression defaultValue;

                                var b = TryDefaultValue(type, out defaultValue);
                                contentsData.CreateArray(destB, postPartition.Dimensions(), bodyDimension, defaultValue);
                            }
                            else
                            {
                                throw new AbstractInterpretationException();
                            }
                        }
                        else
                        {
                            throw new AbstractInterpretationException();
                        }
                        //}
                        //else
                        //{
                        //  throw new AbstractInterpretationException();
                        //}
                    }

                    return(contentsData);
                }