Comments (2)
In this case, n
should have been stored on the stack, before entering the function's body, and restored on exit.
In essence, the generated code should look like (pseudo Mindustry Logic):
call T(2)
end
label T
__tmpX = pop
push n
set n = __tmpX
// function body
n = pop
@counter = pop // jump to caller
If there are more than one parameters, the same __tmpX
should be reused, to prevent exhaustion of local variables in Mindustry Logic. There must be a limit somewhere, and it would be preferable not to hit it.
from mindcode.
Functions have been improved in March 2023 update. Local scope for function variables is now correctly preserved in both recursive and non-recursive functions; recursive functions store and preserve function parameters and variables on stack (see https://github.com/francois/mindcode/blob/main/SYNTAX.markdown#custom-functions).
from mindcode.
Related Issues (20)
- Bug: loop unrolling fails on degenerate loops
- Comments on last line produce syntax errors
- Containers HOT 1
- Add @specialVars literals HOT 4
- QoL: Inverse lookup operation HOT 3
- Function inline optimization is unsafe HOT 4
- Turret not recognized as a block name by Mindcode
- Functions used in expressions are inlined wrongly HOT 2
- Wrong optimization of side effects in the when expressions
- No warning for elseif statement HOT 7
- [Schematics] No option for blocks with changeable block type or unit mode HOT 3
- Can't build on Windows ./mvnw not found HOT 3
- Optimization for speed by code duplication HOT 1
- Continue and Break can't be used inside functions HOT 2
- Variable in ubind optimized at the basic optimization level HOT 2
- Uninitialized variable after always true while loop HOT 2
- Function return values misplaced by loop hoisting
- Undefined function return value HOT 3
- Wrong expression handling in loops
- Fast inverse lookup HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mindcode.