Releases: cardillan/mindcode
Releases · cardillan/mindcode
3.5.2
3.5.1
3.5.0
3.5.0 - 2025-05-19
Fixed
- Fixed wrong
unsafe-case-switching
optimization for small jump tables (#253). - Fixed wrong handling of side effects by the Case Switching optimization (#254).
- Fixed incorrect IDs produced by the
sensor ... @id
instruction (#255). - Fixed unrecognized keywords for some instructions (#256).
- Fixed incorrect block type obtained through the
lookup
instruction in compile-time evaluation and the processor emulator for zero logic ID.
Added
- Added support for the new
op sign
,op round
andunpackcolor
Mindustry BE instructions to the compiler and processor emulator. - Added the
output-profiling
compiler option, which causes the profiling output (number of times each instruction was executed) to be written to the log file.
Experimental
- Added support for using
null
literals in case expression. When used in case expressions involving Mindustry content,null
values in thewhen
clauses are supported by the Case Switching optimization too.
Changed
- Breaking: The system library was changed to accommodate the new logic instructions:
- The
sign
function in themath
library was renamed tosignInexact
. - The
signExact
function in themath
library was renamed tosign
. This function corresponds to the Mindustry 8 instructionop sign
, and when target 8 is selected, the instruction is used instead of the library implementation. - The order of parameters of the
unpackcolor
function in thegraphics
library was changed to match theunpackcolor
instruction in Mindustry 8. When target 8 is selected, the instruction is used instead of the library implementation.
- The
- When splitting jump tables into multiple segments during jump table compression, the instruction jumping to the next segment is always placed first, to make the overall execution of the optimized case expression faster.
- Other improvements to the Case Switching optimization: better optimization, more precise cost and benefit calculation, support for
null
values.
Miscellaneous
- Mindustry Logic built-in functions take precedence over functions defined in system library. This allows system libraries to contain functions that can be used when a corresponding Mindustry Logic function doesn't exist in current target.
- List of supported keywords and built-in variables for instruction parameters are now provided by mimex-generated metadata.
- Added list of accepted built-in variables to the description of functions in the function reference.
- The docker definition was updated to avoid unnecessary recompilations (courtesy of 3bd).
- Updated BE metadata to the latest available BE build.
- Added new metadata types, fixed zero logic IDs problem.
Assets
(Note: the above link was misconfigured and led to the 3.4.0 version of the compiler. It's fixed now. I'll stop putting the links here, I need to update them manually and when I forget, it only creates confusion.)
3.4.0
3.4.0 - 2025-05-11
Fixed
- Removed unnecessary condition duplication for empty loops (#252).
Added
- Added new functions to the
graphics
library:- Added
setAlpha()
function which takes a packed color as an argument (including e.g. named color literals) and returns a packed color with updated alpha channel. - Added
packHsv()
function which creates a packed color value out ofhue
,saturation
,value
andalpha
components.
- Added
- Expanded the Case Switching optimization:
- Range checking of the input values may be suppressed using
unsafe-case-optimization
compiler directive. - Case expressions based on Mindustry content (e.g. items, block types and so on) can be optimized by converting the values to logic ids and building jump tables using these numerical values.
- Large jump tables containing a lot of unused values may be split into two or more segments to save space.
- Range checking of the input values may be suppressed using
Experimental features
- Added module signatures to the remote call mechanism prevent binding to an incompatible remote module.
- Added support for using the same module in multiple remote processors.
- Added an optional output parameter to the
finished()
function, which receives the resulting value of the remote function call if it is already finished.
Changed
- Breaking: changed the command-line arguments of the offline compiler:
- The
-o
command-line option no longer sets the optimization level, but specifies the name of the output file. - The output file needs to be specified using the
-o
or--output
named argument. - There's a new
-O
option taking a numerical value (optimization level). Values0
to3
correspond to optimization levelsnone
,basic
,advanced
andexperimental
.
- The
- Breaking: the remote call mechanism was redesigned. When recompiling code in a processor which utilizes remote calls, all related processors need to be recompiled too.
- The mlog decompiler replaces illegal characters in mlog variable names with underscores. If names of some variables collide due to these conversions, a numeric index is appended to some of them until a unique name is found.
Miscellaneous
- Added an instruction index to the function reference.
- Added list of possible keywords to the description of functions in the function reference.
- Added references to the relevant portion of Yruei's documentation to function reference.
Assets
3.3.3
3.3.3 - 2025-04-26
Fixed
- Fixed internal error when compiling unused functions (#247).
- Fixed whitelabel error in the web application when an internal compilation error occurs. The error is reported as a standard error message instead.
Assets
3.3.2
3.3.2 - 2025-04-26
Added
- Support for dark mode in the web application (courtesy of 3bd). Light/dark mode follows the browser preference.
- Support for named color literals (e.g.
%[red]
) in target 8.
Changed
- Hexadecimal and binary literals can be specified as 64-bit unsigned numbers (e.g.
0xFFFFFFFFFFFFFFFF
represents-1
). These literals are encoded to mlog as is when possible. If the literal wouldn't be properly parsed by the target Mindustry version, it is encoded as a signed decimal literal. - Negative hexadecimal and binary literals are encoded to mlog as is (with possible conversion to lower case). If the literal wouldn't be properly parsed by the target Mindustry version, it is encoded as a signed decimal literal.
Miscellaneous
- Fixed (hopefully) Discord links in the Readme.
Assets
3.3.1
3.3.1 - 2025-04-16
Fixed
- Fixed the logic id translation from blocks to ids and back not handling all types of blocks (#246).
- Fixed small bug in jump tables generation for unused arrays.
Added
- A document offering some tips on writing a better performing Mindcode.
Changed
- Improved list iteration loops generation for symbolic labels to perform the same as a code compiled without symbolic labels.
- Small improvements in chained random array access optimizations.
Miscellaneous
- Updated BE metadata to the last available BE build.
Assets
3.3.0
3.3.0 - 2025-04-11
Fixed
- Fixed some command-line options not having an effect in the command-line tool (#231).
- Fixed wrong handling or hoisted set instruction setting up return address in subsequent loop unrolling (#234).
- Fixed optimizations removing the
spawn
instruction when the output value was not used (#236). - Fixed Jump Optimization not performing the optimization in unrolled loops.
- Fixed error in compile-time evaluation of an expression involving a character literal (#240).
- Fixed incorrect compile-time evaluation of some logic IDs (#242).
- Fixed possible incorrect handling of arguments passed to the
print()
and other output functions (#243).
Added
- Breaking: new
ref
keyword was added to the language. Code that uses this keyword as a function or variable name will not compile and the variable or function will have to be renamed. - Added the
char()
function. The function returns the ASCII value of a character at given index from a string value using theread
instruction, as supported in latest BE version. - Added support for invoking properties and the
sensor
functions on string values to support latest BE Enhancement of sensing string lengths using@size
. - Added the
strlen()
function returning the length of a string determined at runtime. - Added support for compile-time evaluation of the
length()
function, allowing to specify offsets relative to the end of the array in subarrays (e.g.array[0 ... length(array) - 1]
). - Added compile-time evaluation of either stable, or all built-in numerical variables (such as
@pi
or@unitCount
). - Added a new remarks mode,
comments
, to compile remarks as mlog comments (# comment
). - Added support for generating runtime boundary checks for explicitly declared external arrays.
- Added new
printLines()
function to theprinting
library. The function prints each of its arguments on a new line. - Loop Hoisting optimizer enhanced with an ability to optimize instructions setting up return addresses of function calls.
- Added handling of numerical literal values unsupported by Mindustry Logic version 7 and earlier (namely,
-2147483648
).
When a numerical literal or constant expression has this value, a compile-time error is generated. - Added support for strings in
read
andsensor
instructions to processor emulator. - Added a new
--file-references
command-line option. - Added a suggestion of the closest matching alternative when an unknown compiler directive or option value is found.
- Added support for mlog syntax highlighting into the provided IntelliJ file type settings.
Experimental features
- Added support for passing arguments to inline functions by reference. It is possible to pass variables and arrays this way.
- Added new
target-optimization
compiler directive/command line option. Thespecific
option generates code for the specific compilation target only, thecompatible
option generates code intended for the compilation target and future versions of Mindustry Logic. - Added array-specific optimizations for speed (available on
experimental
level). - Added new
arrays
system library with some basic array functions. The size calculations for the library functions are possibly incorrect, as new means for determining code size of functions taking an array as a ref argument needs to be developed. - Added support for generating symbolic labels instead of instruction addresses in jump instructions, through the
symbolic-labels
compiler directive/command line option. - Added support for applying indenting to the generated mlog code based through the
mlog-indent
compiler directive/command line option.
Changed
- Breaking: underscores in multi-word command-line options were changed to hyphens.
- The metadata used by Mindcode compiler and processor emulator now correspond to the compilation target. Schemacode still uses the latest version of the metadata for both building and decompiling schematics.
- Compile-time evaluation cache is cleared when exiting function context. This forces primarily the
length()
function to be reevaluated in each call to an inline function, as its value depends on the actual arguments passed to the function. - Improved optimization of jumps by making multiple passes over jumps-related optimizers, up to the optimization passes limit.
- Volatile built-in variables used an upper or lower bound in a ranged for-loop statement are used directly in the condition, without storing them in a temporary variable.
- Stripped unnecessary
.0
distinctions from local variable prefix. - The
noinit
modifier is no longer disallowed for local variables. - The processor emulator uses numerical values provided by metadata for built-in variables (such as
@pi
or@unitCount
). The metadata version corresponds to the compilation target.
Assets
3.2.1
3.2.1 - 2025-03-23
Fixed
- Fixed errors when trying to invoke properties on internal array elements (#228).
- Fixed wrong optimization of list iteration loops (#229).
- Fixed incorrect optimization of
if
expressions (#230).
Added
- Added a warning when a variable declared volatile is not used anywhere in a program, which would preclude remote access to such a variable.
Changed
- Enhanced Temporary Variables Elimination to remove superfluous temporary variables generated by the compiler for volatile variables.
- Updated Dead Code Elimination to not remove dead writes to volatile variables.
Assets
3.2.0
3.2.0 - 2025-03-16
Fixed
- Fixed the Start with a new schematic button causing HTTP 404.
- Fixed the schematics decompiler incorrectly processing factories with no unit plan selected.
- Fixed wrong values of
@blockCount
,@unitCount
,@itemCount
and@liquidCount
variables in processor emulator (currently assigned values correspond to Mindustry Logic 8 regardless of the compiler target).
Added
- Added mlog keywords as a preferred way to specify mlog keywords to Mindustry Logic functions.
- Added support for passing mlog keywords and formattable string literals as arguments to inline functions.
- Added support for creating constants out of mlog keywords.
- Added known mlog keywords to the file type definitions of the provided Intellij IDEA IDE settings.
- Added new
mlogText()
function for direct encoding of mlog instructions. - Added support for descending iteration order to Range Iteration Loops and List Iteration Loops (#174).
- The description of the storage clause added in Mindcode 3.1 was added to the documentation.
- Added a new Item Transport sample. The sample demonstrates the use of a simple remote call scheme for acquiring units.
Experimental features
- Added support for remote functions and variables (#218).
Changed
- Breaking: new keywords were added to the language:
descending
,module
andremote
. 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. - All reads from and writes to variables declared
volatile
are preserved now. Volatile variables can be accessed from a remote processor safely. - Prefixes for local variables are created from function name by default. Use function-prefix option or command-line argument to generate shorter prefixes.
- Changed the
sort-variables
option to usedraw triangle
instructions to create variables in a defined order.
Deprecated
- Deprecated the
loop
keyword indo while
loop. - Deprecated specifying mlog keywords without the
:
prefix in Mindustry Logic function calls.