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


C# ICLS_Environment.GetFunction方法代码示例

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


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

示例1: Compiler_Expression_Math

        public ICLS_Expression Compiler_Expression_Math(IList<Token> tlist, ICLS_Environment environment, int pos, int posend)
        {
            IList<int> sps = SplitExpressionWithOp(tlist, pos, posend);
            if (sps == null)
                LogError(tlist, "SplitExpressionWithOp return null", pos, posend);
            int oppos = GetLowestMathOp(tlist, sps);
            if (oppos < 0)
            {
                if (tlist[pos + 1].type == TokenType.PUNCTUATION && tlist[pos + 1].text == "(")//函数表达式
                {
                    CLS_Expression_Function func = (CLS_Expression_Function)Compiler_Expression_Function(tlist, environment, pos, posend);
                    if (func != null)
                    {
                        if (environment.GetFunction(func.funcname) != null)
                        {
                            CLS_Expression_GlobalFunction globalFunc = new CLS_Expression_GlobalFunction(func.listParam, func.tokenBegin, func.tokenEnd, func.lineBegin, func.lineEnd);
                            globalFunc.funcname = func.funcname;
                            return globalFunc;
                        }
                    }
                    return func;
                }
                return null;
            }
            Token tkCur = tlist[oppos];
            if (tkCur.text == "=>")
            {
                return Compiler_Expression_Lambda(tlist, environment, pos, posend);
            }
            else if (tkCur.text == "." && pos == oppos - 1 && tlist[pos].type == TokenType.TYPE)
            {
                int right = oppos + 1;
                int rightend = posend;

                ICLS_Expression valueright;
                bool succ2 = Compiler_Expression(tlist, environment, right, rightend, out valueright);
                if (succ2)
                {
                    CLS_Expression_GetValue vg = valueright as CLS_Expression_GetValue;
                    CLS_Expression_Function vf = valueright as CLS_Expression_Function;
                    if (vg != null)
                    {
                        // 优化枚举常量表达式
                        try
                        {
                            System.Type sysType = environment.GetTypeByKeyword(tlist[pos].text).type;
                            if (sysType != null && sysType.IsEnum)
                            {
                                CLS_Expression_Enum enumVal = new CLS_Expression_Enum(sysType);
                                enumVal.tokenBegin = pos;
                                enumVal.tokenEnd = rightend;
                                enumVal.lineBegin = tlist[pos].line;
                                enumVal.lineEnd = tlist[rightend].line;
                                enumVal.value = Enum.Parse(sysType, vg.value_name);
                                return enumVal;
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Log_Warn("Enum expression: " + ex.Message);
                        }
                        CLS_Expression_StaticFind value = new CLS_Expression_StaticFind(pos, rightend, tlist[pos].line, tlist[rightend].line);
                        value.staticmembername = vg.value_name;
                        value.type = environment.GetTypeByKeyword(tlist[pos].text);
                        return value;
                    }
                    else if (vf != null)
                    {
                        CLS_Expression_StaticFunction value = new CLS_Expression_StaticFunction(pos, rightend, tlist[pos].line, tlist[rightend].line);
                        value.functionName = vf.funcname;
                        value.type = environment.GetTypeByKeyword(tlist[pos].text);
                        value.listParam.AddRange(vf.listParam.ToArray());
                        return value;
                    }
                    else if (valueright is CLS_Expression_SelfOp)
                    {
                        CLS_Expression_SelfOp vr = valueright as CLS_Expression_SelfOp;
                        CLS_Expression_StaticMath value = new CLS_Expression_StaticMath(pos, rightend, tlist[pos].line, tlist[rightend].line);
                        value.type = environment.GetTypeByKeyword(tlist[pos].text);
                        value.staticmembername = vr.value_name;
                        value.mathop = vr.mathop;
                        return value;
                    }
                    else
                    {
                        throw new Exception("不可识别的表达式:" + tkCur.ToString());
                    }
                }
                else
                {
                    throw new Exception("不可识别的表达式:" + tkCur.ToString());
                }
            }
            else
            {
                int left = pos;
                int leftend = oppos - 1;
                int right = oppos + 1;
                int rightend = posend;
                if (tkCur.text == "(")
//.........这里部分代码省略.........
开发者ID:wpszz,项目名称:CSLightForUnity,代码行数:101,代码来源:CLS_Compiler_04Math.cs


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