public void TestIL() { var module = new ModuleBuilder("xuy"); var clazz = module.DefineClass("svack_pidars", "wave/lang"); clazz.SetFlags(ClassFlags.Public | ClassFlags.Static); var method = clazz.DefineMethod("insert_dick_into_svack", ("x", WaveTypeCode.TYPE_STRING)); method.SetFlags(MethodFlags.Public | MethodFlags.Static); var body = method.GetGenerator(); body.Emit(OpCodes.LDC_I4_S, 1448); body.Emit(OpCodes.LDC_I4_S, 228); body.Emit(OpCodes.ADD); body.Emit(OpCodes.LDC_I4_S, 2); body.Emit(OpCodes.XOR); body.Emit(OpCodes.DUMP_0); body.Emit(OpCodes.LDF, "x"); body.Emit(OpCodes.RET); var body_module = module.BakeByteArray(); var asm = new WaveAssembly(); asm.AddSegment((".code", body_module)); WaveAssembly.WriteToFile(asm, @"C:\Users\ls-mi\Desktop\wave.dll"); }
public void ElfReadManul() { var file = @"C:\Users\ls-mi\Desktop\wave.elf"; var asm = new WaveAssembly { Name = "wave_test" }; asm.AddSegment((".code", Encoding.ASCII.GetBytes("IL_CODE"))); WaveAssembly.WriteToFile(asm, file); var result = WaveAssembly.LoadFromFile(file); }
public void ElfReadTest() { var file = GetTempFile(); var asm = new WaveAssembly { Name = "wave_test" }; asm.AddSegment((".code", Encoding.ASCII.GetBytes("IL_CODE"))); WaveAssembly.WriteToFile(asm, file); var result = WaveAssembly.LoadFromFile(file); var(_, body) = result.sections[0]; Assert.Equal("IL_CODE", Encoding.ASCII.GetString(body)); File.Delete(file); }