当前位置: 首页>>代码示例>>C#>>正文


C# Expr.ToQualifiedName方法代码示例

本文整理汇总了C#中Expr.ToQualifiedName方法的典型用法代码示例。如果您正苦于以下问题:C# Expr.ToQualifiedName方法的具体用法?C# Expr.ToQualifiedName怎么用?C# Expr.ToQualifiedName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Expr的用法示例。


在下文中一共展示了Expr.ToQualifiedName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMemberAccess

        /// <summary>
        /// Gets a member access object representing the a member access.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="ctx"></param>
        /// <param name="varExp"></param>
        /// <param name="memberName"></param>
        /// <returns></returns>
        public static MemberAccess GetMemberAccess(AstNode node, Context ctx, Expr varExp, string memberName, IAstVisitor visitor)
        {
            var isVariableExp = varExp.IsNodeType(NodeTypes.SysVariable);
            var variableName = isVariableExp ? ((VariableExpr) varExp).Name : string.Empty;

            // CASE 1: External function call "user.create"
            if (isVariableExp && FunctionHelper.IsExternalFunction(ctx.ExternalFunctions, variableName, memberName))
                return new MemberAccess(MemberMode.FunctionExternal) {Name = variableName, MemberName = memberName};

            // CASE 2. Static method call: "Person.Create" 
            if (isVariableExp)
            {
                var result = MemberHelper.IsExternalTypeName(ctx.Memory, ctx.Types, variableName);
                if (result.Success)
                    return MemberHelper.GetExternalTypeMember(node, (Type) result.Item, variableName, null, memberName, true);
            }
            
            // CASE 3: Module
            if (varExp.IsNodeType(NodeTypes.SysVariable))
            {
                var name = varExp.ToQualifiedName();
                if (!ctx.Memory.Contains(name))
                {
                    var modresult = ResolveSymbol(varExp.SymScope, name);
                    if (modresult != null) return modresult;
                }
            }

            // CASE 4: Nested member.
            var res = varExp.Visit(visitor);
            if (res is MemberAccess )
            {
                return res as MemberAccess;
            }

            var obj = res as LObject;
            // Check for empty objects.
            ExceptionHelper.NotNull(node,  obj, "member access");

            var type = obj.Type;

            // Case 3: Method / Property on FluentScript type
            bool isCoreType = obj.Type.IsBuiltInType();
            if (isCoreType)
            {
                var result = MemberHelper.GetLangBasicTypeMember(node, ctx.Methods, obj, memberName);
                return result;
            }

            // CASE 4: Method / Property on External/Host language type (C#)
            var lclass = obj as LClass;
            var lclassType = lclass.Type as LClassType;
            var member = MemberHelper.GetExternalTypeMember(node, lclassType.DataType, variableName, lclass.Value, memberName, false);
            return member;
        }
开发者ID:GHLabs,项目名称:SambaPOS-3,代码行数:63,代码来源:MemberHelper.cs

示例2: ParseFuncExpression

        /// <summary>
        /// Parses function expression :
        /// 1. getAdminUser()
        /// 2. getUser(1)
        /// 3. getUserByNameOrEmail("user01", "[email protected]")
        /// </summary>
        /// <param name="nameExp">Expression representing the function name.</param>
        /// <param name="members">The individual members if function call on a member expression e.g. math.min(1,2);</param>
        /// <returns></returns>
        public Expr ParseFuncExpression(Expr nameExp, List<string> members)
        {
            // Validate
            var funcExp = (FunctionCallExpr)Exprs.FunctionCall(nameExp, null, nameExp.Token);
            _state.FunctionCall++;
            _context.Limits.CheckParserFuncCallNested(_tokenIt.NextToken, _state.FunctionCall);

            // Check for optional parenthesis.
            var expectParenthesis = _tokenIt.NextToken.Token == Tokens.LeftParenthesis;

            // Handle named parameters only for internal functions right now.
            var fname = nameExp.ToQualifiedName();
            var hasMemberAccess = false; // members != null && members.Count > 1;
            var isScriptFunc = nameExp.SymScope.IsFunction(fname);

            // Case 1: External c# function.
            if (_context.ExternalFunctions.Contains(fname))
            {
                ParseParameters(funcExp, expectParenthesis, false, !expectParenthesis);
            }
            // Case 2: Internal function in global namespace.
            else if(isScriptFunc)
            {
                var sym = nameExp.SymScope.GetSymbol(fname) as SymbolFunction;
                var meta = sym.Meta;
                FluentHelper.ParseFuncParameters(funcExp.ParamListExpressions, _tokenIt, this, expectParenthesis, !expectParenthesis, meta);
            }
            else if (!isScriptFunc) // Type method call.
            {
                FluentHelper.ParseFuncParameters(funcExp.ParamListExpressions, _tokenIt, this, expectParenthesis, !expectParenthesis, null);                
            }
            // Case 3: Member acccess
            else if (hasMemberAccess)
            {
                var symScope = this._context.Symbols.Current;
                FunctionMetaData meta = null;
                FunctionExpr fexpr = null;
                for (var ndx = 0; ndx < members.Count; ndx++)
                {
                    var member = members[ndx];
                    
                    // module ?
                    var sym = symScope.GetSymbol(member);
                    if( sym.Category == SymbolCategory.Module)
                    {
                        symScope = ((SymbolModule)sym).Scope;
                    }
                    // last one ?
                    else if (sym.Category == SymbolCategory.Func)
                    {
                        meta = ((SymbolFunction)sym).Meta;
                        break;
                    }
                }
                funcExp.Function = fexpr;
                FluentHelper.ParseFuncParameters(funcExp.ParamListExpressions, _tokenIt, this, expectParenthesis, !expectParenthesis, meta); 
            }
            _state.FunctionCall--;
            return funcExp;
        }
开发者ID:GHLabs,项目名称:SambaPOS-3,代码行数:69,代码来源:Parser.cs


注:本文中的Expr.ToQualifiedName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。