Releases: cardillan/mindcode
Releases · cardillan/mindcode
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.
2.4.0
Fixed
- Fixed Copy to clipboard button not working (#168).
- Fixed unhandled error when decoding a malformed Schematic file string by the web app.
- Fixed Schemacode samples to not use deprecated syntax.
Added
- Added support for partially decompiling existing mlog code into Mindcode.
2.3.0
Fixed
- Fixed wrong compilation order of appended files (#155).
- Fixed inadequate reporting of syntax error (#156).
- Fixed Wrong handling of comparison operators by Data Flow Optimization (#158).
- Fixed wrong parsing of formattable string literals.
- Fixed inadequate handling of unsupported expressions embedded in formattable string literals.
Added
- Breaking: Added support for syntax variants (
strict
andrelaxed
) to Mindcode. The Strict syntax is the default now; to be able to compile existing Mindcode the Relaxed syntax needs to be activated using the#relaxed;
directive. - Added support for the Mlog Watcher Mindustry mod integration to both the web app and the command-line tool. This mod allows the compiled code to be automatically injected into a selected processor in a running Mindustry game.
- Added variable name validation: when inserting mlog into Mindustry processor, variables named
configure
are silently renamed toconfig
. For this reason, usingconfigure
as a name for any variable in Mindcode causes an error. - Added navigable compiler error messages to the web app. Clicking on a message with known position in the source code selects the corresponding position in the editor.
- Added support for outputting the error messages by the command line tool in a format which allows IDEs to parse the position and navigate to the error location in the source code.
- Added a variety of new optimizations to the Expression Optimization.
op
instruction: many new optimizations when one of the two operands is known.lookup
instruction: when possible, the instruction is replaced by aset
instruction setting the item, liquid, building or unit directly to the target variable, allowing further optimizations to take place. Effective onaggresive
optimization level.
- Added warning messages when deprecated features are detected in the source code.
- Added support for creating constants from formattable string literals.
- Added full support for the
sync()
function: a variable passed as an argument to this function becomes automatically volatile.
Schemacode
- Added support for block comments, delimited by
/*
and*/
. These comments can span multiple lines.
Experimental features
- Added support for Mindustry Logic from upcoming version 8. The features supported correspond to the current implementation in Mindustry and might therefore still change. All new features are described in a separate documentation.
- Added a system library, automatically included when the language target is
8A
or higher. - Added support to the If Expression Optimization to propagate values in
if
expressions not just into theset
instruction, but into any instruction taking an input parameter. Available on theexperimental
optimization level.
Changed
- Breaking: Changed the implementation of the
printf()
function under language targetML8A
. Instead of compile-time formatting of passed parameters, the function usesprint
andformat
instructions for run-time formatting. - Changed the definition of the
&&
and||
operators: they are guaranteed to always evaluate to either0
or1
. - Changed the
min()
andmax()
functions to accept more than just two arguments. - Changed the Temporary Variables Elimination optimization to replace unused output variables in instructions with
0
, to ensure no unnecessary variable will be created by the instruction, reducing clutter. Closes #154. - Changed the If Expression Optimization to support value propagation for all instructions having one output parameter (based on instruction metadata), instead of just a subset of specifically handled instructions.
- Changed - yet again - the way the Single Step Elimination optimization removes the last instruction which is a jump to the beginning of the program, so that it doesn't leave behind any jump that might have targeted the removed instruction. Such a jump was harmless, but unnecessary and looked strange in the mlog.
- Changed the text buffer handling in the processor emulator to recognize identical outputs produced by consecutive
printflush
operations and avoid creating duplicate outputs. - When a compiler-generated variable is evaluated as uninitialized (this situation indicates a bug in some of the optimizers), an internal error is thrown.
Deprecated
- Deprecated the original Mindcode syntax.
- Deprecated the usage of parentheses around the list of values in list iteration loops.
- Deprecated escaped double quotes in string literals.
- Deprecated kebab-case identifiers (note that built-in mlog variables, such as
@blast-compound
, will continue to be supported). - Deprecated the
printf()
function in language targetML7A
and earlier. - Deprecated the
configure
property. This property from Mindustry Logic 6 was replaced byconfig
in Mindustry Logic 7.
Miscellaneous
- Added parallel execution of unit tests.
- Renamed the command-line tool module from
compiler
totoolapp
, and the Mindcode compiler module frommindcode
tocompiler
. - Renamed the files in
bin
directory frommcc
/mcc.bat
tomindcode
/mindcode.bat
.
2.2.1
Fixed
- Fixed the layout of the web page not rendering well on smaller screens and mobile devices.
Changed
- Changed the Single Step Elimination optimization to remove the last instruction if it jumps to the start of the program (not just
end
, but also unconditional jump) onadvanced
optimization level.