private ZType GetZTypeByTypeName(string typeName) { //if (typeName == "Func<bool>") //{ // arg = new ZMethodArg(typeName, ZTypeCache.GetByZType(typeof(Func<bool>))); //} //else if (argtypename == "Action") //{ // arg = new ZMethodArg(realArgName, ZTypeCache.GetByZType(typeof(Action))); //} //else //{ var ztypes = ZTypeManager.GetByMarkName(typeName); if (ztypes.Length == 0) { ztypes = ZTypeManager.GetBySharpName(typeName); } if (ztypes.Length > 0) { ZType ztype = ztypes[0] as ZType; //arg = new ZMethodArg(typeName, ztype); return(ztype); } else { } return(null); }
public void Analy() { string fileName = this.ASTClass.FileContext.FileModel.GeneratedClassName; bool IsStatic = false; ZLClassInfo BaseZType = null; if (Raw == null) { IsStatic = false; BaseZType = ZLangBasicTypes.ZOBJECT; } else if (Raw.BaseTypeToken == null) { ExtendsTypeName = null; IsStatic = false; BaseZType = ZLangBasicTypes.ZOBJECT; } else { ExtendsTypeName = Raw.BaseTypeToken.Text; if (ExtendsTypeName == "唯一类型") { IsStatic = true; } else if (ExtendsTypeName == "普通类型" || ExtendsTypeName == "一般类型") { IsStatic = false; BaseZType = ZLangBasicTypes.ZOBJECT; } else { IsStatic = false; var ztypes = ZTypeManager.GetByMarkName(ExtendsTypeName); if (ztypes.Length == 0) { this.ASTClass.FileContext.Errorf(Raw.BaseTypeToken.Position, "类型'{0}'不存在", ExtendsTypeName); } else if (ztypes.Length == 1) { BaseZType = ztypes[0] as ZLClassInfo; } else if (ztypes.Length == 0) { this.ASTClass.FileContext.Errorf(Raw.BaseTypeToken.Position, "'{0}'存在{1}个同名类型", ExtendsTypeName, ztypes.Length.ToString()); } } //if (ClassName != fileName) //{ // this.FileContext.Errorf(BaseTypeToken.Position, "类名称 '" + ClassName + "'和文件名称'" + fileName + "'不一致"); //} } this.ASTClass.ClassContext.SetIsStatic(IsStatic); this.ASTClass.ClassContext.SetSuperClass(BaseZType); }
private void AddDimWord(ZDimType zdim, WordDictionary wordDictionary) { Dictionary <string, string> dims = zdim.Dims; foreach (string dimName in dims.Keys) { string dimTypeName = dims[dimName]; IZDescType[] ztypes = ZTypeManager.GetByMarkName(dimTypeName); if (ztypes.Length > 0) { ZType ztype = ztypes[0] as ZType; WordInfo word = new WordInfo(dimName, WordKind.DimName, ztype); wordDictionary.Add(word); } } }
private void AnalyBase(ContextClass context) { SuperTable = null; if (BaseTypeToken == null) { IsStatic = false; BaseZType = ZTypeManager.ZOBJECT; SuperTable = new SuperSymbolTable("SUPER-唯一", ZTypeManager.ZOBJECT); } else { BaseTypeName = BaseTypeToken.GetText(); if (BaseTypeName == "唯一") { IsStatic = true; SuperTable = new SuperSymbolTable("SUPER-唯一", null); } else { IsStatic = false; var ztypes = ZTypeManager.GetByMarkName(BaseTypeName); if (ztypes.Length == 0) { errorf(BaseTypeToken.Position, "类型'{0}'不存在", BaseTypeName); } else if (ztypes.Length == 1) { BaseZType = ztypes[0] as ZClassType; SuperTable = new SuperSymbolTable("SUPER-" + BaseZType.ZName, BaseZType); } else if (ztypes.Length == 0) { errorf(BaseTypeToken.Position, "'{0}'存在{1}个同名类型", BaseTypeName, ztypes.Length); SuperTable = new SuperSymbolTable("SUPER", null); } } } if (SuperTable == null) { SuperTable = new SuperSymbolTable("SUPER-STATIC", null); } SuperTable.ParentTable = FileContext.UseContext.SymbolTable; context.SetSuperTable(SuperTable); context.BaseZType = BaseZType; }
private ParseResult ParseNameBySegmenter(Token token, IWordDictionary collection) { //WordCollection nameManager = this.procContext.ClassContext.FileContext.GetNameDimWordManger(); WordSegmenter segmenter = new WordSegmenter(collection); Token[] newTokens = segmenter.Split(token); if (newTokens.Length == 2) { string argTypeName = newTokens[0].GetText(); var ArgType = ZTypeManager.GetByMarkName(argTypeName)[0] as ZType; var result = new ParseResult() { TypeName = argTypeName, ZType = ArgType, VarName = newTokens[1].GetText() }; return(result); } else { return(null); } }