Пример #1
0
 public TypeExp(Exp srcExp, Token typeToken, SymbolDefClass dType)
     : base(srcExp)
 {
     TypeToken = typeToken;
     DType     = dType;
     type      = 2;
 }
Пример #2
0
        Exp analyParentClass(AnalyExpContext context)
        {
            ClassContext   classContext = context.ClassContext;
            SymbolDefClass classSymbol  = classContext.ClassSymbol;

            if (classSymbol.BaseGcl == null)
            {
                return(null);
            }
            ExPropertyInfo property = classSymbol.BaseGcl.SearchExProperty(IdentName);

            //if (property == null) return null;
            if (property != null)
            {
                if (ReflectionUtil.IsPublic(property.Property) || ReflectionUtil.IsProtected(property.Property))
                {
                    SymbolDefProperty ps = new SymbolDefProperty(IdentName, property.Property.PropertyType, ReflectionUtil.IsStatic(property.Property));
                    ps.SetProperty(property.Property);

                    VarExp exp = new VarExp(this, this.IdentToken);
                    exp.VarSymbol = ps;
                    return(exp);
                }
            }
            return(null);
        }
Пример #3
0
        public bool Analy(FnName fn, int argIndex)
        {
            var symbols = fn.MethodAST.MethodContext.Symbols;

            if (ArgTypeToken != null && ArgNameToken != null)
            {
                ArgName = ArgNameToken.GetText();
                if (ArgTypeToken.IsKeyIdent("类型"))
                {
                    ArgType      = typeof(object);
                    IsGenericArg = true;
                }
                else
                {
                    IsGenericArg = false;
                    string     argTypeName = ArgTypeToken.GetText();
                    SymbolInfo symbol      = symbols.Get(argTypeName);
                    if (symbol != null)
                    {
                        SymbolDefClass defClass = symbol as SymbolDefClass;
                        if (defClass != null)
                        {
                            ArgType = defClass.ClassBuilder;
                        }
                    }

                    if (ArgType == null)
                    {
                        //var gcls = fn.MethodAST.MethodContext.ClassContext.ImportContext.SearchGCL(argTypeName);
                        //if (gcls.Length == 1)
                        //{
                        //    ArgType = gcls[0].ForType;
                        //}
                        var gcl = fn.MethodAST.MethodContext.ClassContext.SearchType(argTypeName); //
                        if (gcl != null)
                        {
                            ArgType = gcl.ForType;
                        }
                        if (ArgType == null)
                        {
                            error(string.Format("不存在或者不确定'{0}'类型", argTypeName));
                            return(false);
                        }
                    }
                }
                if (ArgType != null)
                {
                    if (symbols.Contains(ArgName))
                    {
                        errorf("'{0}'已经存在相同的名称", ArgName);
                        return(false);
                    }
                    else
                    {
                        SymbolArg argSymbol = new SymbolArg(ArgName, ArgType, argIndex, IsGenericArg);
                        symbols.AddSafe(argSymbol);
                    }
                }
            }
            else
            {
                error("参数不正确");
                return(false);
            }
            return(true);
        }