Esempio n. 1
0
        public void CompileName(ClassContext classContext, bool isStatic)
        {
            if (TypeToken == null || NameToken == null)
            {
                TrueAnalyed = false;
                return;
            }
            IsStatic          = isStatic;
            this.ClassContext = classContext;
            var symbols = ClassContext.Symbols;

            TypeName     = TypeToken.GetText();
            PropertyName = NameToken.GetText();
            PropertyGcl  = classContext.SearchType(TypeName);

            if (PropertyGcl != null)
            {
                PropertyType = PropertyGcl.ForType;
            }
            else
            {
                errorf("没有找到类型'{0}'", TypeName);
            }

            if (ClassContext.ClassSymbol.PropertyDict.ContainsKey(PropertyName))
            {
                error("属性'" + PropertyName + "'已经存在");
                return;
            }

            if (PropertyType == null)
            {
                error("属性类型'" + TypeName + "'不存在");
                return;
            }
            PropertySymbol = new SymbolDefProperty(PropertyName, PropertyType, isStatic);
            symbols.AddSafe(PropertySymbol);
            ClassContext.ClassSymbol.PropertyDict.Add(PropertyName, PropertySymbol);

            var classBuilder = ClassContext.EmitContext.CurrentTypeBuilder;

            GenerateName(classBuilder, IsStatic);

            AnalyBody(classContext);
        }