Пример #1
0
        public static Instruction Step(this Instruction current, Instruction last, CompileContext compileContext)
        {
            if (StatementStructure.Recognize(new CodeBlock(current, last), out StatementStructure statementStructure) != StatementStructureType.Unknown)
            {
                string s = statementStructure.Generate(compileContext);
                compileContext.WriteLine(s);
                return(statementStructure.all.last.Next);
            }
            uint?localVariableIndex = compileContext.GetLocalVariableInstructionIndex(current);

            if (localVariableIndex != null && compileContext.IsUnnecessaryLocalVariableID(localVariableIndex.Value))
            {
                return(current.Next.Next);
            }
            var code = current.OpCode.Code;

            if (!methods.TryGetValue(code, out MethodInfo method))
            {
                throw new Exception(string.Format("Unsupported operate code: {0}", code));
            }
            method.Invoke(null, new object[] { current, compileContext });
            return(current.Next);
        }