Ejemplo n.º 1
0
        /// <summary>
        /// Searches in current solution and in the global cache for the given file and returns it.
        /// If not found, file will be parsed.
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static IAbstractSyntaxTree GetFileSyntaxTree(string file, out DProject OwnerProject)
        {
            OwnerProject = null;
            if (CoreManager.CurrentSolution != null)
            {
                foreach (var prj in CoreManager.CurrentSolution)
                {
                    var dprj = prj as DProject;

                    if (dprj != null && dprj.ContainsFile(file))
                    {
                        OwnerProject = dprj;
                        return(dprj.ParsedModules.GetModuleByFileName(file, dprj.BaseDirectory));
                    }
                }
            }

            var pcl = ParseCacheList.Create(DSettings.Instance.dmd1.ASTCache, DSettings.Instance.dmd2.ASTCache);

            IAbstractSyntaxTree ret = null;

            foreach (var pc in pcl)
            {
                foreach (var pdir in pc.ParsedDirectories)
                {
                    if (file.StartsWith(pdir) && (ret = pc.GetModuleByFileName(file, pdir)) != null)
                    {
                        return(ret);
                    }
                }
            }

            return(DParser.ParseFile(file));
        }
Ejemplo n.º 2
0
        public override void LoadCurrent(Project prj)
        {
            var p = ManagedProject = prj as DProject;

            if (p == null)
            {
                return;
            }

            if (p.DMDVersion == DVersion.D1)
            {
                Combo_DVersion.SelectedIndex = 0;
            }
            else
            {
                Combo_DVersion.SelectedIndex = 1;
            }

            Check_Release.IsChecked = p.IsRelease;

            Libs.Clear();
            foreach (var l in p.LinkedLibraries)
            {
                Libs.Add(l);
            }

            if (Libs.Count > 0)
            {
                List_Libs.SelectedIndex = 0;
            }

            comboBox_PrjType.SelectedIndex = (int)p.OutputType;
        }
Ejemplo n.º 3
0
        public override Project OpenProject(Solution sln, string FileName)
        {
            var ret = new DProject(sln, FileName);

            ret.ReloadProject();
            ret.ParseDSourcesAsync();
            return(ret);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Searches in current solution and in the global cache for the given file and returns it.
        /// If not found, file will be parsed.
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static DModule GetFileSyntaxTree(string file, out DProject OwnerProject)
        {
            OwnerProject = null;
            var mod = GlobalParseCache.GetModule(file);

            if (CoreManager.CurrentSolution != null)
            {
                foreach (var prj in CoreManager.CurrentSolution)
                {
                    var dprj = prj as DProject;

                    if (dprj != null && dprj.ContainsFile(file))
                    {
                        OwnerProject = dprj;
                    }
                }
            }

            return(mod ?? DParser.ParseFile(file));
        }
Ejemplo n.º 5
0
		public override void LoadCurrent(Project prj)
		{
			var p = ManagedProject = prj as DProject;

			if (p == null)
				return;

			if (p.DMDVersion == DVersion.D1)
				Combo_DVersion.SelectedIndex = 0;
			else Combo_DVersion.SelectedIndex = 1;

			Check_Release.IsChecked = p.IsRelease;

			Libs.Clear();
			foreach(var l in p.LinkedLibraries)
				Libs.Add(l);

			if(Libs.Count>0)
				List_Libs.SelectedIndex = 0;

			comboBox_PrjType.SelectedIndex = (int)p.OutputType;
		}
Ejemplo n.º 6
0
        public override Project CreateEmptyProject(string name, string prjfile, FileTemplate FileType)
        {
            var prj = new DProject();

            prj.Name     = name;
            prj.FileName = prjfile;

            switch (_ProjectTypes.IndexOf(FileType))
            {
            case 0:                     // Console app
                prj.OutputType = OutputTypes.Executable;

                var mainFile = prj.BaseDirectory + "\\main.d";

                File.WriteAllText(mainFile, DResources.helloWorldConsoleApp);

                prj.Add(mainFile);
                prj.Save();

                break;

            case 1:                     // Win32 app
                prj.OutputType = OutputTypes.CommandWindowLessExecutable;

                // Create main file
                var mainFile2 = prj.BaseDirectory + "\\main.d";

                File.WriteAllText(mainFile2, DResources.winsamp_d);
                prj.Add(mainFile2);

                // Add library references
                prj.LinkedLibraries.AddRange(new[] { "kernel32.lib", "gdi32.lib" });

                // Create Resources-directory
                var resDir = prj.BaseDirectory + "\\Resources";
                Util.CreateDirectoryRecursively(resDir);
                prj.SubDirectories.Add(resDir);

                // Create manifest & resource file
                var manifest = resDir + "\\Win32.manifest";

                File.WriteAllText(manifest, DResources.Win32Manifest);
                var manifestModule = prj.Add(manifest);

                // Prevent compilation of the manifest file
                manifestModule.Action = SourceModule.BuildAction.None;

                var rc = resDir + "\\Resources.rc";

                File.WriteAllText(rc, DResources.defResource);
                prj.Add(rc);

                // Finally save changes to the project
                prj.Save();

                break;

            case 2:                     // DLL
                prj.OutputType = OutputTypes.DynamicLibary;

                // We have explicitly reference to phobos library when linking to a .dll
                prj.LinkedLibraries.Add("phobos.lib");

                break;

            case 3:                    // Lib
                prj.OutputType = OutputTypes.StaticLibrary;

                var libmainFile = prj.BaseDirectory + Path.DirectorySeparatorChar + prj.Name.Replace(' ', '_') + ".d";

                File.WriteAllText(libmainFile, DResources.libExample);

                prj.Add(libmainFile);
                prj.Save();
                break;

            default:
                return(null);
            }

            return(prj);
        }
Ejemplo n.º 7
0
 public override Project OpenProject(Solution sln,string FileName)
 {
     var ret = new DProject(sln,FileName);
     ret.ReloadProject();
     ret.ParseDSourcesAsync();
     return ret;
 }
Ejemplo n.º 8
0
        public override Project CreateEmptyProject(string name, string prjfile,FileTemplate FileType)
        {
            var prj=new DProject();
            prj.Name = name;
            prj.FileName = prjfile;

            switch (_ProjectTypes.IndexOf(FileType))
            {
                case 0: // Console app
                    prj.OutputType = OutputTypes.Executable;

                    var mainFile = prj.BaseDirectory+ "\\main.d";

                    File.WriteAllText(mainFile,	DResources.helloWorldConsoleApp);

                    prj.Add(mainFile);
                    prj.Save();

                    break;
                case 1: // Win32 app
                    prj.OutputType = OutputTypes.CommandWindowLessExecutable;

                    // Create main file
                    var mainFile2 = prj.BaseDirectory + "\\main.d";

                    File.WriteAllText(mainFile2, DResources.winsamp_d);
                    prj.Add(mainFile2);

                    // Add library references
                    prj.LinkedLibraries.AddRange(new[]{"kernel32.lib","gdi32.lib"});

                    // Create Resources-directory
                    var resDir = prj.BaseDirectory + "\\Resources";
                    Util.CreateDirectoryRecursively(resDir);
                    prj.SubDirectories.Add(resDir);

                    // Create manifest & resource file
                    var manifest=resDir+"\\Win32.manifest";

                    File.WriteAllText(manifest,DResources.Win32Manifest);
                    var manifestModule=prj.Add(manifest);

                    // Prevent compilation of the manifest file
                    manifestModule.Action = SourceModule.BuildAction.None;

                    var rc = resDir + "\\Resources.rc";

                    File.WriteAllText(rc, DResources.defResource);
                    prj.Add(rc);

                    // Finally save changes to the project
                    prj.Save();

                    break;
                case 2: // DLL
                    prj.OutputType = OutputTypes.DynamicLibary;

                    // We have explicitly reference to phobos library when linking to a .dll
                    prj.LinkedLibraries.Add("phobos.lib");

                    break;
                case 3:// Lib
                    prj.OutputType = OutputTypes.StaticLibrary;

                    var libmainFile = prj.BaseDirectory + Path.DirectorySeparatorChar + prj.Name.Replace(' ','_')+".d";

                    File.WriteAllText(libmainFile, DResources.libExample);

                    prj.Add(libmainFile);
                    prj.Save();
                    break;
                default:
                    return null;
            }

            return prj;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Searches in current solution and in the global cache for the given file and returns it.
        /// If not found, file will be parsed.
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static DModule GetFileSyntaxTree(string file,out DProject OwnerProject)
        {
            OwnerProject = null;
            if (CoreManager.CurrentSolution != null)
            {
                foreach (var prj in CoreManager.CurrentSolution)
                {
                    var dprj = prj as DProject;

                    if (dprj!=null && dprj.ContainsFile(file))
                    {
                        OwnerProject = dprj;
                        return dprj.ParsedModules.GetModuleByFileName(file, dprj.BaseDirectory);
                    }
                }
            }

            var pcl = ParseCacheList.Create(DSettings.Instance.dmd1.ASTCache,DSettings.Instance.dmd2.ASTCache);

            DModule ret = null;
            foreach (var pc in pcl)
                foreach (var pdir in pc.ParsedDirectories)
                {
                    if (file.StartsWith(pdir) && (ret = pc.GetModuleByFileName(file, pdir)) != null)
                        return ret;
                }

            return DParser.ParseFile(file);
        }
Ejemplo n.º 10
0
		/// <summary>
		/// Searches in current solution and in the global cache for the given file and returns it.
		/// If not found, file will be parsed.
		/// </summary>
		/// <param name="file"></param>
		/// <returns></returns>
		public static DModule GetFileSyntaxTree(string file,out DProject OwnerProject)
		{
			OwnerProject = null;
			var mod = GlobalParseCache.GetModule(file);

			if (CoreManager.CurrentSolution != null)
				foreach (var prj in CoreManager.CurrentSolution)
				{
					var dprj = prj as DProject;

					if (dprj != null && dprj.ContainsFile(file))
						OwnerProject = dprj;
				}

			return mod ?? DParser.ParseFile(file);
		}
Ejemplo n.º 11
0
            //INode typeNode;
            //IEnumerable<IAbstractSyntaxTree> moduleCache;

            public DDebugSymbolWrapper(DebugScopedSymbol sym, DDebugSupport support) : base(sym)
            {
                this.supp = support;
                try
                {
                    /*var ci=CoreManager.DebugManagement.Engine.Symbols.GetPointerTarget(sym.Offset);
                     * object mo = null;
                     * IntPtr moPtr = new IntPtr();
                     * var raw = CoreManager.DebugManagement.Engine.Memory.ReadVirtual(ci, 4);
                     * Marshal.StructureToPtr(raw, moPtr, false);
                     * mo = Marshal.PtrToStructure(moPtr, typeof(DObject));*/
                }
                catch { }

                // Search currently scoped module
                string file = "";
                uint   line = 0;

                CoreManager.DebugManagement.Engine.Symbols.GetLineByOffset(CoreManager.DebugManagement.Engine.CurrentInstructionOffset, out file, out line);
                codeLine = (int)line;

                if (string.IsNullOrWhiteSpace(file))
                {
                    return;
                }

                // If file name found, get syntax tree, as far as possible
                DProject ownerPrj = null;

                module = DLanguageBinding.GetFileSyntaxTree(file, out ownerPrj);



                // If syntax tree built, search the variable location
                if (module != null)
                {
                    IStatement stmt  = null;
                    var        block = DResolver.SearchBlockAt(module, new CodeLocation(0, codeLine), out stmt);

                    var ctxt = ResolutionContext.Create(null, null, block);

                    var res = TypeDeclarationResolver.ResolveIdentifier(Symbol.Name, ctxt, null);

                    if (res != null && res.Length > 0 && res[0] is DSymbol)
                    {
                        variableNode = ((DSymbol)res[0]).Definition;
                        //moduleCache = DCodeCompletionSupport.Instance.EnumAvailableModules(ownerPrj);
                    }
                }



                // Set type string
                _typeString = base.TypeString;
                if (variableNode != null)
                {
                    var t = variableNode.Type;
                    if (t != null)
                    {
                        _typeString = t.ToString();
                    }
                }



                // Set value string
                if (_typeString.StartsWith("class "))
                {
                    _valueString = base.ValueString;

                    //CodeInjection.WriteObjectVariable(supp.hProcess, supp.varAddr, (uint)sym.Offset);

                    //_valueString = CodeInjection.EvaluateObjectString(supp.hProcess, supp.toStringFunc, supp.varAddr, (uint)sym.Offset);

                    /*
                     * var th = CodeInjection.BeginExecuteMethod(supp.hProcess, supp.toStringFunc);
                     *
                     * CoreManager.DebugManagement.Engine.Execute("~2 g");
                     * CoreManager.DebugManagement.Engine.WaitForEvent();
                     *
                     * CodeInjection.WaitForExecutionEnd(th);
                     */
                    //_valueString = CodeInjection.ReadDString(supp.hProcess, supp.varAddr);
                }
                else
                {
                    _valueString = base.ValueString;

                    if (variableNode != null)
                    {
                        ITypeDeclaration curValueType = variableNode.Type;
                        if (curValueType != null)
                        {
                            if (!IsBasicType(curValueType))
                            {
                                if (TypeString == "string")                                 //TODO: Replace this by searching the alias definition in the cache
                                {
                                    curValueType = new ArrayDecl()
                                    {
                                        InnerDeclaration = new DTokenDeclaration(DTokens.Char)
                                    }
                                }
                                ;
                                else if (TypeString == "wstring")
                                {
                                    curValueType = new ArrayDecl()
                                    {
                                        InnerDeclaration = new DTokenDeclaration(DTokens.Wchar)
                                    }
                                }
                                ;
                                else if (TypeString == "dstring")
                                {
                                    curValueType = new ArrayDecl()
                                    {
                                        InnerDeclaration = new DTokenDeclaration(DTokens.Dchar)
                                    }
                                }
                                ;

                                if (IsArray(curValueType))
                                {
                                    var clampDecl = curValueType as ArrayDecl;
                                    var valueType = clampDecl.InnerDeclaration;

                                    if (valueType is DTokenDeclaration)
                                    {
                                        bool IsString = false;
                                        uint elsz     = 0;
                                        var  realType = DetermineArrayType((valueType as DTokenDeclaration).Token, out elsz, out IsString);

                                        var arr = CoreManager.DebugManagement.Engine.Symbols.ReadArray(sym.Offset, realType, elsz);

                                        if (arr != null)
                                        {
                                            _valueString = BuildArrayContentString(arr, IsString);
                                        }
                                    }
                                }

                                else
                                {
                                    //TODO: call an object's toString method somehow to obtain its representing string manually
                                }
                            }
                        }
                    }
                }
            }