public override Exp Analy(AnalyExpContext context) { base.Analy(context); classContext = context.StmtContext.MethodContext.ClassContext; var symbols = this.AnalyExpContext.Symbols; if (!analyCallBody()) { return(null); } searchedProcDesc = searchProc(classContext); if (searchedProcDesc == null) { errorf("没有找到过程'{0}'", this.ToCode()); return(null); } searchedProcDesc.AdjustBracket(ExpProcDesc); CallExMethod = searchedProcDesc.ExMethod; if (CallExMethod == null) { return(null); } RetType = CallExMethod.Method.ReturnType; analyGeneric(); analyArgLanmbda(context); if (isSubjectEveryOneExp()) { InvokeEveryoneSubejctExp ieoexp = new InvokeEveryoneSubejctExp(this); Exp ioeResultExp = ieoexp.Analy(context); return(ioeResultExp); } else if (isObjectEveryOneExp()) { InvokeEveryoneObejctExp ieoexp = new InvokeEveryoneObejctExp(this); Exp ioeResultExp = ieoexp.Analy(context); return(ioeResultExp); } return(this); }
public override Exp Analy(AnalyExpContext context) { base.Analy(context); var classContext = context.StmtContext.MethodContext.ClassContext; var symbols = this.AnalyExpContext.Symbols; BrackestArgs = BrackestArgs.Analy(context) as BracketExp; if (!BrackestArgs.TrueAnalyed) { return(null); } Type subjectType = SubjectGCL.ForType; if (subjectType.FullName.StartsWith(CompileConstant.LangPackageName + ".列表`1[")) { newCode = 1; ConstructorDesc = new TKTConstructorDesc(); var Constructor = subjectType.GetConstructor(new Type[] {}); if (Constructor == null) { error(BrackestArgs.Postion, "没有正确的创建过程"); return(null); } else { RetType = subjectType; ConstructorDesc.Constructor = Constructor; Type[] genericTypes = GenericUtil.GetInstanceGenriceType(subjectType, typeof(列表 <>)); Type ElementType = genericTypes[0]; var args = BrackestArgs.GetDimArgs(); for (int i = 0; i < args.Count; i++) { Exp arg = args[i].Value as Exp; if (arg.RetType != ElementType && !ReflectionUtil.IsExtends(arg.RetType, ElementType)) { errorf(arg.Postion, "类型不是列表的子类型,不能添加"); } } } } else { var args = BrackestArgs.GetDimArgs(); ProcDesc = new TKTProcDesc(); ProcDesc.Add(SubjectGCL.ShowName); ProcDesc.Add(args); TKTProcDesc newProcDesc = searchNewProc(classContext, ProcDesc); if (newProcDesc != null) { newProcDesc.AdjustBracket(ProcDesc);// ProcDesc.AdjustBracket(newProcDesc); ProcDesc.ExMethod = newProcDesc.ExMethod; newCode = 3; RetType = ProcDesc.ExMethod.Method.ReturnType; } else { ConstructorDesc = new TKTConstructorDesc(args); TKTConstructorDesc realDesc = SubjectGCL.SearchConstructor(ConstructorDesc); if (realDesc == null) { error(BrackestArgs.Postion, "没有正确的创建过程"); return(null); } else { RetType = SubjectGCL.ForType; realDesc.AdjustBracket(ConstructorDesc); ConstructorDesc.Constructor = realDesc.Constructor; newCode = 2; } } } return(this); }