Beispiel #1
0
        /// <summary>
        /// Performs stage specific processing on the compiler context.
        /// </summary>
        public void Run()
        {
            // Retrieve a stream to place the code into
            using (_codeStream = MethodCompiler.RequestCodeStream())
            {
                // HINT: We need seeking to resolve labels.
                Debug.Assert(_codeStream.CanSeek, "Can't seek code output stream.");
                Debug.Assert(_codeStream.CanWrite, "Can't write to code output stream.");

                if (!_codeStream.CanSeek || !_codeStream.CanWrite)
                {
                    throw new NotSupportedException("Code stream doesn't support seeking or writing.");
                }

                // Emit method prologue
                BeginGenerate();

                // Emit all instructions
                EmitInstructions();

                // Emit the method epilogue
                EndGenerate();
            }
        }