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); }