/// <summary> /// Initializes a new instance of <see cref="BaseCodeEmitter" />. /// </summary> /// <param name="methodName">Name of the method.</param> /// <param name="linker">The linker.</param> /// <param name="codeStream">The stream the machine code is written to.</param> public void Initialize(string methodName, MosaLinker linker, Stream codeStream) { Debug.Assert(codeStream != null); Debug.Assert(linker != null); MethodName = methodName; Linker = linker; CodeStream = codeStream; Labels = new Dictionary <int, int>(); OpcodeEncoder = new OpcodeEncoder(this); }
/// <summary> /// Initializes a new instance of <see cref="BaseCodeEmitter" />. /// </summary> /// <param name="methodName">Name of the method.</param> /// <param name="linker">The linker.</param> /// <param name="codeStream">The stream the machine code is written to.</param> public void Initialize(string methodName, Linker.MosaLinker linker, Stream codeStream) { Debug.Assert(codeStream != null); Debug.Assert(linker != null); MethodName = methodName; Linker = linker; CodeStream = codeStream; // only necessary if method is being recompiled (due to inline optimization, for example) var symbol = linker.GetSymbol(MethodName); symbol.RemovePatches(); Labels = new Dictionary <int, int>(); OpcodeEncoder = new OpcodeEncoder(this); }