public static object[] SearchDirectIdent(ClassContext context, string name) { List <object> result = new List <object>(); foreach (IGcl tkt in context.ImportContext.DirectClasses) { ExPropertyInfo property = tkt.SearchExProperty(name);// TKTMappingUtil.SearchExProperty(name, tkt); if (property != null) { if (ReflectionUtil.IsStatic(property.Property) && ReflectionUtil.IsPublic(property.Property)) { result.Add(property); } } ExFieldInfo field = tkt.SearchExField(name); if (field != null) { if (field.Field.IsPublic && field.Field.IsStatic) { result.Add(field); } } } return(result.ToArray()); }
Exp analyParentClass(AnalyExpContext context) { ClassContext classContext = context.ClassContext; SymbolDefClass classSymbol = classContext.ClassSymbol; if (classSymbol.BaseGcl == null) { return(null); } ExPropertyInfo property = classSymbol.BaseGcl.SearchExProperty(IdentName); //if (property == null) return null; if (property != null) { if (ReflectionUtil.IsPublic(property.Property) || ReflectionUtil.IsProtected(property.Property)) { SymbolDefProperty ps = new SymbolDefProperty(IdentName, property.Property.PropertyType, ReflectionUtil.IsStatic(property.Property)); ps.SetProperty(property.Property); VarExp exp = new VarExp(this, this.IdentToken); exp.VarSymbol = ps; return(exp); } } return(null); }
public override ExPropertyInfo[] GetPropertyInfoes() { List <ExPropertyInfo> exList = new List <ExPropertyInfo>(); var propertyArray = this.SharpType.GetProperties(); foreach (var property in propertyArray) { ZCodeAttribute[] arrs = AttributeUtil.GetAttributes <ZCodeAttribute>(property); foreach (var zcattr in arrs) { ExPropertyInfo exPI = new ExPropertyInfo(property, true, zcattr.Code); exList.Add(exPI); } } if (ParentMapping != null && !isRoot()) { ExPropertyInfo[] pArr = ParentMapping.GetPropertyInfoes(); foreach (ExPropertyInfo pitem in pArr) { pitem.IsSelf = false; } exList.AddRange(pArr); } return(exList.ToArray()); }
public override ExPropertyInfo SearchExProperty(string name) { var propertyArray = this.SharpType.GetProperties(); foreach (var property in propertyArray) { if (!ReflectionUtil.IsDeclare(this.SharpType, property)) { continue; } /* 映射类可能有多个同义的属性名称对应同一个实际属性 */ ZCodeAttribute[] arrs = AttributeUtil.GetAttributes <ZCodeAttribute>(property); foreach (var zcode in arrs) { if (zcode.Code == name) { return(new ExPropertyInfo(property, true, name)); } } } if (ParentMapping != null && !isRoot()) { ExPropertyInfo epi = ParentMapping.SearchExProperty(name); if (epi != null) { epi.IsSelf = false; return(epi); } } return(null); }
public static ExPropertyInfo CreatExPropertyInfo(PropertyInfo propertyInfo, Type forType) { if (propertyInfo == null) { return(null); } ExPropertyInfo exFieldInfo = new ExPropertyInfo(propertyInfo, propertyInfo.DeclaringType == forType); return(exFieldInfo); }
public static ExPropertyInfo SearchExProperty(string name, Type forType) { var propertyInfo = forType.GetProperty(name); if (propertyInfo == null) { return(null); } ExPropertyInfo exPropertyInfo = new ExPropertyInfo(propertyInfo, propertyInfo.DeclaringType == forType); return(exPropertyInfo); }
public override void Analy(AnalyStmtContext context) { base.Analy(context); var symbols = this.AnalyStmtContext.Symbols; int foreachIndex = context.MethodContext.CreateForeachIndex(); var propertyName = "Item"; var subjType = ToExp.ListExp.RetType; ExProperty = GclUtil.SearchExProperty(propertyName, subjType);//subjType.GetExProperty(propertyName); PropertyInfo countProperty = subjType.GetProperty("Count"); getCountMethod = countProperty.GetGetMethod(); createForeachSymbols(context, symbols, foreachIndex); setMethod = ExProperty.Property.GetSetMethod(); }
public ExPropertyInfo SearchExProperty(string name) { var propertyArray = MType.GetProperties(/*BindingFlags.DeclaredOnly*/); foreach (PropertyInfo property in propertyArray) { if (ReflectionUtil.IsDeclare(MType, property)) { if (isExFieldInfoByAttr(name, property)) { return(GclUtil.CreatExPropertyInfo(ForType.GetProperty(property.Name), ForType)); } /*ExFieldInfo exFieldInfo = searchExFieldInfoByAttr(name, property); * if (exFieldInfo != null) * { * return exFieldInfo; * }*/ /*ZCodeAttribute propertyAttr = Attribute.GetCustomAttribute(property, typeof(ZCodeAttribute)) as ZCodeAttribute; * if (propertyAttr == null) * { * if (property.Name == name) * { * //return ForType.GetExProperty(property.Name); * return GclUtil.CreatExPropertyInfo(ForType.GetProperty(property.Name), ForType); * } * } * else * { * if (propertyAttr.Code == name) * { * //return ForType.GetExProperty(property.Name); * return GclUtil.CreatExPropertyInfo(ForType.GetProperty(property.Name), ForType); * } * }*/ } } if (isRootMapping()) { return(null); } else { ExPropertyInfo property = ParentMapping.SearchExProperty(name); return(property); } }
public override ExPropertyInfo SearchExProperty(string name) { var propertyArray = this.SharpType.GetProperties(); foreach (var property in propertyArray) { if (!ReflectionUtil.IsDeclare(this.SharpType, property)) { continue; } ZCodeAttribute propertyAttr = Attribute.GetCustomAttribute(property, typeof(ZCodeAttribute)) as ZCodeAttribute; string zpropertyName = null; if (propertyAttr != null) { //zpropertyName = property.Name; zpropertyName = propertyAttr.Code; if (zpropertyName == name) { return(new ExPropertyInfo(property, true, name)); } } //else //{ // zpropertyName = property.Name; //} //if (zpropertyName == name) //{ // return new ExPropertyInfo(property, true, name); //} } //if (ParentMapping != null) //{ ExPropertyInfo epi = ParentMapping.SearchExProperty(name); if (epi != null) { epi.IsSelf = false; return(epi); } //} return(null); }
public override Exp Analy(AnalyExpContext context) { base.Analy(context); int foreachIndex = context.StmtContext.MethodContext.CreateForeachIndex(); var symbols = context.Symbols; Exp listExp = everyoneExp.ListExp; //PropertyInfo countProperty = listExp.RetType.GetProperty("Count"); ExPropertyInfo countProperty = GclUtil.SearchExProperty("Count", listExp.RetType); var rgetCountMethod = countProperty.Property.GetGetMethod(); getCountMethod = new ExMethodInfo(rgetCountMethod, countProperty.IsSelf); //PropertyInfo itemProperty = listExp.RetType.GetProperty("Item"); ExPropertyInfo itemProperty = GclUtil.SearchExProperty("Item", listExp.RetType); diMethod = new ExMethodInfo(itemProperty.Property.GetGetMethod(), itemProperty.IsSelf); createForeachSymbols(context, symbols, foreachIndex, everyoneExp.ListExp.RetType); this.RetType = invokeExp.CallExMethod.Method.ReturnType; return(this); }
public override ExPropertyInfo[] GetPropertyInfoes() { List <ExPropertyInfo> exList = new List <ExPropertyInfo>(); var propertyArray = this.SharpType.GetProperties(); foreach (var property in propertyArray) { ZCodeAttribute propertyAttr = Attribute.GetCustomAttribute(property, typeof(ZCodeAttribute)) as ZCodeAttribute; if (propertyAttr != null) { var zpropertyName = propertyAttr.Code; ExPropertyInfo exPI = new ExPropertyInfo(property, ReflectionUtil.IsDeclare(this.SharpType, property), zpropertyName); exList.Add(exPI); } } ExPropertyInfo[] pArr = ParentMapping.GetPropertyInfoes(); foreach (ExPropertyInfo pitem in pArr) { pitem.IsSelf = false; } exList.AddRange(pArr); return(exList.ToArray()); }
public override Exp Analy(AnalyExpContext context) { base.Analy(context); var symbols = this.AnalyExpContext.Symbols; SubjectExp = SubjectExp.Analy(context); // AnalyExp(SubjectExp); ArgExp = ArgExp.Analy(context); //AnalyExp(ArgExp); var propertyName = "Item"; var subjType = SubjectExp.RetType; ExProperty = GclUtil.SearchExProperty(propertyName, subjType); //subjType.GetExProperty(propertyName); if (ExProperty == null) { error(SubjectExp.Postion, "不存在索引"); return(null); } else { RetType = ExProperty.Property.PropertyType; } return(this); }
public ExPropertyInfo SearchExProperty(string name) { var propertyArray = MType.GetProperties(/*BindingFlags.DeclaredOnly*/); foreach (var property in propertyArray) { if (ReflectionUtil.IsDeclare(MType, property)) { ZCodeAttribute propertyAttr = Attribute.GetCustomAttribute(property, typeof(ZCodeAttribute)) as ZCodeAttribute; if (propertyAttr == null) { if (property.Name == name) { //return ForType.GetExProperty(property.Name); return(GclUtil.CreatExPropertyInfo(ForType.GetProperty(property.Name), ForType)); } } else { if (propertyAttr.Code == name) { //return ForType.GetExProperty(property.Name); return(GclUtil.CreatExPropertyInfo(ForType.GetProperty(property.Name), ForType)); } } } } if (isRootMapping()) { return(null); } else { ExPropertyInfo property = ParentMapping.SearchExProperty(name); return(property); } }
public override Exp Analy(AnalyExpContext context) { base.Analy(context); var symbols = this.AnalyExpContext.Symbols; VarName = VarToken.GetText(); if (!IsNestedField) { if (VarSymbol == null) { VarSymbol = symbols.Get(VarName); } if (VarSymbol == null) { //VarSymbol = symbols.Get(VarName); List <SymbolEnumItem> enumValues = context.ClassContext.SearchEnumItem(VarName); if (enumValues.Count == 1) { VarSymbol = enumValues[0]; } if (enumValues.Count > 1) { errorf("'{0}'有多个相同约定值", VarName); return(null); } } if (VarSymbol == null) { if (context.ClassContext.ClassSymbol.BaseGcl != null) { ExPropertyInfo property = context.ClassContext.ClassSymbol.BaseGcl.SearchExProperty(VarName); if (property != null) { if (ReflectionUtil.IsPublic(property.Property) || ReflectionUtil.IsProtected(property.Property)) { SymbolDefProperty ps = new SymbolDefProperty(VarName, property.Property.PropertyType, ReflectionUtil.IsStatic(property.Property)); ps.SetProperty(property.Property); VarSymbol = ps; } } } } if (VarSymbol == null) { if (context.ClassContext.ClassSymbol.BaseGcl != null) { ExFieldInfo field = context.ClassContext.ClassSymbol.BaseGcl.SearchExField(VarName); if (field != null) { if (field.Field.IsPublic || field.Field.IsFamily) { SymbolDefField fs = new SymbolDefField(VarName, field.Field.FieldType, field.Field.IsStatic); fs.SetField(field.Field); VarSymbol = fs; } } } } if (VarSymbol == null) { if (IsAssignedBy) { SymbolVar varSymbol = new SymbolVar(VarName); if (!varSymbol.IsInBlock) { varSymbol.LoacalVarIndex = context.StmtContext.MethodContext.CreateLocalVarIndex(VarName); symbols.Add(varSymbol); } VarSymbol = varSymbol; } else { errorf("'{0}'没有赋值", VarName); return(null); } } RetType = ((InstanceSymbol)VarSymbol).DimType; } else { } return(this); }
public override void Analy(AnalyStmtContext context) { //base.LoadRefTypes(context); int foreachIndex = context.MethodContext.CreateForeachIndex(); if (ListExp == null) { error("'循环每一个语句'不存在要循环的列表"); } if (ElementToken == null) { error("'循环每一个语句'不存在成员名称"); } if (ListExp == null || ElementToken == null) { return; } this.AnalyStmtContext = context; var symbols = context.Symbols; ListExp = AnalyExp(ListExp); if (ListExp == null) { TrueAnalyed = false; return; } if (ListExp.RetType == null) { TrueAnalyed = false; return; } else if (!canForeach(ListExp.RetType)) { error(ListExp.Postion, "该结果不能用作循环每一个"); return; } if (ReflectionUtil.IsExtends(ListExp.RetType, typeof(列表 <>))) { startIndex = 1; compareMethod = typeof(Calculater).GetMethod("LEInt", new Type[] { typeof(int), typeof(int) }); } else { startIndex = 0; compareMethod = typeof(Calculater).GetMethod("LTInt", new Type[] { typeof(int), typeof(int) }); } //PropertyInfo countProperty = ListExp.RetType.GetProperty("Count"); ExPropertyInfo countProperty = GclUtil.SearchExProperty("Count", ListExp.RetType); getCountMethod = new ExMethodInfo(countProperty.Property.GetGetMethod(), countProperty.IsSelf); //PropertyInfo itemProperty = ListExp.RetType.GetProperty("Item"); ExPropertyInfo itemProperty = GclUtil.SearchExProperty("Item", ListExp.RetType); diMethod = new ExMethodInfo(itemProperty.Property.GetGetMethod(), itemProperty.IsSelf); elementName = ElementToken.GetText(); if (IndexToken != null) { indexName = IndexToken.GetText(); } else { indexName = "$$$foreach_" + foreachIndex + "_index"; } createForeachSymbols(context, symbols, foreachIndex, ListExp.RetType); analySubStmt(Body); }
public override Exp Analy(AnalyExpContext context) { base.Analy(context); if (MemberToken == null) { error("'的'字前面没有对象"); return(null); } if (MemberToken == null) { error("'的'字后面没有属性名称"); return(null); } var symbols = this.AnalyExpContext.Symbols; SubjectExp.IsAssignedBy = this.IsAssignedBy; SubjectExp.IsAssignedValue = this.IsAssignedValue; SubjectExp = SubjectExp.Analy(context); propertyName = MemberToken.GetText(); var subjType = SubjectExp.RetType; if (subjType == null) { return(null); } if (propertyName == "每一个" && subjType.IsGenericType && subjType.GetGenericTypeDefinition() == typeof(Z语言系统.列表 <>)) { EveryOneExp eoexp = new EveryOneExp(); eoexp.ListExp = this.SubjectExp; eoexp.MemberToken = this.MemberToken; Exp eoExp = eoexp.Analy(context); return(eoExp); } else { if (!(subjType is TypeBuilder)) { IGcl obj = context.StmtContext.MethodContext.ClassContext.ImportContext.SearchGCL(subjType); if (obj == null) { //ExProperty = subjType.GetExProperty(propertyName); ExProperty = GclUtil.SearchExProperty(propertyName, subjType); } else { ExProperty = obj.SearchExProperty(propertyName); } } else { string name = subjType.Name; SymbolInfo symbol = symbols.Get(name); if (symbol is SymbolDefClass) { ExProperty = (symbol as SymbolDefClass).GetExProperty(propertyName); //ExProperty = GclUtil.SearchExProperty(propertyName, symbol as SymbolDefClass); } } } if (ExProperty == null) { error(SubjectExp.Postion, "不存在" + propertyName + "属性"); return(null); } else { RetType = ExProperty.Property.PropertyType; } return(this); }
public SymbolPropertyDirect(string name, ExPropertyInfo exProperty) { this.SymbolName = name; ExProperty = exProperty; }