Releases: cardillan/mindcode
Releases · cardillan/mindcode
3.1.0
3.1.0 - 2025-02-20
Fixed
- Fixed some syntax errors reported at wrong places (#214).
- Fixed wrong block/unit logic IDs (#224).
- Fixed error decompiling schematics with Air Factory (#225).
Added
- Added support for internal and external arrays/subarrays (closes #213).
- Added parallel iteration through arrays/lists in list iteration loops.
- Added support for the new
printchar
instruction in compiler, optimizer and processor emulator. - Added character literals (e.g.
'A'
). The value of the literal is the ASCII value of the character in quotes. - Added the
ascii()
function. The function returns the ASCII value of the first character of a string literal or constant.
Experimental features
- Added the "backpropagation" optimization to Data Flow Optimization (closes #151).
- Added support for compiling in runtime checks for checking internal array elements are not accessed out of bounds. One of the methods uses the MlogAssertions mod, which is currently only available for Mindustry 7.
Changed
- The default optimization level in both the web application and command line compiler is now
experimental
.
Assets
3.0.0
3.0.0 - 2025-01-26
Fixed
- Fixed functions called using varargs potentially not recognized as used (#203).
- Fixed incorrect implementation of the strict equality operator (#206).
- Fixed wrong reference counting for inline functions (#207).
- Fixed compiler errors when placing enhanced comments into loops.
- Fixed wrong compile-time and emulator evaluation of
asin
,acos
andatan
functions (#209). - Fixed compile-time evaluation potentially processing functions not available in current target. The only affected target was 6, where non-existent functions
asin
,acos
,atan
andpackcolor
could be compile-time evaluated instead of reported as non-existent.
Added
- Added support for encoding results of compile-time expressions as color literals.
- Added capability to automatically add a
printflush message1
instruction at the end of the main program body if missing from program. - Added the
auto-printflush
compiler directive and--auto-printflush
command-line option to control the addition of theprintflush message1
instruction. - Added explanatory messages to the web app when compiling the source yields an empty program.
Changed
- More precise calculations of optimization benefits in loop unrolling and call inlining.
- The
sensor
instruction is considered deterministic if a deterministic property of a non-volatile value, which is not a linked variable, is being queried. - When clicking on an error or warning in the web application, the entire portion of the source code causing the error or warning is selected.
- Most advanced optimizations were moved to the
basic
level. Only optimizations that might be incorrect in some contexts (such as optimizations replacing computed IDs of Mindustry items with IDs known to the compiler) are left on the advanced level. - The default optimization level in the web application is now
advanced
.
Assets
3.0.0 Preview 1
This is a pre-release for Mindcode 3.0. The webapp can be found here: https://mindcode3-55e3aab18846.herokuapp.com/
3.0.0-preview1 - 2025-01-17
Fixed
- Fixed errors when compiling empty bodies of functions and statements (#99).
- Fixed errors when compiling unary plus and minus operators (#175).
- Fixed execution errors not being displayed in the web application (#185).
printflush()
anddrawflush()
didn't compile when called as methods on blocks (#190).- Fixed Single Step Elimination mistakenly removing some conditional jump (#199).
- Fixed inaccurate precision loss handling (#202).
- Fixed Data Flow Optimization crashing on return statement containing conditional expressions (#205).
- Fixed the Web Application not working inside the Docker container.
Added
- Added support for embedding expression in formattable String literals (e.g.
println($"Items: ${localItems + computeRemoteItems()}.")
). - Added support for color literals in the form of
%rrggbb
or%rrggbbaa
, e.g.%ff0000
is bright red.- The
packcolor()
function taking constant arguments is evaluated at compile time or during optimization. - Processor emulator supports color literals.
- The
- Added increment/decrement operators (
++
and--
) in both prefix and postfix form (e.g.i++
,--total
). - Added support for code blocks (delimited by
begin
andend
). - Added mechanism for invoking properties on expressions (#92).
- Added support for using external variables and properties wherever "normal" variables can be used (e.g. as output arguments to function calls).
- Added ability to report errors and warnings in unused functions.
- Added several new library functions
graphics
library:- Added
drawflush()
function which empties the draw buffer - Added
unpackcolor()
function which decomposes a packed color into individual r/g/b/a components.
- Added
printing
library:- Added
printflush()
function which empties the text buffer - Added functions for outputting numbers in binary and hexadecimal base:
formatBinaryNumber()
,printBinaryNumber()
,formatHexNumber()
,printHexNumber()
.
- Added
math
library:- Added
boolean()
function which converts a number to a boolean value (0
ifnull
or zero,1
otherwise) - Added
integer()
function which converts a number to an integer by truncating the fractional part - Added
log2()
function returning a base 2 logarithm of a number - Added
lerp()
function for linear interpolation between two values
- Added
- Added new
--excerpt
command-line option, allowing to specify only a part of the input file to be compiled.
Experimental features
- Added support for explicit variable declarations.
- Newly defined
relaxed
,mixed
andstrict
syntax modes.
Changed
- Breaking: new keywords were added to the language:
begin
,cached
,external
,linked
,noinit
,var
andvolatile
. 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. - Breaking: statements and declaration no longer provide any value and using them where an expression providing a value is expected causes compilation errors. In the past even statements and declarations were considered expressions, albeit they always evaluated to
null
. - Removed
sensor
from the list of keywords. - The
loop
keyword indo loop while
loops is optional. The keyword will be deprecated and eventually dropped. - Special types of variables (external variables and properties) can be used in the same way as normal variables, e.g. as function output arguments.
- When enhanced comments are used on a line which contains a beginning of a new statement or expression, the output generated by the enhanced comment precedes the first such statement/expression (#185).
- Better reporting of errors and warnings produced during compilation.
- Changed the mechanism of mlog variable names generation.
- Optimization of bitwise and boolean expressions which are incorrect for non-integers are only performed on
advanced
level. - Any compile-time constant expression can be used as a value for a program parameter.
Assets
2.7.4
2.7.3
2.7.3 - 2024-12-28
Fixed
- Fixed If Expression optimization wrongly applying forward assignment to some instructions. This particular optimization was also moved to the
advanced
optimization level. (#193).
Assets
2.7.2
2.7.2 - 2024-12-27
Fixed
- Fixed wrong compile-time evaluation of trigonometric functions (radians were assumed instead of degrees used by Mindustry - #192).
- Fixed the documentation stating that
do
in loops is optional (#191). - Fixed decompiler output missing the
#set target
directive (#188).
Changed
- Changed Mindcode to recognize new properties supported in Mindustry Version 8:
@currentAmmoType
,@armor
,@velocityX
,@velocityY
,@cameraX
,@cameraY
,@cameraWidth
,@cameraHeight
and@solid
(#187). - The decompiler now produces a function call syntax instead of method call syntax for
printflush
anddrawflush
instructions.
Assets
2.7.1
2.7.1 - 2024-12-07
Fixed
- Fixed Function Inlining optimization incorrectly processing functions with output parameters (#183).
Changed
- Changed the Print Merger optimization and processor emulator to correctly round numbers in print instructions in accordance with Mindustry Logic update)
Assets
2.7.0
2.7.0 - 2024-11-28
Fixed
- Fixed wrong Jump Threading optimization in out-of-line functions (#177).
- Fixed bugs in the Data Flow Optimization:
- The virtual
setaddr
instruction, unused due to the corresponding jump being unreachable, wouldn't be removed from code. This caused errors referencing a non-existent label. - Data Flow Optimization would sometimes corrupt the expected code structure when removing unneeded instructions, causing bugs or runtime errors during subsequent optimizations.
- The entry condition to a loop might be incorrectly evaluated, leading to wrong optimizations of some loops.
- A variable read in an unreachable part of code might be reported as uninitialized. This might lead to compilation error for compiler-generated uninitialized variables.
- The virtual
- Fixed the If Expression Optimization mistakenly propagating a jump into the bodies of the if/else statement, causing errors during subsequent optimizations.
- Fixed the Single Step Elimination occasionally crashing when removing a superfluous jump.
- Fixed the Loop Unrolling Optimization possibly unrolling incorrect number of iterations on loops with no exit condition.
- Fixed a bug in the implementation of the
median(x...)
function in themath
system library.
Added
- Added separate Testing Framework command-line tool. The tool allows compiling and running Mindcode source files under various optimization settings, helping to detect bugs in Mindcode.
Experimental features
- Added limited Unit testing support.
Changed
- Breaking: changed the default language target from ML7 to ML7A. The following functions are affected:
getBlock
: previously, the building at given coordinates was returned through an output parameter. In ML7A, the building is returned through function return value. SeegetBlock()
.ulocate
: previously, the function returned a boolean value (true
when the building was found,false
otherwise). In ML7A, the function returns a building (if found), and thefound
flag is returned through an output parameter. SeegetBlock()
.
- Changed automatic generation of Intellij IDEA settings files to only modify the zip files when the contents of the contained files changes.
- Changed Loop Unrolling Optimization to handle more cases of loop control variable modification on advanced level.
2.6.0
Breaking: This release comes with a new keyword in Mindcode syntax (require
), which break existing code where this keyword was used as a variable or function name.
Fixed
- Fixed the
findLinkedBlocks
library function not to produce a warning about uninitialized variables. - Fixed the mlog decompiler crashing on
jump
instructions targeting instructions outside valid range. - Fixed unhandled error when decompiling invalid code from mlog by the web application.
- Fixed
or
operator being evaluated the same as||
instead of|
by the processor emulator.
Added
- Added warnings for unrecognized built-in variables. An unrecognized built-in variable might be invalid or mistyped.
- Added the built-in math constants
@pi
,@e
,@degToRad
and@radToDeg
to the processor emulator. - Added automatic generation of Intellij IDEA settings files to keep them up-to-date with the language definition.
Experimental features
- Added a new
require
keyword for adding a system library or another external file (for command-line compilers) to the compiled code. - Added information about the compiled code size of individual functions to the system library documentation.
- Added new functions to the
printing
system library (printExactFast
andprintExactSlow
). - Added new functions to the
math
system library (round
,frac
,sign
,isZero
,isEqual
,nullToZero
,sum
,avg
,median
). - Added configurable execution flags governing the behavior of the processor emulator.
Changed
- Breaking: changed the system library to several separate files that can be included in the compiled code using the
require
keyword. The system libraries are no longer automatically loaded when compiling forML8A
target, and most of them can be used with earlier targets as well. - Changed rules for function overloading: a vararg function doesn't conflict with a non-vararg function. When a function call matches both a vararg function and a non-vararg function, the non-vararg function will be called.
- Changed all variables within system libraries to use the
_
prefix, to avoid possible clashes with constants and program parameters declared in the main file. - Changed existing examples to utilize functions from the system library where one is available.
- Changed processor emulator to output all existing variables and their values when encountering the
stop
instruction. - Changed the Jump Optimization to handle cases where the jump instruction contains a value produced by a function.
2.5.0
Breaking: This release comes with new keywords in Mindcode syntax (begin
, var
and void
), which break existing code where those new keywords were used as a variable or function name.
Fixed
- Fixed incorrectly processed case expression passed into functions (#107).
- Fixed arguments incorrectly passed to recursive calls (#169).
- Fixed output function parameters incorrectly accepting expressions as arguments (#170).
- Fixed error when allocating a stack using the ML8A target (#171).
- Fixed optimization not recognizing all interactions with Mindustry World (#172).
- Fixed wrong optimization of List iteration loops with output iterator variables (#173).
Added
- Added a new
void
keyword for declaring functions not returning any value. - Added a new
begin
andvar
keywords reserved for future use. - Added support for omitting optional arguments in the argument list.
- Added support for the special
@wait
argument of themessage()
function.
Experimental features
- Added output and input/output parameters of user defined functions.
- Added vararg (variable arity) functions.
- Added function overloading.
- Added the possibility to specify custom instructions not known to Mindcode through the
mlog()
function. - Added the
findLinkedBlocks
function to the system library.
Changed
- Changed the Loop Unrolling optimization to replace output iterator variables with the variable assigned to them.
- Changed the Single Step Eliminator to remove a jump is if there is an identical jump preceding it and there are no other jumps or labels between them. Active on
experimental
. - Changed the expression evaluator to evaluate operations over known built-in values. The change enhances the Data Flow and Jump Normalization optimizations.
- Changed the Schemacode compiler to correctly output positions of error messages generated by both the Schemacode and Mindcode compilers, taking into account both the source file and/or position of the Mindcode program or program snippet within the source file.
Deprecated
- Deprecated the syntax of properties omitting the
@
prefix for Mindustry built-in variables (e.g.vault1.coal
instead ofvault1.@coal
). - Deprecated the syntax of Mindustry Logic function calls not requiring the
out
modifier when passing in an output argument.
Miscellaneous
- Improved the command-line tool output of the Compile Schemacode action.