Esempio n. 1
0
        private ZType SearchValue(string zname)
        {
            ContextImportUse contextiu = this.FileContext.ImportUseContext;
            var ztypes = contextiu.SearchZTypesByClassNameOrDimItem(zname);

            return(ztypes[0]);
        }
Esempio n. 2
0
        private void AnalyType()
        {
            if (_IsExist)
            {
                return;
            }
            ContextImportUse contextiu = this.FileContext.ImportUseContext;

            string[] names = contextiu.GetArgSegementer().Cut(ArgText);
            if (names.Length != 2)
            {
                throw new CCException();
            }
            ArgZTypeName = names[0];
            ArgName      = names[1];
            if (this.MethodContext.HasParameter(ArgName))
            {
                _IsExist = true;
                CodePosition argPos = new CodePosition(ParameterRaw.ParameterToken.Line, ParameterRaw.ParameterToken.Col + ArgZTypeName.Length);
                FileContext.Errorf(argPos, "参数'{0}'重复", ArgName);
            }
            else
            {
                ZType[] ztypes = contextiu.SearchZTypesByClassNameOrDimItem(ArgZTypeName);
                ArgZType = ztypes[0];
                //_argSymbol = new SymbolArg(ArgName, ArgZType);
                //this.ProcContext.AddParameter(_argSymbol);
                //_argSymbol = new ZCParamInfo(ArgName, ArgZType);
                //ProcContext.AddParameter(_argSymbol);
                _ZCParam            = MethodContext.AddParameterName(ArgName);
                _ZCParam.ZParamType = ArgZType;
            }
        }
Esempio n. 3
0
 //ContextImportTypes segManager;
 //public ZTypeFinder Finder { get;private set; }
 public TypeArgParser(ContextClass classContext)//(ContextImportTypes segManager)
 {
     //this.segManager = segManager;
     // Finder = new ZTypeFinder(segManager);
     this.ClassContext = classContext;
     ImportUseContext  = classContext.FileContext.ImportUseContext;
 }
Esempio n. 4
0
        private ZLMethodInfo SearchZMethod(string name)
        {
            ZMethodCall calldesc = new ZMethodCall();

            calldesc.Add(name);
            ContextImportUse contextiu = this.FileContext.ImportUseContext;

            return(contextiu.SearchUseMethod(calldesc)[0]);
        }
Esempio n. 5
0
        private void AnalyNameItemText(LexTokenText nameToken)
        {
            ContextImportUse contextiu = this.ASTFile.FileContext.ImportUseContext;
            string           typeName  = nameToken.Text;

            if (contextiu.ContainsUserZTypeName(typeName))
            {
                this.ASTFile.FileContext.Errorf(nameToken.Position, "'{0}'重复使用", typeName);
            }
            else
            {
                contextiu.AddUseZTypeName(typeName);
                _TextStructTokens.Add(nameToken);
            }
        }
Esempio n. 6
0
        private ZLEnumItemInfo SearchValue(string zname)
        {
            ContextImportUse contextiu = this.FileContext.ImportUseContext;

            ZLEnumItemInfo[] cu = contextiu.SearchUsedZEnumItems(zname);
            return(cu[0]);

            //ContextUse cu = this.ClassContext.FileContext.UseContext;
            //foreach (var zenum in cu.UseZEnumList)
            //{
            //    var zitem = zenum.SearchValue(zname);
            //    if (zitem != null)
            //    {
            //        return zitem;
            //    }
            //}
            throw new CCException();
        }
Esempio n. 7
0
        private string AnalyPackageRaw(ZCompileCore.ASTRaws.SectionImportRaw.PackageRaw packageRaw)
        {
            ContextImportUse    contextiu = this.ASTFile.FileContext.ImportUseContext;
            List <LexTokenText> Tokens    = packageRaw.Parts;
            string PackageFullName        = string.Join("/", Tokens.Select(p => p.Text));

            if (contextiu.ContainsImportPackageName(PackageFullName))
            {
                this.ASTFile.FileContext.Errorf(packageRaw.Position, "开发包'{0}'已经导入", PackageFullName);
            }
            else
            {
                contextiu.AddImportPackageName(PackageFullName);
                LoadPackageTypes(PackageFullName, packageRaw.Position);
                return(PackageFullName);
            }
            return(null);
        }
Esempio n. 8
0
        private void AddPackage(ZPackageInfo zdesc)
        {
            ContextImportUse contextiu = this.ASTFile.FileContext.ImportUseContext;

            foreach (var item in zdesc.EnumTypes)
            {
                contextiu.AddImportType(item);
            }

            foreach (ZLDimInfo item in zdesc.DimTypes)
            {
                contextiu.AddDimType(item);
            }

            foreach (var item in zdesc.ClassTypes)
            {
                contextiu.AddImportType(item);
            }
            return;
        }
Esempio n. 9
0
        private ZType AnalyPropertyZType()
        {
            if (IsExists)
            {
                return(null);
            }
            bool isStatic = this.ParentProperties.ASTClass.ClassContext.IsStatic();

            ZPropertyCompiling.IsStatic = isStatic;
            ContextImportUse importUseContext = this.ParentProperties.ASTClass.FileContext.ImportUseContext;

            if (HasValue())
            {
                PropertyValueExp = AnalyPropertyValueExp();
                ZType ztype = PropertyValueExp.RetType;
                if (ztype != null)
                {
                    return(ztype);
                }
            }
            else
            {
                //if (Raw.NameToken.Text.StartsWith("子弹类型"))
                //{
                //    Debugr.WriteLine("子弹类型");
                //}
                ZType[] ztypes = importUseContext.SearchImportType(this.PropertyName);
                if (ztypes.Length == 1)
                {
                    return(ztypes[0]);
                }
                else if (ztypes.Length == 0)
                {
                    this.ExpContext.FileContext.Errorf(Raw.NameToken.Line, Raw.NameToken.Col, "没有搜索到属性‘" + PropertyName + "’的类型");
                }
                else
                {
                }
            }
            return(ZLangBasicTypes.ZOBJECT);
        }
Esempio n. 10
0
        public void AnalyNameItemType(LexTokenText nameToken)
        {
            ContextImportUse importUseContext = this.ASTFile.FileContext.ImportUseContext;
            string           typeName         = nameToken.Text;
            var ztypes = importUseContext.SearchByTypeName(typeName);

            if (ztypes.Length == 0)
            {
                this.ASTFile.FileContext.Errorf(nameToken.Position, "没有搜索到'{0}'", typeName);
                return;
            }
            var descType = ztypes[0];

            if (descType is ZLClassInfo)
            {
                ZLClassInfo zclass = descType as ZLClassInfo;
                if (zclass.IsStatic)
                {
                    importUseContext.AddUseType(zclass);
                }
                else
                {
                    this.ASTFile.FileContext.Errorf(nameToken.Position, "'{0}'不是唯一类型,不能被导入类", typeName);
                }
            }
            else if (descType is ZLEnumInfo)
            {
                ZLEnumInfo zenum = descType as ZLEnumInfo;
                importUseContext.AddUseType(zenum);
            }
            else if (descType is ZLDimInfo)
            {
                ZLDimInfo zdim = descType as ZLDimInfo;
                importUseContext.AddDimType(zdim);
            }
            else
            {
                throw new CCException();
            }
        }
Esempio n. 11
0
        private ZLFieldInfo SearchZMember(string zname)
        {
            ContextImportUse importUseContext = this.FileContext.ImportUseContext;

            return(importUseContext.SearchUseZField(zname));
        }
Esempio n. 12
0
        private ZLPropertyInfo SearchZMember(string zname)
        {
            ContextImportUse importUseContext = this.FileContext.ImportUseContext;

            return(importUseContext.SearchUseZProperty(zname));
        }