public void UpdateProgramWithMetrics(VProgram vprogram)
        {
            var methods = buildMethodIndex(vprogram);
            var classes = buildClassIndex(vprogram);

            for (_x.descendCollection("Targets"); _x.nextInCollection();)
                for (_x.descendCollection("Target"); _x.nextInCollection();)
                    for (_x.descendCollection("Modules"); _x.nextInCollection();)
                        for (_x.descendCollection("Module"); _x.nextInCollection();)
                            for (_x.descendCollection("Namespaces"); _x.nextInCollection();)
                                for (_x.descendCollection("Namespace"); _x.nextInCollection();)
                                {
                                    var ns = _x["Name"] + ".";
                                    _x.descend("Types");
                                    for (_x.descendCollection("Type"); _x.nextInCollection();)
                                    {
                                        var typeName = ns + _x["Name"];
                                        if (typeName.Contains("NyttFoto"))
                                        {

                                        }
                                        if (classes.ContainsKey(typeName))
                                            setMetrics(classes[typeName]);
                                        updateMethods(typeName + "::", methods);
                                    }
                                    _x.ascend();
                                }
        }
Beispiel #2
0
 public static void DoDialog(Form parent, Storage storage, string filename)
 {
     var vprogram = new VProgram(filename);
     using (var dlg = new FProject())
     {
         dlg.Text = vprogram.VAssemblies.First().Name;
         foreach (var vass in vprogram.VAssemblies)
             dlg.lstAssemblies.Items.Add(new ProjectAssembly {Name = vass.Name, FullFilename = vass.Filename});
         if (dlg.ShowDialog(parent) == DialogResult.OK)
             dlg.save(storage.ProjectFolder);
     }
 }
Beispiel #3
0
        public VAssembly(VProgram vprogram, string filename)
        {
            Is3DParty = Path.GetFileName(filename).First() == 'x' || Path.GetFileName(filename).First() == 'i';
            VProgram = vprogram;
            Filename = filename;
            AssemblyDefinition = AssemblyDefinition.ReadAssembly(filename);
            foreach (var type in AssemblyDefinition.MainModule.Types.Where(t => t.Methods.Any(m => !m.IsConstructor)))
            {
                if (type.BaseType!=null && type.BaseType.Name == "MulticastDelegate")
                    continue;
                if (type.Name.Contains("Nytt"))
                {

                }
                VClasses.Add(new VClass(this, type));
            }
        }
Beispiel #4
0
        public Archipelag(
            VisionContent vContent,
            VProgram vprogram,
            WaterSurface water,
            ShadowMap shadow)
            : base((IVEffect)null)
        {
            var codeIslands = CodeIsland.Create(vContent, this, vprogram.VAssemblies);
            foreach (var codeIsland in codeIslands)
            {
                water.ReflectedObjects.Add(codeIsland);
                shadow.ShadowCastingObjects.Add(codeIsland);
                Children.Add(codeIsland);
            }

            _bannerSign = new BannerSign(vContent, codeIslands);
            _arcs = new Arcs(vContent, this);
        }
Beispiel #5
0
        private static void processOneIsland(
            List<ArcVertex> lines,
            CodeIsland island,
            VProgram vp,
            Dictionary<string, CodeIsland> modules)
        {
            if (island.VAssembly.Is3DParty)
                return;

            var arc = new ArcGenerator(4);

            foreach (var vclass in island.Classes.Values)
            {
                var arcStart = lines.Count;

                var done = new HashSet<VisionClass> {vclass};
                foreach (var vmethod in vclass.VClass.VMethods)
                    foreach (var name in vmethod.Calling)
                    {
                        VMethod callTo;
                        if (!vp.VMethods.TryGetValue(name, out callTo))
                            continue;
                        CodeIsland islandD;
                        if (!modules.TryGetValue(callTo.AssemblyName, out islandD))
                            continue;
                        var calledClass = islandD.Classes[callTo.VClass.FullName];
                        vclass.CalledClasses.Add(calledClass);
                        if (done.Contains(calledClass))
                            continue;
                        done.Add(calledClass);
                        var v1 = island.World.TranslationVector + new Vector3(vclass.X, vclass.Height, vclass.Y);
                        var v2 = islandD.World.TranslationVector + new Vector3(calledClass.X , calledClass.Height, calledClass.Y);
                        var distance = Vector3.Distance(v1, v2)/8;
                        arc.CreateArc(
                            v1,
                            v2,
                            Vector3.Up,
                            distance);
                        var arcStart2 = lines.Count;
                        arc.StoreVertices(
                            lines,
                            (p, f, idx) =>
                            {
                                var c = 0.25f + f/2;
                                return new ArcVertex(
                                    p,
                                    new Color(c, c, 1 - c, 1f),
                                    (idx%2) == 1 ? 0 : (MathUtil.TwoPi*(int) (distance/16 + 1)));
                            });
                        //calledClass.IncomingArcs.Add(new StartAndCount { Start = arcStart2, Count = lines.Count - arcStart2 });
                    }

                vclass.OutgoingArcs = new StartAndCount {Start = arcStart, Count = lines.Count - arcStart};
            }
        }
 private static Dictionary<string, VClass> buildClassIndex(VProgram vprogram)
 {
     var dic = new Dictionary<string, VClass>();
     foreach ( var vassembly in vprogram.VAssemblies )
         foreach ( var vclass in vassembly.VClasses )
             if ( !dic.ContainsKey(vclass.FullName ))
                 dic.Add(vclass.FullName, vclass);
     return dic;
 }
        private static Dictionary<string, VMethod> buildMethodIndex(VProgram vprogram)
        {
            var dic = new Dictionary<string, VMethod>();
            foreach (var vm in vprogram.VMethods.Values)
            {
                var md = vm.MethodDefinition;
                var name = md.Name;
                if (md.IsGetter)
                    name = name.Substring(4) + ".get";
                else if (md.IsSetter)
                    name = name.Substring(4) + ".set";
                else if (md.IsConstructor)
                    name = vm.VClass.TypeDefinition.Name;
                var parameters = "";
                foreach (var param in md.Parameters)
                {
                    var prefix = "";
                    var tn = param.ParameterType.Name.TrimEnd('&');
                    if (param.ParameterType.IsByReference)
                        prefix = "ref ";
                    else if (param.IsOut)
                        prefix = "out ";

                    var i = param.ParameterType.FullName.IndexOf('/');
                    if (i > 0)
                    {
                        var j = param.ParameterType.FullName.LastIndexOf('.', i);
                        tn = param.ParameterType.FullName.Substring(j + 1, i - j - 1) + "." + tn;
                    }

                    string tn2;
                    if (TypeTranslator.TryGetValue(tn, out tn2))
                        tn = tn2;
                    //else
                    //    Debug.Print(tn);
                    if (parameters.Length != 0)
                        parameters += ", ";
                    parameters += prefix + tn;
                }
                var adaptedName = string.Format("{0}::{1}({2})", md.DeclaringType, name, parameters);
                if (!dic.ContainsKey(adaptedName))
                    dic.Add(adaptedName, vm);
            }
            return dic;
        }
 public LoadProgramCommand(VProgram vProgram)
 {
     _vProgram = vProgram;
 }