Releases: cardillan/mindcode
3.13.0
3.13.0 – 2026-01-18
Note
The atomic code blocks are only guaranteed to execute correctly in the latest BE version (build 26609 or higher). The latest beta release (v154.3) doesn't provide necessary support for atomic code blocks.
Fixed
- Fixed incorrect emulation of the instruction accumulator for targets 6 and 7 affecting instruction scheduling.
Added
- Added new
@maxUnitssensable property. - Added an atomic code block: a block of code guaranteed to be executed atomically (without interruption), meaning that other processors or game updates do not change the world state.
- Added the
setrateandiptcompiler options. These options specify the rate at which a world processor executes instructions (used by the compiler when building atomic blocks). - Added the
volatile-atomiccompiler option governing the way atomic blocks are created. - Added the
processor-id,program-nameandprogram-versioncompiler options. These options take string values, which are then encoded into a*idvariable and can be used to identify the processor in the schematics. - Added the
emulator-fpscompiler options to specify the frame rate to be emulated by the processor emulator. While frames are always emulated fully by Mindcode emulator, the change in instruction scheduling caused by different frame rate only affects situations where an interaction between two or more processors is being emulated. - Added the ability to run the compiled schematics on the schematics emulator to the tool app.
- Added support for sensing
@xand@yin blocks when emulating schematics. - Added the
encode-zero-characterscompiler option, which allows encoding zero characters in string literals. Use with caution: resulting code cannot be edited or passed via clipboard. Option has no effect in the web app.
Changed
- Runtime errors generated when running the code in the processor emulator no longer prevent outputting the compiled code in the tool app.
- Changed the format of the
targetcompiler option. Instead of a processor edition (standard or world), a particular processor type is now specified, using the first letter of the type name (i.e.,mfor micro-,lfor logic-,hfor hyper-, andwfor world-processor, case-insensitive), for example,#set target = 8L;. - When compiling Mindcode for a processor in a schematic, the target type of the processor is determined by the block type in the schematic.
- Compiler-defined constants now follow the
@@VARIABLEpattern, instead of earlier__VARIABLE__(for example,@@MINDUSTRY_VERSION). - Changed the emulator handling of the
waitinstruction with zero argument to match the latest Mindustry BE behavior.
Miscellaneous
- The system of compiler options has been updated to allow determining whether a given option has been set. This allows the default values of unset options to be derived from the values of other options.
- The transfer variable, defined for uncached external and remote variables, is no longer used for reads. Instead, a fresh new temporary variable is used each time. This may increase the number of temporary variables generated but avoids unnecessary instructions when using postfix operators on these variables. This became quite important with atomic blocks.
3.12.1
3.12.0
3.12.0 - 2026-01-11
Fixed
- Fixed incorrect evaluation of some numeric mlog constants (#295).
- Fixed the Mandelbrot schematic sample not rendering after build.
Changed
- The Loop Rotation optimization has been updated:
- Full loop rotation is performed even for conditions which contain complex code (such as nested loops or function calls).
- A full loop rotation is also considered alongside a partial rotation if it could be beneficial to Loop Hoisting.
- The Loop Hoisting optimization has been extended:
- The optimizer gathers information to support the Loop Rotation optimization.
- When a loop is fully rotated, an instruction can be hoisted in such a way that it's executed at most once, but only if the loop actually runs.
- When a loop is not known to execute at least once, an instruction affecting just the loop can still get hoisted entirely out of the loop if the loop is nested.
- The mlog processor emulator has been completely rewritten. The emulator now matches the behavior if a Mindustry processor of the version identified by the
target(oremulator-targetcompiler options. - The execution flags have been updated to match the new processor emulator. Some flags have been removed, some have been added, and some have been renamed.
- The processor emulator is now able to execute supported instructions even when created using an
mlog()fuction or an mlog block. This includes the code generated by thecompatibilitylibrary.
3.11.0
3.11.0 - 2025-12-25
Note: the new features in this release bring about changes to the best practices for writing Mindcode.
Fixed
- Some
selectoptimizations were not applied when optimizing for size. As a result, code optimized for size might end up larger than code optimized for speed. - Some
selectoptimizations may have been incorrect. Due to the previous bug, the probability of them being applied was low (#290). - Fixed the wrong optimization of volatile variables in If Expression Optimization (#291).
- Fixed instructions being hoisted in front of the loop even when the loop is not guaranteed to run (#293).
- Fixed loop-dependent instructions being possibly hoisted in front of the loop (#294).
Added
- Breaking: new keywords have been added to the language:
publicandprivateand are reserved for future use. Code that uses any of these keywords as a function or variable name will not compile, and the variable or function will have to be renamed. - Added the
no-argument-paddingcompiler option. When activated, instructions are not padded to the maximum number of arguments. - Added the
authorcompiler option. The option adds an entry to the list of authors, which is then displayed alongside the usual compiler signature. - Added support for new instruction opcode (
ucontrol deconstruct). - Added a binary
inoperator for testing whether a value is contained in a given range or a list of values.
Changed
- Breaking: The
andandoroperators now perform short-circuit evaluation. - The Jump Optimization has been renamed to Condition Optimization, and has been significantly extended:
- Condition streamlining is now applied to the
selectandorinstructions as well as tojump. - The optimization is applied to all variables, not just temporary ones. The results of the DFO analysis are used to track user-defined variables.
- On
advancedlevel, constant folding of conditional expressions is now also performed.
- Condition streamlining is now applied to the
- Breaking: The
jump-optimizationcommand-line option and compiler directive has been renamed tocondition-optimization. - The Loop Optimization has been renamed to Loop Rotation, and has been extended to support short-circuit conditions. Full and partial loop rotations are now supported.
- Breaking: The
loop-optimizationcommand-line option and compiler directive has been renamed toloop-rotation. - The Boolean Optimization, previously included in the If Expression Optimization as a Select Optimization, has been extracted into a separate optimization class and enhanced:
- Several optimizations aimed at short-circuited conditional expressions were added.
- Where possible, an
opinstruction is used instead ofselect. This allows applying some optimizations even when the compilation target doesn't supportselect.
- The Expression Optimization has been updated:
- More cases where a
selectinstruction can be replaced with asetinstruction are now supported. - When the resulting values of
selectare0and1and the condition allows it, the instruction is replaced with anopinstruction. - The instruction normalizing the result of an
||operator to0or1is removed when not needed. - Added an optimization turning a
readinstruction with a constant string and a constant index into asetinstruction setting the character value directly.
- More cases where a
- When evaluating
jumpandselectconditions during optimizations, cases where the operands of the condition are identical (the same variable) are handled. - The
compatibilitysystem library now also performs a test to find out whether assigningnullto@counteris ignored by the processor. - The mimex metadata have been updated to match the current BE version. The most significant change is a new set of sound constants.
- The documentation has been restructured. Individual optimizers are described in separate files, and the description of Logic functions with links to the Function reference was also moved to a separate file.
Miscellaneous
- A new optimization, Instruction Reordering, is being developed. The corresponding compiler directive is already present, but the optimization, even when explicitly enabled, is not yet functional.
- All experimental features are now considered standard. The default optimization level is now advanced. Going forward, only features controllable via compiler options will be marked experimental, and the default optimization level will be
advanced. Note that Mindcode is a live system and features may be modified to support new functionalities. A reasonable effort will be spent to ensure smooth conversion or backwards compatibility, but all features, both well-established and relatively recent, can be changed or removed in a new release.
3.10.0
3.10.0 - 2025-11-17
Fixed
- Fixed an error in the Single Step Elimination optimization causing some superfluous jumps not being removed.
Added
- A new fast dispatch optimization is available for case expressions. Fast dispatch uses just a single instruction to transfer the control to the desired branch of a case expression, including the
elsebranch. - A new value translation optimization, which reads values encoded into a text string using the
readinstruction, may be applied on case expressions (#289). - Added the
use-text-translationscompiler option to allow/disallow using encoding values into a text string for the above optimization.
Changed
- Breaking: the
text-tablescompiler option has been renamed (yet again - sorry) touse-text-jump-tables. - The Case Switcher optimization was updated to fully support
nullvalues inwhenbranches (even in integer expressions). - The Extended testing tool now accepts values for any compiler directive in the settings file.
3.9.0
3.9.0 - 2025-10-27
Fixed
- Fixed error on the Schematic Decompiler page (#288).
- Fixed the compiler not rejecting integer and double compiler option values outside their allowed range.
- Fixed the compiler not stopping the compilation when an error in compiler directive gets detected.
- Fixed rare internal error in Jump Threading optimization.
- Fixed broken reporting of source file positions when compiling Mindcode within a schematic.
Added
- Breaking: new keywords have been added to the language:
debugandexport. Code that uses any of these keywords as a function or variable name will not compile, and the variable or function will have to be renamed. - Added support for implementing the
!==operator using aselect stricEqualinstruction in target8. - Added the
emulate-strict-not-equalcompiler option to allow/disallow usingselectinstead ofjump strictNotEqual. - Added new internal array implementations using new Mindustry 8 logic capabilities:
- Added support for using text-based table dispatch in array implementations.
- Added the
use-lookup-arraysanduse-short-arraysoptions. - Added warnings when a name specified by the
mlogmodifier collides with another user-defined variable or array element in the current processor. - Added the ability to output the final code size broken down by function and an accompanying
print-code-sizeoptions. - Added the
error()function, which can be used to report errors detected at runtime. - Added the
debugcompiler option for compiling code with debug support. - Added debug code blocks. Compiled only when
debugis set to true. - Added debug functions. Calls to debug functions are ignored unless
debugis set to true. - Added target selection to the Mindcode Compiler and Schematics Builder pages in the web app.
Changed
- Breaking: change to options governing runtime check generation:
- the
error-reportingoption now specifies the mechanism to be used by the compiler to report runtime errors. When set tonone, no runtime checks occur, regardless of other settings. This was previously governed by theboundary-checksoption. - the
boundary-checksoption now takes a value oftrueorfalse, activating/deactivating boundary checks on array accesses. - the
error-functionoption takes a value oftrueorfalse. Whentrue, the error is reported using the mechanism specified byerror-reporting; when false, theerror()` function has no effect.
- the
- Breaking: specifying the mlog name of a variable using the
remotemodifier is no longer supported. Theremotemodifier now takes only the name of the remote processor as a parameter, enclosed in parentheses. Use themlogmodifier to specify the mlog name of the remote variable. - The
mlogvariable name must not match a linked block name. - The
mlogmodifier accepts multiple expressions, allowing to specify names for individual array elements. - The
mlogmodifier also accepts one of the lookup keywords (:block,:unit,:item,:liquidor:team) in array declarations, allowing to specify the lookup type used by the array. - The
cachedandnoinit cachedmodifiers can be used with variables declaredremote, with the same effect as in case of variables declaredexternal. - Warnings are no longer issued for unused volatile variables. It is assumed that an unused volatile variable will be accessed indirectly.
- Changed the default value of the
mlog-block-optimizationfromfalsetotrue.
Deprecated
- Using the
remotemodifier to mark functions and variables to be accessible remotely is deprecated. Use theexportkeyword instead. - Using parameters with the
externalorremotemodifiers without parentheses is deprecated.
Removed
- The
loopkeyword, deprecated earlier and optional in thedo whileloop syntax, has been removed. - The optimization level setting was removed from the user interface on the web page.
3.8.0
3.8.0 - 2025-09-25
Fixed
- Circular module dependencies get correctly identified and reported (#226).
- Fixed a possible internal compiler error when performing the Temp Variable Elimination optimization.
Added
- Added support for local compiler options.
- Added the
weightcompiler option.
Changed
- Breaking: files included via the
requiredirective or via the-acommand-ine argument must contain amoduledeclaration. - Breaking: modules must be compiled using the
strictsyntax mode. Thestrictmode is the default for any source file containing amoduledeclaration, regardless of whether the module contains remote functionality or not. - Breaking: the
text-jump-tablescompiler option has been renamed totext-tables.
Miscellaneous
- Reorganized the Compiler options documentation.
- Split the System library documentation into separate files.
- Updated the code size calculations for the System library documentation. The array jump tables are no longer included in the calculations.
- Added a section on Variable-based lookups and the
encode()function to the Performance tips documentation.
3.8.0 beta 5
3.8.0-beta.5 - 2025-09-07
Note: this is a beta release. It's been released to provide bugfixes and new enhancements to Mindcode and Schemacode.
The newly added features are fully functional. There's an unfinished support for the #setlocal directive. It doesn't have any effect at this time.
Fixed
- Fixed Jump Threading optimization causing an internal error (#283).
- Fixed Compiler error unrolling an unreachable loop (#285).
Added
- Added support for calling remote functions locally.
- Added support for evaluating the
@nameproperty of all objects (not just objects with a logic ID) to compile-time evaluator. The@nameproperty is always compile-time evaluated when possible, regardless of thebuiltin-evaluationoption. - Added support for evaluating the
@nameproperty to the Expression Optimization. The@nameproperty is always compile-time evaluated when possible, regardless of thebuiltin-evaluationoption. - Added new
filenameattribute to schematic definition, allowing to specify the name of the output file to use for the generated schematic. - Breaking added new
targetattribute to schematic definition, allowing to specify the target version for the schematic. This might break existing schematics, as previously schematics were compiled using the latest metadata version only. - Added support for a content map in schematics, both when reading and when writing them. The content map is included in all schematic files, regardless of target (older Mindustry versions which do not support a content map will ignore them when reading schematics).
- Added the
--output-directorycommand-line option; if the output directory isn't specified as part of an explicit output file designation, the file will be placed in the output directory.
Changed
- Breaking: mlog variable name specified using the
mlogandremotespecifier must be enclosed in parentheses. Any constant string expression is supported.
Miscellaneous
- Separated the mimex data into a standalone repository, which is now included as a git submodule at
compiler/src/main/resources/mimex. - Updated the BE version metadata to the latest available BE build.
3.8.0 beta 4
3.8.0-beta.4 - 2025-07-28
Note: this is a beta release. It's been released primarily to support the newest Mindustry Logic instructions (select), and as a preview of the newest optimization features (namely, text-based jump tables).
The newly added features are fully functional. There's an unfinished support for the #setlocal directive. It doesn't have any effect at this time.
Fixed
- Fixed a possible internal compiler error when using the Temp Variable Elimination and the select optimization.
Added
- Added a new
encode()function for easier encoding of data into strings. - Added support for using user-defined functions in constant expressions.
Changed
- Breaking: remote functions and variables/arrays must always be specified with a fully qualified name (e.g.
processor1.xorprocessor2.foo()) when accessing or calling them from a main processor. - Removed restrictions on requiring the same source files from different modules.
- Remote variables are not reported as unused.
3.8.0 beta 3
3.8.0-beta.3 - 2025-07-24
Note: this is a beta release. It's been released primarily to support the newest Mindustry Logic instructions (select), and as a preview of the newest optimization features (namely, text-based jump tables).
The newly added features are fully functional. There's an unfinished support for the #setlocal directive. It doesn't have any effect at this time.
Fixed
- Fixed the Data Flow Optimization not optimizing global variables (#280).
- Fixed Loop Hoisting processing instructions that change variables already read by the loop (#282). Loop Hoisting can process global variables again.
- Fixed a bug in the
bubblesortfunction in thearrayssystem library.
Changed
- Changed the Jump Threading optimization to redirect jumps to a function call directly to the function. The optimization may currently only take place when
symbolic-labelsis set tofalse. - Improved the
selectoptimization in the If Expression Optimization to handle more cases as well as nested or chained conditional expressions.