LookupProcedureByName() public method

public LookupProcedureByName ( string moduleName, string procName ) : Reko.Core.ExternalProcedure
moduleName string
procName string
return Reko.Core.ExternalProcedure
Example #1
0
        public void SysV_TerminatingFunction()
        {
            cfgSvc.Stub(c => c.GetInstallationRelativePath("libc.xml"))
                .Return("libc.xml");

            var env = new OperatingEnvironmentElement
            {
                TypeLibraries =
                     {
                         new TypeLibraryElement
                         {
                              Name="libc.xml"
                         }
                     },
                CharacteristicsLibraries =
                     {
                         new TypeLibraryElement
                         {
                             Name="libcharacteristics.xml",
                         }
                     }
            };

            Given_EnvironmentConfiguration(env);
            tlSvc.Stub(t => t.LoadCharacteristics(null))
                .IgnoreArguments()
                .Return(new CharacteristicsLibrary
                {
                    Entries =
                    {
                        {
                            "exit",
                            new ProcedureCharacteristics {
                                Terminates = true
                            }
                        }
                    }
                });
            tlSvc.Stub(t => t.LoadMetadataIntoLibrary(null, null, null))
                .IgnoreArguments()
                .Return(new TypeLibrary
                {
                    Signatures =
                    {
                         {
                            "exit",
                            new FunctionType()
                         }
                     }
                });
            mr.ReplayAll();

            var sysv = new SysVPlatform(sc, arch);
            var proc = sysv.LookupProcedureByName(null, "exit");
            Assert.IsTrue(proc.Characteristics.Terminates, "exit should have been marked as terminating.");
        }
Example #2
0
        public void SysV_TerminatingFunction()
        {
            var mr = new MockRepository();
            var sc = new ServiceContainer();
            var arch = mr.Stub<IProcessorArchitecture>();
            var tlSvc = mr.Stub<ITypeLibraryLoaderService>();
            var cfgSvc = mr.Stub<IConfigurationService>();
            sc.AddService<IConfigurationService>(cfgSvc);
            sc.AddService<ITypeLibraryLoaderService>(tlSvc);
            cfgSvc.Stub(c => c.GetEnvironment(null))
                .IgnoreArguments()
                .Return(new OperatingEnvironmentElement
                {
                     TypeLibraries = 
                     {
                         new TypeLibraryElement 
                         {
                              Name="libc.xml"
                         }
                     },
                     CharacteristicsLibraries =
                     {
                         new TypeLibraryElement
                         {
                             Name="libcharacteristics.xml",
                         }
                     }
                });
            tlSvc.Stub(t => t.LoadCharacteristics(null))
                .IgnoreArguments()
                .Return(new CharacteristicsLibrary
                {
                    Entries =
                    {
                        { 
                            "exit", 
                            new ProcedureCharacteristics {
                                Terminates = true
                            }
                        }
                    }
                });
            tlSvc.Stub(t => t.LoadLibrary(null, null))
                .IgnoreArguments()
                .Return(new TypeLibrary
                {
                    Signatures =
                    {
                         {
                            "exit",
                            new ProcedureSignature(null)
                         }
                     }
                });
            mr.ReplayAll();

            var sysv = new SysVPlatform(sc, arch);
            var proc = sysv.LookupProcedureByName(null, "exit");
            Assert.IsTrue(proc.Characteristics.Terminates, "exit should have been marked as terminating.");
        }