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 void GenerateName(TypeBuilder classBuilder, bool isStatic) { string propertyName = PropertySymbol.SymbolName; Type propertyType = PropertySymbol.PropertyType; MethodAttributes methodAttr = getMethodAttr(isStatic); FieldAttributes fieldAttr = getFieldAttr(isStatic); FieldBuilder field = classBuilder.DefineField("_" + propertyName, propertyType, fieldAttr); PropertyBuilder property = classBuilder.DefineProperty(propertyName, PropertyAttributes.None, propertyType, null); emitGet(classBuilder, propertyName, propertyType, isStatic, field, property, methodAttr); emitSet(classBuilder, propertyName, propertyType, isStatic, field, property, methodAttr); PropertySymbol.SetProperty(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); }