Пример #1
0
            private void MapOutputPortsMethod(Plan p, Collection <int> path, string freshvar)
            {
                // Map receiver.
                Plan.ParameterChooser c           = p.parameterChoosers[0];
                OutPortId             pOutputPort = new OutPortId(path, 0);

                path.Add(c.planIndex);
                OutPortId recPort = new OutPortId(path, c.resultIndex);

                path.RemoveAt(path.Count - 1);
                foobar.set(pOutputPort, foobar.Get(recPort));

                // Map return value.
                MethodCall mct = p.transformer as MethodCall;

                if (!mct.method.ReturnType.Equals(typeof(void)))
                {
                    OutPortId newObjPort = new OutPortId(path, 1);
                    foobar.set(newObjPort, freshvar);
                }

                // Map mutated parameters.
                // Start from 1 because already handled receiver.
                for (int i = 1; i < p.parameterChoosers.Length; i++)
                {
                    c           = p.parameterChoosers[i];
                    pOutputPort = new OutPortId(path, i + 1); // Add 1 because of retval.
                    path.Add(c.planIndex);
                    OutPortId paramPort = new OutPortId(path, c.resultIndex);
                    path.RemoveAt(path.Count - 1);
                    foobar.set(pOutputPort, foobar.Get(paramPort));
                }
            }
Пример #2
0
            private void MapOutputPortsPrimitive(Plan p, Collection <int> path, string freshvar)
            {
                // Map primitive.
                OutPortId newObjPort = new OutPortId(path, 0);

                foobar.set(newObjPort, freshvar);
            }
Пример #3
0
            private void HandlePrimitive(Plan p, Collection <int> path)
            {
                OutPortId newPort = new OutPortId(path, 0);
                string    newName = nameManager.foobar.Get(newPort);

                b.Add(p.transformer.ToCSharpCode(new ReadOnlyCollection <string>(new List <string>()), newName));
            }
Пример #4
0
            private void HandleMethod(Plan p, Collection <int> path)
            {
                MethodCall mct      = p.transformer as MethodCall;
                string     freshvar = null;

                if (!mct.method.ReturnType.Equals(typeof(void)))
                {
                    OutPortId newObjPort = new OutPortId(path, 1);
                    freshvar = nameManager.foobar.Get(newObjPort);
                }


                Collection <string> arguments = new Collection <string>();

                for (int i = 0; i < p.parameterChoosers.Length; i++)
                {
                    if (i == 0 && mct.method.IsStatic)
                    {
                        arguments.Add(null);
                        continue;
                    }
                    Plan.ParameterChooser c = p.parameterChoosers[i];
                    path.Add(c.planIndex);
                    OutPortId paramPort = new OutPortId(path, c.resultIndex);
                    path.RemoveAt(path.Count - 1);
                    arguments.Add(nameManager.foobar.Get(paramPort));
                }
                b.Add(p.transformer.ToCSharpCode(new ReadOnlyCollection <string>(arguments), freshvar));
            }
Пример #5
0
            public void set(OutPortId id, string s)
            {
                bool alreadyThere = keys.Contains(id.ToString());

                int keySize = names.Keys.Count;

                if (names.ContainsKey(id) && !namesghost.ContainsKey(id.ToString()))
                {
                    throw new Exception();
                }

                names[id] = s;
                namesghost[id.ToString()] = s;

                if (names.Keys.Count != namesghost.Keys.Count)
                {
                    throw new Exception();
                }

                if (alreadyThere && keySize < names.Keys.Count)
                {
                    throw new Exception();
                }

                keys.Add(id.ToString());
            }
Пример #6
0
            private void MapOutputPortsFieldSetter(Plan p, Collection <int> path, string freshvar)
            {
                // Map receiver.
                Plan.ParameterChooser c           = p.parameterChoosers[0];
                OutPortId             pOutputPort = new OutPortId(path, 0);

                path.Add(c.planIndex);
                OutPortId recPort = new OutPortId(path, c.resultIndex);

                path.RemoveAt(path.Count - 1);
                foobar.set(pOutputPort, foobar.Get(recPort));
            }
Пример #7
0
            private void HandleField(Plan p, Collection <int> path)
            {
                Collection <string> args = new Collection <string>();

                for (int i = 0; i < p.parameterChoosers.Length; i++)
                {
                    Plan.ParameterChooser c = p.parameterChoosers[i];
                    path.Add(c.planIndex);
                    OutPortId paramPort = new OutPortId(path, c.resultIndex);
                    path.RemoveAt(path.Count - 1);
                    args.Add(nameManager.foobar.Get(paramPort));
                }
                b.Add(p.transformer.ToCSharpCode(new ReadOnlyCollection <string>(args), "dummy"));
            }
Пример #8
0
            public override bool Equals(object obj)
            {
                OutPortId other  = obj as OutPortId;
                bool      retval = true;

                if (other == null)
                {
                    retval = false;
                }
                else if (this.i != other.i)
                {
                    retval = false;
                }
                else if (this.list.Count != other.list.Count)
                {
                    retval = false;
                }
                else
                {
                    for (int c = 0; c < this.list.Count; c++)
                    {
                        if (this.list[c] != other.list[c])
                        {
                            retval = false;
                            break;
                        }
                    }
                }

                string s1 = this.ToString();
                string s2 = other.ToString();

                if (retval == true && this.GetHashCode() != other.GetHashCode())
                {
                    throw new Exception();
                }
                if (retval == false && s1.Equals(s2))
                {
                    throw new Exception();
                }
                if (retval == true && !s1.Equals(s2))
                {
                    throw new Exception();
                }

                return(retval);
            }
Пример #9
0
            private void HandleArray(Plan p, Collection <int> path)
            {
                OutPortId newObjPort = new OutPortId(path, 0);
                string    newObjName = nameManager.foobar.Get(newObjPort);

                Collection <string> args = new Collection <string>();

                for (int i = 0; i < p.parameterChoosers.Length; i++)
                {
                    Plan.ParameterChooser c = p.parameterChoosers[i];
                    path.Add(c.planIndex);
                    OutPortId paramPort = new OutPortId(path, c.resultIndex);
                    path.RemoveAt(path.Count - 1);
                    args.Add(nameManager.foobar.Get(paramPort));
                }
                b.Add(p.transformer.ToCSharpCode(new ReadOnlyCollection <string>(args), nameManager.foobar.Get(newObjPort), useRandoopContracts, p.CanGenerateContractAssertion));
            }
Пример #10
0
            private void MapOutputPortsConstructor(Plan p, Collection <int> path, string freshvar)
            {
                // Map new object.
                OutPortId newObjPort = new OutPortId(path, 0);

                foobar.set(newObjPort, freshvar);

                // Map mutated parameters.
                for (int i = 0; i < p.parameterChoosers.Length; i++)
                {
                    Plan.ParameterChooser c           = p.parameterChoosers[i];
                    OutPortId             pOutputPort = new OutPortId(path, i + 1);
                    path.Add(c.planIndex);
                    OutPortId paramPort = new OutPortId(path, c.resultIndex);
                    path.RemoveAt(path.Count - 1);
                    foobar.set(pOutputPort, foobar.Get(paramPort));
                }
            }
Пример #11
0
            private void HandleArray(Plan p, Collection<int> path)
            {
                OutPortId newObjPort = new OutPortId(path, 0);
                string newObjName = nameManager.foobar.Get(newObjPort);

                Collection<string> args = new Collection<string>();
                for (int i = 0; i < p.parameterChoosers.Length; i++)
                {
                    Plan.ParameterChooser c = p.parameterChoosers[i];
                    path.Add(c.planIndex);
                    OutPortId paramPort = new OutPortId(path, c.resultIndex);
                    path.RemoveAt(path.Count - 1);
                    args.Add(nameManager.foobar.Get(paramPort));
                }
                b.Add(p.transformer.ToCSharpCode(new ReadOnlyCollection<string>(args), nameManager.foobar.Get(newObjPort)));
            }
Пример #12
0
            private void HandleMethod(Plan p, Collection<int> path)
            {
                MethodCall mct = p.transformer as MethodCall;
                string freshvar = null;
                if (!mct.method.ReturnType.Equals(typeof(void)))
                {
                    OutPortId newObjPort = new OutPortId(path, 1);
                    freshvar = nameManager.foobar.Get(newObjPort);
                }


                Collection<string> arguments = new Collection<string>();

                for (int i = 0; i < p.parameterChoosers.Length; i++)
                {
                    if (i == 0 && mct.method.IsStatic)
                    {
                        arguments.Add(null);
                        continue;
                    }
                    Plan.ParameterChooser c = p.parameterChoosers[i];
                    path.Add(c.planIndex);
                    OutPortId paramPort = new OutPortId(path, c.resultIndex);
                    path.RemoveAt(path.Count - 1);
                    arguments.Add(nameManager.foobar.Get(paramPort));
                }
                b.Add(p.transformer.ToCSharpCode(new ReadOnlyCollection<string>(arguments), freshvar));
            }
Пример #13
0
 private void HandlePrimitive(Plan p, Collection<int> path)
 {
     OutPortId newPort = new OutPortId(path, 0);
     string newName = nameManager.foobar.Get(newPort);
     b.Add(p.transformer.ToCSharpCode(new ReadOnlyCollection<string>(new List<string>()), newName));
 }
Пример #14
0
            private void MapOutputPortsMethod(Plan p, Collection<int> path, string freshvar)
            {
                // Map receiver.
                Plan.ParameterChooser c = p.parameterChoosers[0];
                OutPortId pOutputPort = new OutPortId(path, 0);
                path.Add(c.planIndex);
                OutPortId recPort = new OutPortId(path, c.resultIndex);
                path.RemoveAt(path.Count - 1);
                foobar.set(pOutputPort, foobar.Get(recPort));

                // Map return value.
                MethodCall mct = p.transformer as MethodCall;
                if (!mct.method.ReturnType.Equals(typeof(void)))
                {
                    OutPortId newObjPort = new OutPortId(path, 1);
                    foobar.set(newObjPort, freshvar);
                }

                // Map mutated parameters.
                // Start from 1 because already handled receiver.
                for (int i = 1; i < p.parameterChoosers.Length; i++)
                {
                    c = p.parameterChoosers[i];
                    pOutputPort = new OutPortId(path, i + 1); // Add 1 because of retval.
                    path.Add(c.planIndex);
                    OutPortId paramPort = new OutPortId(path, c.resultIndex);
                    path.RemoveAt(path.Count - 1);
                    foobar.set(pOutputPort, foobar.Get(paramPort));
                }
            }
Пример #15
0
            private void MapOutputPortsConstructor(Plan p, Collection<int> path, string freshvar)
            {
                // Map new object.
                OutPortId newObjPort = new OutPortId(path, 0);
                foobar.set(newObjPort, freshvar);

                // Map mutated parameters.
                for (int i = 0; i < p.parameterChoosers.Length; i++)
                {
                    Plan.ParameterChooser c = p.parameterChoosers[i];
                    OutPortId pOutputPort = new OutPortId(path, i + 1);
                    path.Add(c.planIndex);
                    OutPortId paramPort = new OutPortId(path, c.resultIndex);
                    path.RemoveAt(path.Count - 1);
                    foobar.set(pOutputPort, foobar.Get(paramPort));
                }
            }
Пример #16
0
 private void MapOutputPortsFieldSetter(Plan p, Collection<int> path, string freshvar)
 {
     // Map receiver.
     Plan.ParameterChooser c = p.parameterChoosers[0];
     OutPortId pOutputPort = new OutPortId(path, 0);
     path.Add(c.planIndex);
     OutPortId recPort = new OutPortId(path, c.resultIndex);
     path.RemoveAt(path.Count - 1);
     foobar.set(pOutputPort, foobar.Get(recPort));
 }
Пример #17
0
 private void MapOutputPortsPrimitive(Plan p, Collection<int> path, string freshvar)
 {
     // Map primitive.
     OutPortId newObjPort = new OutPortId(path, 0);
     foobar.set(newObjPort, freshvar);
 }
Пример #18
0
 private void MapOutputPortsDummy(Plan p, Collection<int> path, string freshvar)
 {
     OutPortId newObjPort = new OutPortId(path, 0);
     foobar.set(newObjPort, freshvar);
 }
Пример #19
0
            public void set(OutPortId id, string s)
            {
                bool alreadyThere = keys.Contains(id.ToString());

                int keySize = names.Keys.Count;

                if (names.ContainsKey(id) && !namesghost.ContainsKey(id.ToString()))
                    throw new Exception();

                names[id] = s;
                namesghost[id.ToString()] = s;

                if (names.Keys.Count != namesghost.Keys.Count)
                    throw new Exception();

                if (alreadyThere && keySize < names.Keys.Count)
                    throw new Exception();

                keys.Add(id.ToString());

            }
Пример #20
0
 public string Get(OutPortId id)
 {
     return names[id];
 }
Пример #21
0
 public string Get(OutPortId id)
 {
     return(names[id]);
 }
Пример #22
0
            private void MapOutputPortsDummy(Plan p, Collection <int> path, string freshvar)
            {
                OutPortId newObjPort = new OutPortId(path, 0);

                foobar.set(newObjPort, freshvar);
            }