LangcraftisacodegeneratortargetingMinecraftDataPacks.Itcancurrentlyrunafairlysubstantialsetofbitcodefileswithoutissue.Theprojecthasabuilt-incommandinterpreterfordebuggingthatsupportsbreakpoints(ish)andinspectingregister/memoryvalues.AllgenerateddatapackscanberuninarealMinecraftJavaEdition1.16+worldinunder5minutes.
Usagecargorun----arg1--arg2./path/to/llvm/bitcode.bcValidargumentsare:
--help:Displayusageandavailableoptions--out=path/to/dir/:Specifythedirectorythedatapackfilesshouldbeplacedin(defaultis./out)--run:Runthecommandinterpreteronthegeneratedcode--trace-bbs:InsertaprintcommandatthebeginningofeachLLVMbasicblockTousethegenerateddatapackinMinecraft:
Copytheentireoutputfolder(./outbydefault)tothedatapacks/directoryofaMinecraftworld(usingasuperflatvoidworldisrecommended)Run/functionsetup:setup.ThisonlyhastobedonethefirsttimeaLangcraftdatapackisusedinaworld.Run/functionrust:runIfthedatapackismodifiedwhiletheworldisopen,run/reloadandthengobacktostep3.Rustcodemustbebuiltasfollows:
Releasemodepanic=abort#![no_std]#![no_main]Haveamainfunctionwith#[no_mangle]Usei686-unknown-linuxrust_interpisaRustprojectalreadyconfiguredtogeneratetheproperbitcode.Theinterpreterbinarytargetasshowninthedemocanbebuiltwith:
shcompile_rust.shAndthefiletousewillbe:
rust_interp/target/i686-unknown-linux-gnu/release/deps/interpreter-SOMEHEXSTRING.bc
AnyotherlanguagecapableofgeneratingLLVMbitcodecanbeused,aslongasitcanbebuiltforabare-metal32-bittarget.Foraclangexampleseecompile_c.sh.
NotethatthelatestnightlyversionsofrustcnowuseLLVM11,whichLangcraftcannotparse(yet).Youcansetanearlierversiontouseforadirectorywith:
rustupoverridesetnightly-2020-08-23DemoAvideoofaLangcraft-compiledinterpretercanbeseenhere.
LicenseLicensedundereitherof
MITLicenseApacheLicense,Version2.0
评论