public override LLVMValueRef Emit(EmittingContext pContext) { //Emit types. Need to do it in order of dependencies so all types resolve foreach (var i in Structs.OrderBy((pS) => pS.EmitOrder)) { i.Emit(pContext); } //Emit type methods headers for (int i = 0; i < Structs.Count; i++) { Structs[i].EmitMethodHeaders(pContext); } //Emit method Headers LLVMValueRef main = default; for (int i = 0; i < Methods.Count; i++) { var m = Methods[i].EmitHeader(pContext); if (Methods[i].Annotation.Value == Utils.KeyAnnotations.RunMethod) { main = m; } } //Emit type methods for (int i = 0; i < Structs.Count; i++) { Structs[i].EmitMethods(pContext); } //Emit method bodies for (int i = 0; i < Methods.Count; i++) { Methods[i].Emit(pContext); } pContext.FinishDebug(); return(main); }