public static void WriteMethodBody(CodeTextWriter Writer, MethodDefinition Method, bool ValueType) { MethodTranslateContextCXX methodContext = new MethodTranslateContextCXX(Method); Writer.WriteLine("{"); Writer.indent(); Writer.WriteLine("// [S2000] Method Body"); if (Method.IsConstructor && Method.IsStatic) { Writer.WriteLine("// [S2000-2] Static Constructor Body"); Writer.WriteLine("static std::once_flag flag;"); Writer.WriteLine("std::call_once(flag,[&]()"); Writer.WriteLine("{"); Writer.indent(); } if (Method.Body.HasVariables) { Writer.WriteLine("// [S2000-0] Local Varaiables"); foreach (var localVar in Method.Body.Variables) { if (Method.Body.InitLocals) { Writer.WriteLine($"{localVar.CXXVarDeclaration()} v{localVar.Index} = {localVar.CXXVarInitVal()};"); } else { Writer.WriteLine($"{localVar.CXXVarDeclaration()} v{localVar.Index};"); } } } Writer.WriteLine("// [S2000-1] Code Body"); foreach (var instruction in Method.Body.Instructions) { IterateILInstruction(instruction, methodContext); } foreach (var sr in methodContext.StaticReference) { var constructor = sr.GetStaticConstructor(); if (constructor == null) { continue; } Writer.WriteLine($"{constructor.CXXMethodCallName(sr)}();"); } foreach (var instruction in Method.Body.Instructions) { Writer.WriteLine(NoteILInstruction(instruction, methodContext)); var Lable = instruction.GetLabel(); if (methodContext.LableReference.Contains(Lable)) { Writer.WriteLineRaw(Lable + " :"); } Writer.WriteLine(TranslateILInstruction(instruction, methodContext)); } if (Method.IsConstructor && Method.IsStatic) { Writer.unindent(); Writer.WriteLine("});"); Writer.WriteLine("// [S2000-2] Static Constructor Body End"); } Writer.unindent(); Writer.WriteLine("}"); }