Esempio n. 1
0
 public IntermediateCode(Object _operant, InstructionType _type, int line)
 {
     operant     = _operant;
     type        = _type;
     lineNum     = line;
     information = new IntermediateCodeInformation();
 }
Esempio n. 2
0
        /// <summary>
        /// 获取刚执行完的指令信息
        /// </summary>
        /// <returns>指令信息</returns>
        public IntermediateCodeInformation GetLastCodeInformation()
        {
            IntermediateCodeInformation lastInformation = new IntermediateCodeInformation();

            lastInformation.Address = pc;
            lastInformation.Line    = codesArray[pc].lineNum;
            return(lastInformation);
        }
Esempio n. 3
0
        /// <summary>
        /// 获取源代码-中间代码信息
        /// </summary>
        /// <returns>源代码-中间代码信息</returns>
        public Dictionary <int, IntermediateCodeInformation> GetIntermediateCodeInformation()
        {
            int length = codesArray.Count;
            Dictionary <int, IntermediateCodeInformation> informations = new Dictionary <int, IntermediateCodeInformation>();

            // 遍历中间代码
            for (int i = 0; i < length; i++)
            {
                IntermediateCode current = codesArray[i];
                int currentLine          = current.lineNum;
                IntermediateCodeInformation currentInformation;

                // 判断该中间指令对应源代码的行是否已经加入信息表中
                if (informations.TryGetValue(currentLine, out currentInformation))
                {
                    // 该行含函数调用则更新函数入口地址列表
                    if (current.type == InstructionType.call)
                    {
                        currentInformation.IsFunctionCall = true;
                        currentInformation.FuncionEntryList.AddLast((int)current.operant);
                        informations[currentLine] = currentInformation;
                    }
                }
                else
                {
                    // 该行源代码首条中间指令
                    currentInformation                  = new IntermediateCodeInformation();
                    currentInformation.Address          = i;
                    currentInformation.Line             = currentLine;
                    currentInformation.IsFunctionCall   = false;
                    currentInformation.FuncionEntryList = new LinkedList <int>();
                    informations.Add(currentLine, currentInformation);
                }
            }
            return(informations);
        }
Esempio n. 4
0
 public IntermediateCode(InstructionType _type, int line)
 {
     type        = _type;
     information = new IntermediateCodeInformation();
     lineNum     = line;
 }
Esempio n. 5
0
 public IntermediateCode(int line)
 {
     information = new IntermediateCodeInformation();
     lineNum     = line;
 }