Skip to content

Commit 495de42

Browse files
committed
Release 3.3.0
1 parent d3cc202 commit 495de42

15 files changed

+3922
-3722
lines changed

CHANGELOG.markdown

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,28 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project now adheres to [Semantic Versioning](https://semver.org/).
66

7-
## 3.3.0 - Future release
7+
## 3.3.0 - 2025-04-11
88

99
### Fixed
1010

1111
* Fixed some command-line options not having an effect in the command-line tool ([#231](https://github.com/cardillan/mindcode/issues/231)).
1212
* Fixed wrong handling or hoisted set instruction setting up return address in subsequent loop unrolling ([#234](https://github.com/cardillan/mindcode/issues/234)).
1313
* Fixed optimizations removing the `spawn` instruction when the output value was not used ([#236](https://github.com/cardillan/mindcode/issues/236)).
1414
* Fixed Jump Optimization not performing the optimization in unrolled loops.
15+
* Fixed error in compile-time evaluation of an expression involving a character literal ([#240](https://github.com/cardillan/mindcode/issues/240)).
16+
* Fixed incorrect compile-time evaluation of some logic IDs ([#242](https://github.com/cardillan/mindcode/issues/242)).
17+
* Fixed possible incorrect handling of arguments passed to the `print()` and other output functions ([#243](https://github.com/cardillan/mindcode/issues/243)).
1518

1619
### Added
1720

1821
* **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.
1922
* Added the [`char()` function](doc/syntax/SYNTAX-4-FUNCTIONS.markdown#the-char-function). The function returns the ASCII value of a character at given index from a string value using the `read` instruction, as supported in latest BE version.
2023
* Added support for invoking properties and the `sensor` functions on string values to support latest BE Enhancement of sensing string lengths using `@size`.
24+
* Added the [`strlen()` function](doc/syntax/SYNTAX-4-FUNCTIONS.markdown#the-strlen-function) returning the length of a string determined at runtime.
2125
* 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]`).
2226
* Added compile-time evaluation of either stable, or all built-in numerical variables (such as `@pi` or `@unitCount`).
2327
* Added a new remarks mode, `comments`, to compile remarks as mlog comments (`# comment`).
24-
* Added support for generating boundary checks for explicitly declared external arrays.
28+
* Added support for generating runtime boundary checks for explicitly declared external arrays.
2529
* Added new `printLines()` function to the `printing` library. The function prints each of its arguments on a new line.
2630
* Loop Hoisting optimizer enhanced with an ability to optimize instructions setting up return addresses of function calls.
2731
* Added handling of numerical literal values unsupported by Mindustry Logic version 7 and earlier (namely, `-2147483648`).
@@ -44,6 +48,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/), and this
4448

4549
* **Breaking**: underscores in multi-word command-line options were changed to hyphens.
4650
* 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.
51+
* 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.
4752
* Improved optimization of jumps by making multiple passes over jumps-related optimizers, up to the optimization passes limit.
4853
* 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.
4954
* Stripped unnecessary `.0` distinctions from local variable prefix.

README.markdown

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
**Schemacode**, an extension built over Mindcode, is a specialized definition language designed for creating a complete Mindustry schematic from a text file. [Schematics builder](doc/syntax/SCHEMACODE.markdown) compiles these definition files directly into Mindustry schematics, either into binary `.msch` file, or into the text representation. Processors can be included in these schematics, complete with the code (specified either in Mindcode or mlog) and linked blocks.
2020

21-
## Mindcode Syntax
22-
2321
> [!NOTE]
24-
> To use new Mindustry Logic capabilities from the new [Mindustry 8 pre-release](https://github.com/Anuken/Mindustry/releases/tag/v147), use `#set target = 8;` in your code.
22+
> To use new Mindustry Logic capabilities from the new [Mindustry 8 pre-release](https://github.com/Anuken/Mindustry/releases/tag/v147), use `#set target = 8;` in your code. [Here](/doc/syntax/MINDUSTRY-8.markdown#new-functionality-in-mindustry-8) is a summary of the new Logic content and corresponding Mindcode functionality.
23+
24+
## Mindcode Syntax
2525

2626
Please refer to the [documentation](doc/syntax/SYNTAX.markdown) for a complete description of Mindcode syntax. You can also use the code examples in the web application to get familiar with Mindcode.
2727

@@ -34,16 +34,18 @@ See [issues](https://github.com/cardillan/mindcode/issues?q=is%3Aissue%20state%3
3434
The most important recent changes to Mindcode include:
3535

3636
* Language features
37-
* Support for [symbolic labels in generated mlog code](/doc/syntax/SYNTAX-5-OTHER.markdown#option-symbolic-labels).
37+
* Passing arguments (including arrays) to inline functions by reference.
3838
* Specific syntax for [mlog keywords](doc/syntax/SYNTAX.markdown#mlog-keywords).
3939
* Support for passing mlog keywords as arguments to inline functions.
40-
* External and internal arrays (`@counter` arrays).
40+
* External and internal arrays (`@counter` arrays), including basic array optimizations.
4141
* Expressions in string interpolation: `print($"Sum: ${a + b}.")`.
4242
* Support for color literals: `%00ffff80`.
4343
* Prefix/postfix increment/decrement operators: `i++`, `--j`.
4444
* Redefined [strict and relaxed syntax modes](/doc/syntax/SYNTAX.markdown#strict-syntax).
4545
* Variable declaration (optional in relaxed syntax, compulsory in strict syntax).
4646
* Basic functionality
47+
* Support for [symbolic labels and indentation in generated mlog code](/doc/syntax/SYNTAX-5-OTHER.markdown#option-symbolic-labels).
48+
* Using Mindustry Logic metadata corresponding to the target selected for compilation.
4749
* Significant improvement in reporting error messages generated during compilation.
4850
* A built-in [library of system functions](doc/syntax/SYSTEM-LIBRARY.markdown).
4951
* Ability to inject the mlog code to Mindustry processors via the [Mlog Watcher mod](doc/syntax/TOOLS-MLOG-WATCHER.markdown).
@@ -52,7 +54,7 @@ The most important recent changes to Mindcode include:
5254
* Mindustry Logic 8
5355
* Complete support for the Mindustry Logic in the latest [Mindustry BE version](/doc/syntax/MINDUSTRY-8.markdown).
5456
* Full support for [remote functions and variables](doc/syntax/REMOTE-CALLS.markdown).
55-
* New `printchar` instruction and character literals.
57+
* New string/character based instructions and character literals.
5658

5759
See [changelog](CHANGELOG.markdown) for a comprehensive list of changes.
5860

compiler/src/test/resources/info/teksol/mc/mindcode/tests/processor/executes-sort-variables.log

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
29 instructions before optimizations.
22
1 instructions eliminated by Dead Code Elimination (4 iterations).
33
1 instructions eliminated by Single Step Elimination (6 iterations).
4-
14 instructions eliminated by Data Flow Optimization (3 passes, 12 iterations).
4+
14 instructions eliminated by Data Flow Optimization (3 passes, 13 iterations).
55
2 instructions eliminated by Loop Unrolling (4 iterations).
66
1 loops unrolled by Loop Unrolling.
77
11 instructions after optimizations.
@@ -212,28 +212,38 @@ Modifications by Iterated phase, Data Flow Optimization, pass 1, iteration 5 (-1
212212
16 label *label3
213213

214214
Modifications by Iterated phase, Data Flow Optimization, pass 2, iteration 1 (-1 instructions):
215-
216-
3 op mul :test:step p 2
215+
0 set p 1
216+
1 assertflush
217+
2 label *label8
218+
- * op mul :test:step p 2
219+
+ 3 op mul :test:i p 2
217220
4 label *label9
218221
5 label *label12
219222
- * set :test:i :test:step
220-
+ 6 set :test:b :test:step
221-
7 op mul :test:step p 4
222-
8 label *label13
223-
- * set :test:b :test:i
224-
9 label *label16
225-
10 set :test:i :test:step
226-
11 op mul :test:step p 8
223+
6 op mul :test:step p 4
224+
7 label *label13
225+
8 set :test:b :test:i
227226

228-
Modifications by Iterated phase, Data Flow Optimization, pass 2, iteration 2 (-2 instructions):
227+
Modifications by Iterated phase, Data Flow Optimization, pass 2, iteration 2 (-1 instructions):
229228
0 set p 1
230229
1 assertflush
231230
2 label *label8
232-
- * op mul :test:step p 2
231+
- * op mul :test:i p 2
233232
+ 3 op mul :test:b p 2
234233
4 label *label9
235234
5 label *label12
236-
- * set :test:b :test:step
235+
6 op mul :test:step p 4
236+
7 label *label13
237+
- * set :test:b :test:i
238+
8 label *label16
239+
9 set :test:i :test:step
240+
10 op mul :test:step p 8
241+
242+
Modifications by Iterated phase, Data Flow Optimization, pass 2, iteration 3 (-1 instructions):
243+
244+
3 op mul :test:b p 2
245+
4 label *label9
246+
5 label *label12
237247
- * op mul :test:step p 4
238248
+ 6 op mul :test:i p 4
239249
7 label *label13

compiler/src/test/resources/library/outputs/arrays-experimental.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
9 instructions eliminated by Jump Optimization (2 passes, 7 iterations).
66
19 instructions eliminated by Single Step Elimination (4 passes, 11 iterations).
77
1729 instructions eliminated by Expression Optimization (3 passes, 5 iterations).
8-
209 instructions eliminated by Data Flow Optimization (11 passes, 56 iterations).
8+
209 instructions eliminated by Data Flow Optimization (11 passes, 55 iterations).
99
7 instructions eliminated by Loop Optimization (5 iterations).
1010
7 loops improved by Loop Optimization.
1111
1972 instructions added by Loop Unrolling (19 iterations).

0 commit comments

Comments
 (0)