static ProjectCompileResult CompileProject(string srcFile, CompileMessageCollection messageCollection) { ProjectFileCompiler compiler = new ProjectFileCompiler(srcFile, messageCollection); ProjectCompileResult result = compiler.Compile(); return(result); }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string src = ""; src = "例子/第1个ZLOGO程序.zlogo"; src = "例子/重复绘图.zlogo"; src = "例子/测试画笔颜色.zlogo"; if (args.Length > 1) { src = args[0]; } ProjectCompileResult result = compiler.Compile(src); if (result.HasError() == false) { compiler.Run(result); } else { ShowErrors(result); Console.ReadKey(); } }
static ProjectCompileResult CompileFile(string srcFile, CompileMessageCollection MessageCollection) { FileCompiler compiler = new FileCompiler(); ProjectCompileResult result = compiler.Compile(srcFile, MessageCollection); return(result); }
static ProjectCompileResult Compile(CompileCmdModel model) { ProjectCompileResult result = null; if (model.IsCompileProject) { result = CompileFile(model.SrcFile); } else { result = CompileProject(model.SrcFile); } if (model.IsShowError) { if (result.HasError()) { ShowErrors(result); } } if (model.IsRun) { if (result.HasError() == false) { Run(result); } } return(result); }
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); }
static ProjectCompileResult Compile(CompileCmdModel model) { CompileMessageCollection MessageCollection = new CompileMessageCollection(); ProjectCompileResult result = null; if (model.IsCompileProject) { result = CompileFile(model.SrcFile, MessageCollection); } else { result = CompileProject(model.SrcFile, MessageCollection); } if (model.IsShowError) { if (MessageCollection.HasError()) { ShowErrors(result); } } if (model.IsRun) { if (MessageCollection.HasError() == false) { Run(result); } } return(result); }
//private Process CurrentProcess { get; set; } //ProjectCompiler compiler = new ProjectCompiler(); private void Run() { var editorForm = GetCurrentEditor(); if (editorForm == null) { return; } if (editorForm.Editor.CurrentFile == null) { return; } this.msgDock.ResetConsoles(); saveText(); ZDevCompiler compiler = new ZDevCompiler(editorForm.Editor.CurrentFile); ProjectCompileResult results = compiler.Compile(); this.msgDock.ShowErrors(results); if (results.Errors.Count == 0) { try { compiler.Run(); } catch (Exception ex) { MessageBox.Show("程序运行错误", ex.Message); } } }
public ProjectCompileResult CompileProject(ZCompileProjectModel zCompileProjectModel) { ProjectContext projectContext = new ProjectContext(); ProjectCompileResult result = CompileProject(zCompileProjectModel, projectContext); return(result); }
public ZProjectEngine(CompileMessageCollection cmc, SourceProjectModel zCompileProjectModel) { MessageCollection = cmc; this.projectModel = zCompileProjectModel; result = new ProjectCompileResult(); result.MessageCollection = MessageCollection; ProjectContext = new ContextProject(zCompileProjectModel, MessageCollection); }
static ProjectCompileResult CompileProject(string srcFile) { FileInfo srcFileInfo = new FileInfo(srcFile); ProjectCompiler compiler = new ProjectCompiler(); ProjectCompileResult result = compiler.Compile(srcFileInfo); return(result); }
public ProjectCompileResult Compile() { ZCompileBuilder builder = new ZCompileBuilder(); ProjectCompileResult result = builder.CompileProject(projectModel); CompileResult = result; return(result); }
private bool HasError() { ProjectCompileResult compileResult = this.ProjectContext.CompileResult; var fi = this.FileContext.FileModel.ZFileInfo; bool b = compileResult.Errors.ContainsKey(fi); return(b); }
public ProjectCompileResult Compile(string filePath) { //FileInfo zlogoFileInfo = new FileInfo(filePath); ZProjectModel projectModel = Init(filePath); ZProjectEngine builder = new ZProjectEngine(); ProjectCompileResult result = builder.Compile(projectModel); return(result); }
private void errorf(ProjectCompileResult result, string file, int line, int col, string formatstring, params string[] args) { CompileMessage msg = new CompileMessage() { FileName = file, Line = line, Col = col, Text = string.Format(formatstring, args) }; result.Errors.Add(msg); }
public ProjectCompileResult Compile(string srcPath) { InitFile(srcPath); ZProjectEngine builder2 = new ZProjectEngine(); ProjectCompileResult result = builder2.Compile(projectModel); CompileResult = result; return(result); }
//string projectFilePath; public ProjectCompileResult Compile(FileInfo projectFileInfo) { //Messager.Clear(); //this.projectFilePath = projectFilePath; ZProjectModel projectModel = ReadModel(projectFileInfo); ZProjectEngine builder2 = new ZProjectEngine(); ProjectCompileResult result = builder2.Compile(projectModel); return(result); }
public static void Run(ProjectCompileResult result) { __CompileResult = result; if (result.EntrtyZType != null) { CompiledMainType = result.EntrtyZType.SharpType; Thread newThread = new Thread(new ThreadStart(RunMainTypeEntry)); newThread.SetApartmentState(ApartmentState.STA); newThread.Start(); } }
public bool CheckRunZLogo(ProjectCompileResult result) { if (result.CompiledTypes.Count == 0) { return(false); } ZClassType zclass = result.CompiledTypes[0] as ZClassType; ZMethodInfo method = zclass.FindDeclaredZMethod("RunZLogo"); return(method != null); }
public ProjectCompileResult Compile() { if (CompileResult == null) { ZCompileBuilder builder = new ZCompileBuilder(); ProjectCompileResult result = builder.CompileProject(projectModel); CompileResult = result; //return result; } return(CompileResult); }
public bool CheckRunZLogo(ProjectCompileResult result) { if (result.MessageCollection.Errors.Count > 0) { return(false); } //if (result.CompiledTypes.Count == 0) return false; ZLClassInfo zclass = result.CompiledTypes.ZClasses[0] as ZLClassInfo; MethodInfo method = zclass.SharpType.GetMethod("RunZLogo"); return(method != null); }
public void CreateZType() { ProjectCompileResult compileResult = this.ProjectContext.CompileResult; if (!HasError()) { Type type = this.ClassSection.Builder.CreateType(); IZDescType ztype = ZTypeManager.GetByMarkType(type); this.FileContext.EmitedZClass = ztype as ZType; this.ProjectContext.CompileResult.CompiledTypes.Add(ztype); } }
void createXmFileProject(FileInfo zlogoFileInfo) { initProject(); projectModel.ProjectFileName = zlogoFileInfo.Name; ZXMParser xmZxmParser = new ZXMParser(zlogoFileInfo); ProjectCompileResult compileResult2 = xmZxmParser.Parse(projectModel); if (compileResult2.HasError()) { CompileResult = compileResult2; } }
ProjectCompileResult CompileProject(string srcFile) { CompileMessageCollection messageCollection = new CompileMessageCollection(); //FileInfo srcFileInfo = new FileInfo(srcFile); //ProjectCompiler compiler = new ProjectCompiler(); //ProjectCompileResult result = compiler.Compile(srcFileInfo, MessageCollection); //return result; ProjectFileCompiler compiler = new ProjectFileCompiler(srcFile, messageCollection); ProjectCompileResult result = compiler.Compile(); return(result); }
public ProjectCompileResult Compile(string srcFile) { MessageCollection.Clear(); //CompileMessageCollection MessageCollection = new CompileMessageCollection(); FileCompiler compiler = new FileCompiler(this.InitPorjectModel); ProjectCompileResult result = compiler.Compile(srcFile, MessageCollection); return(result); //ZProjectModel projectModel = Init(filePath); //ZProjectEngine builder = new ZProjectEngine(MessageCollection, projectModel); //ProjectCompileResult result = builder.Compile(); //return result; }
public static void ShowErrors(ProjectCompileResult compileResult) { StringBuilder buffBuilder = new StringBuilder(); //buffBuilder.AppendFormat("文件'{0}'有以下错误:\n", srcFile); foreach (CompileMessage compileMessage in compileResult.Errors.ValuesToList()) { if (compileMessage.Line > 0 || compileMessage.Col > 0) { buffBuilder.AppendFormat(" {2} 第{0}行,第{1}列", compileMessage.Line, compileMessage.Col, compileMessage.SourceFileInfo.ZFileName); } buffBuilder.AppendFormat("错误:{0}\n", compileMessage.Text); } Console.WriteLine(buffBuilder.ToString()); Console.ReadKey(); }
public static void ShowErrors(ProjectCompileResult compileResult) { StringBuilder buffBuilder = new StringBuilder(); //buffBuilder.AppendFormat("文件'{0}'有以下错误:\n", srcFile); foreach (CompileMessage compileMessage in compileResult.MessageCollection.Errors) { if (compileMessage.Line > 0 || compileMessage.Col > 0) { buffBuilder.AppendFormat(" {2} 第{0}行,第{1}列", compileMessage.Line, compileMessage.Col, compileMessage.Key.ToString()); } buffBuilder.AppendFormat("错误:{0}\n", compileMessage.Content); } Console.WriteLine(buffBuilder.ToString()); Console.ReadKey(); }
void initProject() { CompileResult = null; projectModel = new ZCompileProjectModel(); projectModel.ProjectRootDirectoryInfo = srcFileInfo.Directory; projectModel.BinarySaveDirectoryInfo = srcFileInfo.Directory; projectModel.NeedSave = true; projectModel.AddRefPackage("Z语言系统"); projectModel.AddRefDll(new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Lib/Z文件系统.dll"))); projectModel.AddRefDll(new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Lib/Z桌面控件.dll"))); projectModel.AddRefDll(new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Lib/Z互联网.dll"))); projectModel.AddRefDll(new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Lib/Z绘图.dll"))); projectModel.AddRefDll(new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Lib/Z操作系统.dll"))); //projectModel.AddRefDll(new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Lib/NSoup.dll"))); }
public ProjectCompileResult Compile() { var SrcFile = this.srcFileInfo.FullName; bool IsCompileProject = SrcFile.EndsWith(ZDevCompiler.ZYYExt, StringComparison.InvariantCultureIgnoreCase); if (IsCompileProject) { CompileResult = CompileFile(SrcFile); } else { CompileResult = CompileProject(SrcFile); } return(CompileResult); }
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); }
public void Compile() { ImporteSection.Analy(); DimSection.AnalyBody(); DimSection.EmitBody(); ProjectCompileResult compileResult = this.ProjectContext.CompileResult; if (compileResult.Errors.ContainsKey(this.FileContext.FileModel.ZFileInfo)) { return; } else { //Type type = DimSection.Builder.CreateType(); var ztype = DimSection.GetCreatedZType();//var ztype = ZTypeCache.CreateZDescType(type); this.ProjectContext.CompileResult.CompiledTypes.Add(ztype); } }