CSLE.CLS_Expression_Compiler._FileCompiler C# (CSharp) Method

_FileCompiler() private method

private _FileCompiler ( string filename, IList tokens, bool embDeubgToken, ICLS_Environment env, bool onlyGotType ) : IList
filename string
tokens IList
embDeubgToken bool
env ICLS_Environment
onlyGotType bool
return IList
        IList<ICLS_Type> _FileCompiler(string filename, IList<Token> tokens, bool embDeubgToken, ICLS_Environment env, bool onlyGotType)
        {
            List<ICLS_Type> typelist = new List<ICLS_Type>();

            List<string> usingList = new List<string>();
            //识别using

            //扫描token有没有要合并的类型
            //using的实现在token级别处理即可
            bool bJumpClass = false;
            for (int i = 0; i < tokens.Count; i++)
            {
                if (tokens[i].type == TokenType.PUNCTUATION && tokens[i].text == ";")
                    continue;
                if (tokens[i].type == TokenType.COMMENT)
                    continue;
                if (tokens[i].type == TokenType.KEYWORD && tokens[i].text == "using")
                {
                    int dep;
                    int pos = i;
                    int iend = FindCodeAny(tokens, ref pos, out dep);
                    List<string> list = Compiler_Using(tokens, env, pos, iend);
                    string useText = "";
                    for (int j = 0; j < list.Count; j++)
                    {
                        useText += list[j];
                        if (j != list.Count - 1)
                        {
                            useText += ".";
                        }
                    }
                    usingList.Add(useText);
                    i = iend;
                    continue;
                }

                if (tokens[i].type == TokenType.PUNCTUATION && tokens[i].text == "[")
                {
                    if (tokens[i + 1].text == "NotScipt" || (tokens[i + 1].text == "CSLE" && tokens[i + 3].text == "NotScipt"))
                    {
                        bJumpClass = true;
                        i = i + 2;
                        continue;
                    }
                }
                if (tokens[i].type == TokenType.KEYWORD && (tokens[i].text == "class" || tokens[i].text == "interface"))
                {
                    string name = tokens[i + 1].text;
                    //在这里检查继承
                    List<string> typebase = null;
                    int ibegin = i + 2;
                    if (onlyGotType)
                    {
                        while (tokens[ibegin].text != "{")
                        {
                            ibegin++;
                        }
                    }
                    else
                    {
                        if (tokens[ibegin].text == ":")
                        {
                            typebase = new List<string>();
                            ibegin++;
                        }
                        while (tokens[ibegin].text != "{")
                        {
                            if (tokens[ibegin].type == TokenType.TYPE)
                            {
                                typebase.Add(tokens[ibegin].text);
                            }
                            ibegin++;
                        }
                    }
                    int iend = FindBlock(env, tokens, ibegin);
                    if (iend == -1)
                    {
                        env.logger.Log_Error("查找文件尾失败。");
                        return null;
                    }
                    if (bJumpClass)
                    {
                        env.logger.Log("(NotScript)findclass:" + name + "(" + ibegin + "," + iend + ")");
                    }
                    else if (onlyGotType)
                    {
                        env.logger.Log("(scriptPreParser)findclass:" + name + "(" + ibegin + "," + iend + ")");

                    }
                    else
                    {
                        env.logger.Log("(scriptParser)findclass:" + name + "(" + ibegin + "," + iend + ")");

                    }
                    if (bJumpClass)
                    {//忽略这个Class
                        //ICLS_Type type = Compiler_Class(env, name, (tokens[i].text == "interface"), filename, tokens, ibegin, iend, embDeubgToken, true);
                        //bJumpClass = false;
                    }
                    else
                    {
                        ICLS_Type type = Compiler_Class(env, name, (tokens[i].text == "interface"), typebase, filename, tokens, ibegin, iend, embDeubgToken, onlyGotType, usingList);
                        if (type != null)
                        {
                            typelist.Add(type);
                        }
                    }
                    i = iend;
                    continue;
                }
            }

            return typelist;
        }
        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)