private void InitPorjectModel(SourceProjectModel projectModel, string srcPath) { //var srcFileInfo = new FileInfo(srcPath); //var projectModel = new SourceProjectModel(); string srcFileTypeName = Path.GetFileNameWithoutExtension(srcPath); //projectModel.ProjectRootDirectoryInfo = srcFileInfo.Directory; projectModel.BinaryFileKind = PEFileKinds.Dll; //projectModel.BinarySaveDirectoryInfo = srcFileInfo.Directory; projectModel.ProjectPackageName = "ZLOGOEmit"; projectModel.EntryClassName = srcFileTypeName; projectModel.BinaryFileNameNoEx = srcFileTypeName; //projectModel.ProjectFileInfo = new ZCompileFileInfo( true, srcPath,null,null); //projectModel.AddRefPackage("Z语言系统"); projectModel.AddRefPackage("ZLogoEngine"); projectModel.AddRefDll(new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ZLogoEngine.dll"))); projectModel.NeedSave = true; //ZFileModel classModel = new ZFileModel(new ZCompileFileInfo(false, srcPath, PreCode,null)); //projectModel.AddClass(classModel); //return projectModel; string sourceCode = File.ReadAllText(srcPath); SourceFileModel fileModel = new SourceFileModel(srcPath, srcPath, projectModel.EntryClassName, projectModel.ProjectPackageName, projectModel.EntryClassName, sourceCode, 1); fileModel.PreSourceCode = PreCode; projectModel.AddFile(fileModel); }
public ProjectCompileResult Compile() { if (!File.Exists(ProjectFilePath)) { string projectFileKey = ProjectFilePath; MessageCollection.AddError( new CompileMessage(new CompileMessageSrcKey(projectFileKey), 0, 0, "项目文件'" + projectFileKey + "'不存在")); ProjectCompileResult psr = new ProjectCompileResult() { MessageCollection = MessageCollection }; return(psr); } SourceProjectModel projectModel = ReadModel(); if (projectModel != null) { builder = new ZProjectEngine(MessageCollection, projectModel); var result = builder.Compile(); if (result.ProjectModel == null) { result.ProjectModel = projectModel; } return(result); } return(null); }
public ZProjectEngine(CompileMessageCollection cmc, SourceProjectModel zCompileProjectModel) { MessageCollection = cmc; this.projectModel = zCompileProjectModel; result = new ProjectCompileResult(); result.MessageCollection = MessageCollection; ProjectContext = new ContextProject(zCompileProjectModel, MessageCollection); }
public ContextProject(SourceProjectModel projectModel, CompileMessageCollection messageCollection) { ProjectModel = projectModel; PackageName = ProjectModel.ProjectPackageName; MessageCollection = messageCollection; AssemblyDescDictionary = new Dictionary <Assembly, ZAssemblyInfo>(); CompiledTypes = new ZLCollection(); }
private void InitPorjectModel(SourceProjectModel projectModel, string srcPath) { projectModel.AddRefPackage("Z标准包"); projectModel.AddRefPackage("ZExcel开发包"); projectModel.ProjectPackageName = "ZLangSingleFile"; projectModel.BinaryFileKind = PEFileKinds.ConsoleApplication; projectModel.RefDllList = GetRefDllList(srcPath); string sourceCode = File.ReadAllText(srcPath); SourceFileModel fileModel = new SourceFileModel(srcPath, srcPath, projectModel.EntryClassName, projectModel.ProjectPackageName, projectModel.EntryClassName, sourceCode, 1); projectModel.AddFile(fileModel); }
public ProjectCompileResult Compile(string srcPath, CompileMessageCollection messageCollection) { MessageCollection = messageCollection; projectModel = new SourceProjectModel(); InitFile(srcPath); if (this.InitProjectAct != null) { InitProjectAct(projectModel, srcPath); } ZProjectEngine builder2 = new ZProjectEngine(MessageCollection, projectModel); ProjectCompileResult result = builder2.Compile(); result.ProjectModel = projectModel; CompileResult = result; return(result); }
private SourceProjectModel ReadModel() { FileInfo srcFileInfo = new FileInfo(ProjectFilePath); string[] lines = File.ReadAllLines(ProjectFilePath); SourceProjectModel projectModel = projFileParser.ParseProjectFile(MessageCollection, lines, srcFileInfo.Directory.FullName, ProjectFilePath); //projectModel.AddRefPackage("Z语言系统"); projectModel.AddRefPackage("Z标准包"); if (projectModel.ProjectRootDirectoryInfo == null) { projectModel.ProjectRootDirectoryInfo = srcFileInfo.Directory; } if (projectModel.BinarySaveDirectoryInfo == null) { projectModel.BinarySaveDirectoryInfo = srcFileInfo.Directory; } return(projectModel); }
public SourceProjectModel ParseProjectFile(CompileMessageCollection messageCollection, string[] lines, string folderPath, string projectFilePath)//, ZCompileFileInfo zfileInfo) { SourceProjectModel projectModel = new SourceProjectModel(); projectModel.NeedSave = true; projectModel.AddRefPackage("Z语言系统"); for (int i = 0; i < lines.Length; i++) { string code = lines[i]; if (string.IsNullOrEmpty(code)) { continue; } else if (code.StartsWith("//")) { continue; } else if (code.StartsWith("包名称:")) { string name = code.Substring(4); projectModel.ProjectPackageName = name; projectModel.BinaryFileNameNoEx = name; } else if (code.StartsWith("生成类型:")) { string lx = code.Substring(5); PEFileKinds fileKind = PEFileKinds.ConsoleApplication; if (lx == "开发包") { fileKind = PEFileKinds.Dll; } else if (lx == "控制台程序") { fileKind = PEFileKinds.ConsoleApplication; } else if (lx == "桌面程序") { fileKind = PEFileKinds.WindowApplication; } projectModel.BinaryFileKind = fileKind; } else if (code.StartsWith("编译:")) { string src = code.Substring(3); //string srcPath = Path.Combine(folderPath, src); SourceFileModel classModel = readFileModel(folderPath, src, projectModel.ProjectPackageName);// new SourceFileModel(new ZCompileFileInfo(false, srcPath, null, null)); projectModel.AddFile(classModel); } else if (code.StartsWith("设置启动:")) { string name = code.Substring(5); projectModel.EntryClassName = name; } else if (code.StartsWith("保存:")) { string name = code.Substring(3); projectModel.BinaryFileNameNoEx = name; } else { messageCollection.AddError( new CompileMessage(new CompileMessageSrcKey(projectFilePath), i + 1, 0, "项目指令'" + code + "'无效")); } } return(projectModel); }