Example #1
0
 public override Exp Analy()
 {
     if (this.IsAnalyed)
     {
         return(this);
     }
     SubjectExp = SubjectExp.Analy();
     if (SubjectExp.RetType == null)
     {
         //Type newType =typeof(列表<>).MakeGenericType(typeof(object));
         //ZType newZtype = ZTypeManager.RegNewGenericType(newType);
         ZLClassInfo newZClass = ZTypeManager.MakeGenericType(ZLangBasicTypes.ZLIST, ZLangBasicTypes.ZOBJECT);
         SubjectExp.RetType = newZClass;
     }
     CreateEachSymbols();
     AnalyCountMethod();
     ItemExp      = new ExpEachItem(this.ExpContext, this.ListSymbol, this.IndexSymbol);
     this.RetType = ZLangBasicTypes.ZVOID;
     IsAnalyed    = true;
     return(this);
 }
Example #2
0
        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);
        }
Example #3
0
        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);
        }