Releases: cardillan/mindcode
Releases · cardillan/mindcode
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.
2.2.0
Fixed
- Fixed wrong size computation of code generated by the
remark()
function if theremarks
option was set tonone
oractive
. - Fixed Data Flow optimization incorrectly handling equality and inequality comparisons (#146).
- Fixed Data Flow optimization incorrectly processing execution paths through a case expression (#147).
- Fixed Function Inlining optimization missing some opportunities to inline a function.
- Fixed the
webapp.bat
file not working on Windows due to classpath being too long.
Added
- Added secondary set of icons representing constants with dashes in identifiers replaced by underscores (e.g.
ITEM_COAL
instead ofITEM-COAL
). Kebab-case identifiers (with dashes) are deprecated in Mindcode and will be desupported in a future release. (In Schemacode, there are currently no plans to remove support for kebab-case identifiers.) - Added support for declaring program parameters using a new
param
keyword. Using global variables for program parametrization is deprecated, program parameters should be used instead. Support for program parametrization through global variables will be removed in a future release. - Added a new
noinline
keyword, which will prevent a function from being inlined even when called just once, and by the Function Inlining optimization. The keyword can only be used when declaring a function. - Added support for block comments, delimited by
/*
and*/
. These comments can span multiple lines. - Added a new schematic sample with quite a sophisticated code on the Schematics page. It consists of an overdrive dome supplied by units controlled by a microprocessor. The microprocessor searches for available units among a list of supported types, switches to the preferred unit type when it becomes available, and rebinds units (possibly switching the type again) if units in use are destroyed or taken over by the player or a rogue processor.
Experimental features
Experimental features may contain bugs or produce suboptimal code, and are subject to change.
- Added support for multiple loop variables in list iteration loops. Each iteration processes as many elements from the list as there are loop variables.
- Added an
out
keyword to be used with loop control variables in list iteration loop, allowing list elements to be modified. - Added a new GUI option to choose optimization level in the web app when compiling Mindcode or building Schemacode.
- Added a capability to run the compiled code on an emulated processor, by using a
Compile and Run
button in the web app, or the--run
command line option. The output is shown in a separate control in the web app, or written to the log when using the command line tool. - Added a capability to the command line tool to compile several source files at once using the
--append
command line argument. - Added new optimization level,
experimental
. On this setting, the Data Flow optimizer doesn't assume the assignments to global variables might be changed by editing the compiled code, allowing to perform more optimizations on them. Program parameters must be used instead of global variables for program parametrization if this optimization level is used. - Added formattable string literals, which allow formatting outputs of the
print
andprintln
functions the same way asprintf
does. - Added enhanced comments, an alternative way to enter remarks.
- Added new
sort-variables
compiler directive which ensures that user variables will be accessed in a well-defined order, to make inspecting the variables in the Mindustry processors Vars screen easier. - Added generation of signature at the end of the compiled code. The signature is a
print
instruction (which is not executed) with the text "Compiled by Mindcode - github.com/cardillan/mindcode". The signature is not added should the instruction limit be exceeded, or when the program doesn't naturally end in an unconditional jump. Adding the signature can be disabled in the command line tool by the--no-signature
command line argument.
Changed
- Changed the names of optimization levels from
off
andaggressive
tonone
andadvanced
. The former names are still supported in the#set
compiler directive, but not in the command-line options. - Changed the Loop Hoisting optimization to analyze functions modifying variables inside loop instead of blanket assumption that all global variables may be changed by a function.
- Changes to the web app
- A button was added do the web app to copy the output code to the clipboard with a single click.
- It is now possible to select the optimization level directly in the web app user interface. The default optimization level is now
basic
for Mindcode compiler andadvanced
for Schemacode builder.
- Changed the syntax to allow an optional
do
keyword in allfor
andwhile
loops, and optionalthen
keyword inif
andelsif
statements. - Changed the Single Step Elimination optimization to remove the
end
instruction at the very end of the program onadvanced
optimization level. - Changed the command line tool to output final instruction numbers when printing out the unresolved code, for easier localization of errors reported when running the compiled code on an emulated processor.
Miscellaneous
- From this version (
2.2.0
) on, Mindcode will use semantic versioning (major version will be increased for significant changes to the syntax). The command-line tool now reports the version when passed in-v
or--version
as a parameter. - Replaced pattern matching in switch cases (JDK17 preview feature) with
if
and other constructs to remove the dependency on the--enable-preview
switch. - Updated existing Mindcode and Schemacode samples further to adapt for upcoming changes in syntax (optional keywords were added). Some samples were reworked.
2024-09-15
- Fixed slightly wrong (too low) cost estimation in the Case Switching optimization.
- New
remark()
function, as described here. - Slightly improved the Case Switching optimization - instead of expanding the jump table range by one on each side and limiting the input value using the
op min
andop max
instructions, the jump table covers only the existingwhen
branches and values outside the supported range are handled using conditional jumps. This change saves two instructions and potentially speeds up the execution for input values lying outside the jump table. - Some of the Mindcode samples used during unit tests were updated to use semicolons in anticipation to planned Mindcode changes.
2024-09-10
- Fixed wrong expression handling in loops by Data Flow Optimizer (issue #131).
- Fixed Data Flow Optimizer not removing some superfluous variables when using
case
expressions (issue #133). - Fixed Data Flow Optimizer incorrectly applying common subexpression optimization in some cases (issue #133).
- Added support for specifying processor code (both Mindcode and mlog) as a concatenation of multiple code snippets
from various sources (string literal, string constant or external file). - Added new Mandelbrot Generator schematics example.
- Starting from this release, releases will be published in GitHub
including the Mindcode compiler provided as a.jar
(binary) file.