예제 #1
0
        public void Generate(List <FourExp> fourExpList, VarTable varTable, List <AssemblerIns> cmdList)
        {
            //为变量分配内存,并对符号的活跃信息域进行初始化
            List <string> varNameList = varTable.GetNames();

            initVarTable(varTable, fourExpList, varNameList);

            //生成数据段
            genDataIns(varNameList, varTable, cmdList);

            int count = 0;

            foreach (FourExp f in fourExpList)
            {
                foreach (string varName in varNameList)
                {
                    //从符号表的后续引用信息域和活跃域中去除无用信息
                    if (varTable.GetPeekRefeInfo(varName) == count)
                    {
                        //varTable.PopRefeInfo(varName);
                        varTable.PopActInfo(varName);
                    }
                    count++;
                }
                convert(f, varTable, cmdList);
                optimize();
            }
        }