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()); }
public static ExFieldInfo CreatExFieldInfo(FieldInfo propertyInfo, Type forType) { if (propertyInfo == null) { return(null); } ExFieldInfo exFieldInfo = new ExFieldInfo(propertyInfo, propertyInfo.DeclaringType == forType); return(exFieldInfo); }
public static ExFieldInfo SearchExField(string name, Type forType) { var fieldInfo = forType.GetField(name); if (fieldInfo == null) { return(null); } ExFieldInfo exFieldInfo = new ExFieldInfo(fieldInfo, fieldInfo.DeclaringType == forType); return(exFieldInfo); }
public SymbolFieldDirect(string name, ExFieldInfo exField) { this.SymbolName = name; ExField = exField; }
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); }