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


C# ICLS_Environment.GetTypeByKeywordQuiet方法代码示例

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


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

示例1: Compiler_Class

        ICLS_Type Compiler_Class(ICLS_Environment env, string classname, IList<string> baseTypeNames, string filename, IList<Token> tokens, int ibegin, int iend, bool EmbDebugToken, bool onlyGotType = false, IList<string> usinglist = null)
        {
            CLS_Type_Class sClass = env.GetTypeByKeywordQuiet(classname) as CLS_Type_Class;

            if (sClass == null)
                sClass = new CLS_Type_Class(classname, filename);

            sClass.compiled = false;
            (sClass.function as SType).functions.Clear();
            (sClass.function as SType).members.Clear();

            if (onlyGotType)
                return sClass;

            // 调试Token
            if (EmbDebugToken)
                (sClass.function as SType).EmbDebugToken(tokens);

            bool bStatic = false;
            int sortIndex = 0;

            for (int i = ibegin; i <= iend; i++)
            {
                if (tokens[i].type == TokenType.KEYWORD && tokens[i].text == "static")
                {
                    bStatic = true;
                    continue;
                }

                if (tokens[i].type == TokenType.ProtoIndex)
                {
                    sortIndex = int.Parse(tokens[i].text);
                    continue;
                }

                if (tokens[i].type == TokenType.TYPE || (tokens[i].type == TokenType.IDENTIFIER && tokens[i].text == classname))//发现类型
                {
                    ICLS_Type idtype = env.GetTypeByKeyword("null");
                    bool bctor = false;
                    if (tokens[i].type == TokenType.TYPE)
                    {
                        if (tokens[i].text == classname && tokens[i + 1].text == "(")
                        {
                            //构造函数
                            bctor = true;
                            i--;
                        }
                        else if (tokens[i + 1].text == "[" && tokens[i + 2].text == "]")
                        {
                            idtype = env.GetTypeByKeyword(tokens[i].text + "[]");
                            i += 2;
                        }
                        else if (tokens[i].text == "void")
                        {

                        }
                        else
                        {
                            idtype = env.GetTypeByKeyword(tokens[i].text);
                        }
                    }

                    if (tokens[i + 1].type == CSLE.TokenType.IDENTIFIER || bctor) //类型后面是名称
                    {
                        string idname = tokens[i + 1].text;
                        if (tokens[i + 2].type == CSLE.TokenType.PUNCTUATION && tokens[i + 2].text == "(")//参数开始,这是函数
                        {
                            logger.Log("发现函数:" + idname);
                            SType.Function func = new SType.Function();
                            func.bStatic = bStatic;

                            int funcparambegin = i + 2;
                            int funcparamend = FindBlock(env, tokens, funcparambegin);
                            if (funcparamend - funcparambegin > 1)
                            {
                                int start = funcparambegin + 1;
                                for (int j = funcparambegin + 1; j <= funcparamend; j++)
                                {
                                    if (tokens[j].text == "," || tokens[j].text == ")")
                                    {
                                        string ptype = "";
                                        for (int k = start; k <= j - 2; k++)
                                            ptype += tokens[k].text;
                                        var pid = tokens[j - 1].text;
                                        var type = env.GetTypeByKeyword(ptype);

                                        if (type == null)
                                        {
                                            throw new Exception(filename + ":不可识别的函数头参数:" + tokens[funcparambegin].ToString());
                                        }

                                        func._paramnames.Add(pid);
                                        func._paramtypes.Add(type);
                                        start = j + 1;
                                    }
                                }
                            }

                            int funcbegin = funcparamend + 1;
                            if (tokens[funcbegin].text == "{")
//.........这里部分代码省略.........
开发者ID:wpszz,项目名称:CSLightForUnity,代码行数:101,代码来源:CLS_Compiler_07OO.cs

示例2: Compiler_Class

        ICLS_Type Compiler_Class(ICLS_Environment env, string classname, bool bInterface, IList<string> basetype, string filename, IList<Token> tokens, int ibegin, int iend, bool EmbDebugToken, bool onlyGotType, IList<string> usinglist)
        {

            CLS_Type_Class stype = env.GetTypeByKeywordQuiet(classname) as CLS_Type_Class;

            if (stype == null)
                stype = new CLS_Type_Class(classname, bInterface, filename);

            if (basetype != null && basetype.Count != 0 && onlyGotType == false)
            {
                List<ICLS_Type> basetypess = new List<ICLS_Type>();
                foreach (string t in basetype)
                {
                    ICLS_Type type = env.GetTypeByKeyword(t);
                    basetypess.Add(type);
                }
                stype.SetBaseType(basetypess);
            }

            if (onlyGotType) return stype;

            //if (env.useNamespace && usinglist != null)
            //{//使用命名空间,替换token

            //    List<Token> newTokens = new List<Token>();
            //    for (int i = ibegin; i <= iend; i++)
            //    {
            //        if (tokens[i].type == TokenType.IDENTIFIER)
            //        {
            //            string ntype = null;
            //            string shortname = tokens[i].text;
            //            int startpos = i;
            //            while (ntype == null)
            //            {

            //                foreach (var u in usinglist)
            //                {
            //                    string ttype = u + "." + shortname;
            //                    if (env.GetTypeByKeywordQuiet(ttype) != null)
            //                    {
            //                        ntype = ttype;

            //                        break;
            //                    }

            //                }
            //                if (ntype != null) break;
            //                if ((startpos + 2) <= iend && tokens[startpos + 1].text == "." && tokens[startpos + 2].type == TokenType.IDENTIFIER)
            //                {
            //                    shortname += "." + tokens[startpos + 2].text;

            //                    startpos += 2;
            //                    if (env.GetTypeByKeywordQuiet(shortname) != null)
            //                    {
            //                        ntype = shortname;

            //                        break;
            //                    }
            //                    continue;
            //                }
            //                else
            //                {
            //                    break;
            //                }
            //            }
            //            if (ntype != null)
            //            {
            //                var t = tokens[i];
            //                t.text = ntype;
            //                t.type = TokenType.TYPE;
            //                newTokens.Add(t);
            //                i = startpos;
            //                continue;
            //            }
            //        }
            //        newTokens.Add(tokens[i]);
            //    }
            //    tokens = newTokens;
            //    ibegin = 0;
            //    iend = tokens.Count - 1;
            //}

            stype.compiled = false;
            (stype.function as SType).functions.Clear();
            (stype.function as SType).members.Clear();
            //搜寻成员定义和函数
            //定义语法            //Type id[= expr];
            //函数语法            //Type id([Type id,]){block};
            //属性语法            //Type id{get{},set{}};
            bool bPublic = false;
            bool bStatic = false;
            if (EmbDebugToken)//SType 嵌入Token
            {
                stype.EmbDebugToken(tokens);
            }
            for (int i = ibegin; i <= iend; i++)
            {

                if (tokens[i].type == TokenType.KEYWORD && tokens[i].text == "public")
                {
//.........这里部分代码省略.........
开发者ID:lightszero,项目名称:cslightcore,代码行数:101,代码来源:CLS_Compiler_07OO.cs


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