Beispiel #1
0
    private void LoadPanel(PageType page)
    {
        string   prefabPath = ControllerDic[page].controller.getPanel.GetPrefabPath();
        MyLoader loader     = new MyLoader();

        loader.LoadPrefab(prefabPath, 1, onLoaded, page);
    }
Beispiel #2
0
 public InterproceduralManager(MyLoader loader)
 {
     this.loader         = loader;
     this.host           = loader.Host;
     this.CFGCache       = new MethodCFGCache(loader);
     this.stackDepth     = 0;
     this.callStack      = new Stack <IMethodDefinition>();
     this.dataflowCache  = new Dictionary <IMethodDefinition, DataFlowAnalysisResult <DependencyPTGDomain>[]>();
     this.previousResult = new Dictionary <InterProceduralCallInfo, DependencyPTGDomain>();
 }
Beispiel #3
0
 public SongTaoDependencyAnalysis(MyLoader loader,
                                  InterproceduralManager interprocManager,
                                  ScopeProcessorInfo processToAnalyze)
 {
     this.interprocManager = interprocManager;
     this.host             = loader.Host;
     this.loader           = loader;
     this.equalities       = new Dictionary <IVariable, IExpression>();
     this.processToAnalyze = processToAnalyze;
 }
Beispiel #4
0
 private void LoadPage(PageType pageType)
 {
     try
     {
         string   prefabPath = controllerDic[pageType].controller.getPage.GetPrefabPath();
         MyLoader loader     = new MyLoader();
         loader.LoadPrefab(prefabPath, 0, onLoaded, pageType);
     }
     catch (Exception e)
     {
         Debug.Log(" LoadPage " + e.ToString());
         throw;
     }
 }
Beispiel #5
0
        static void Main(string[] args)
        {
            try
            {
                List <double> doubleWerte = new List <double>();
                MyTree        newMT       = new MyTree();
                string[]      filenames;
                filenames = MyLoader.LoadCsvFile("Filenames.config");
                MyLoader.LoadIntAndDouble(filenames, newMT, doubleWerte);

                float durchschnittBaum = newMT.GetDurchschnittTree();
                Console.WriteLine("Durchschnitt des Baumes: " + durchschnittBaum);

                float durchschnittListe = List.GetDurchschnittList(doubleWerte);
                Console.WriteLine("Durchschnitt der Liste: " + durchschnittListe);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #6
0
 public MethodCFGCache(MyLoader loader)
 {
     this.host         = loader.Host;
     this.loader       = loader;
     this.methodCFGMap = new Dictionary <IMethodDefinition, ControlFlowGraph>();
 }
Beispiel #7
0
 public ProducesMethodAnalyzer(MyLoader loader, ITypeDefinition processorClass)
 {
     this.loader         = loader;
     this.processorClass = processorClass;
 }
Beispiel #8
0
        public static SarifLog AnalyzeDll(string inputPath, ScopeMethodKind kind,

                                          bool useScopeFactory = true, bool interProc = false, StreamWriter outputStream = null)
        {
            // Determine whether to use Interproc analysis
            AnalysisOptions.DoInterProcAnalysis = interProc;

            AnalysisStats.TotalNumberFolders++;

            var host = new MyHost();

            PlatformTypes.Resolve(host);

            var loader = new MyLoader(host);

            host.Loader = loader;

            var scopeGenAssembly = loader.LoadMainAssembly(inputPath);

            AnalysisStats.TotalDllsFound++;

            loader.LoadCoreAssembly();

            var program = new ScopeProgramAnalysis(host, loader);

            // program.interprocAnalysisManager = new InterproceduralManager(host);
            program.ScopeGenAssembly = scopeGenAssembly;
            //program.ReferenceFiles = referenceFiles;

            program.ClassFilters    = new HashSet <string>();
            program.ClousureFilters = new HashSet <string>();

            program.EntryMethods = new HashSet <string>();

            if (kind == ScopeMethodKind.Reducer || kind == ScopeMethodKind.All)
            {
                program.ClassFilters.Add("Reducer");
                program.ClousureFilters.Add("<Reduce>d__");
                program.EntryMethods.Add("Reduce");
            }
            if (kind == ScopeMethodKind.Producer || kind == ScopeMethodKind.All)
            {
                program.ClassFilters.Add("Processor");
                program.ClousureFilters.Add("<Process>d__");
                program.EntryMethods.Add("Process");
                //program.ClassFilter = "Producer";
                //program.ClousureFilter = "<Produce>d__";
                //program.EntryMethod = "Produce";
            }

            program.MethodUnderAnalysisName = "MoveNext";

            IEnumerable <Tuple <MethodDefinition, MethodDefinition, MethodDefinition> > scopeMethodPairs;

            if (useScopeFactory)
            {
                scopeMethodPairs = program.ObtainScopeMethodsToAnalyze();
                if (!scopeMethodPairs.Any())
                {
                    if (outputStream != null)
                    {
                        outputStream.WriteLine("Failed to obtain methods from the ScopeFactory. ");
                    }
                    System.Console.WriteLine("Failed to obtain methods from the ScopeFactory.");

                    //System.Console.WriteLine("Now trying to find methods in the the assembly");
                    //scopeMethodPairs = program.ObtainScopeMethodsToAnalyzeFromAssemblies();
                }
            }
            else
            {
                scopeMethodPairs = program.ObtainScopeMethodsToAnalyzeFromAssemblies();
            }


            if (scopeMethodPairs.Any())
            {
                var log = CreateSarifOutput();

                IReadOnlyDictionary <string, Tuple <Schema, Schema> > allSchemas;
                if (useScopeFactory)
                {
                    allSchemas = program.ReadSchemasFromXML(inputPath);
                }
                else
                {
                    allSchemas = program.ReadSchemasFromXML2(inputPath);
                }

                foreach (var methodPair in scopeMethodPairs)
                {
                    AnalysisStats.TotalMethods++;

                    var entryMethodDef = methodPair.Item1;
                    var moveNextMethod = methodPair.Item2;
                    var getEnumMethod  = methodPair.Item3;
                    System.Console.WriteLine("Method {0} on class {1}", moveNextMethod.Name, moveNextMethod.ContainingType.FullPathName());

                    Schema inputSchema  = null;
                    Schema outputSchema = null;
                    Tuple <Schema, Schema> schemas;
                    if (allSchemas.TryGetValue(moveNextMethod.ContainingType.ContainingType.Name, out schemas))
                    {
                        inputSchema  = schemas.Item1;
                        outputSchema = schemas.Item2;
                    }

                    try
                    {
                        InputSchema  = inputSchema;
                        OutputSchema = outputSchema;
                        var dependencyAnalysis = new SongTaoDependencyAnalysis(host, program.interprocAnalysisManager, moveNextMethod, entryMethodDef, getEnumMethod);
                        var depAnalysisResult  = dependencyAnalysis.AnalyzeMoveNextMethod();

                        WriteResultToSarifLog(inputPath, outputStream, log, moveNextMethod, depAnalysisResult, dependencyAnalysis, program.factoryReducerMap);

                        InputSchema  = null;
                        OutputSchema = null;
                    }
                    catch (Exception e)
                    {
                        System.Console.WriteLine("Could not analyze {0}", inputPath);
                        System.Console.WriteLine("Exception {0}\n{1}", e.Message, e.StackTrace);
                        AnalysisStats.TotalofDepAnalysisErrors++;
                        AnalysisStats.AddAnalysisReason(new AnalysisReason(moveNextMethod, moveNextMethod.Body.Instructions[0],
                                                                           String.Format(CultureInfo.InvariantCulture, "Throw exception {0}\n{1}", e.Message, e.StackTrace.ToString())));
                    }
                }
                return(log);
            }
            else
            {
                System.Console.WriteLine("No method {0} of type {1} in {2}", program.MethodUnderAnalysisName, program.ClassFilters, inputPath);
                return(null);
            }
        }