Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: Support for parameters in switches #155

Merged
merged 4 commits into from Oct 3, 2020
Merged

Conversation

@glx22
Copy link
Contributor

@glx22 glx22 commented Jun 2, 2020

New syntax, compatible with old one:

switch (<feature>, (SELF|PARENT), <ID>(, <param_name>)*, <expression>) {
	(<range>: <return_value>;)*
	<return_value>;
}
@glx22 glx22 force-pushed the glx22:switch_param branch from 42b98e4 to 77e62da Jun 5, 2020
@glx22
Copy link
Contributor Author

@glx22 glx22 commented Jun 5, 2020

It's rebased on top of #156 for easier testing

@andythenorth
Copy link
Contributor

@andythenorth andythenorth commented Jun 5, 2020

Works for me in Iron Horse.

@glx22 glx22 force-pushed the glx22:switch_param branch 2 times, most recently from 0ecc64c to 6816a40 Jun 6, 2020
nml/actions/action2.py Outdated Show resolved Hide resolved
nml/actions/action2.py Outdated Show resolved Hide resolved
nml/actions/action2var.py Outdated Show resolved Hide resolved
nml/actions/action2var.py Outdated Show resolved Hide resolved
nml/actions/action2var.py Outdated Show resolved Hide resolved
nml/ast/switch.py Outdated Show resolved Hide resolved
nml/ast/switch.py Outdated Show resolved Hide resolved
nml/ast/switch.py Outdated Show resolved Hide resolved
@glx22 glx22 force-pushed the glx22:switch_param branch from 6816a40 to e22958c Jul 5, 2020
Copy link
Contributor

@FLHerne FLHerne left a comment

Reviewed code-wise. I haven't yet tried to figure out whether the resulting NFO makes sense.

nml/actions/action2layout.py Outdated Show resolved Hide resolved
nml/actions/action2.py Outdated Show resolved Hide resolved
nml/actions/action2.py Outdated Show resolved Hide resolved
nml/actions/action2var.py Outdated Show resolved Hide resolved
nml/actions/action2var.py Outdated Show resolved Hide resolved
nml/actions/action2var.py Outdated Show resolved Hide resolved
nml/ast/switch.py Outdated Show resolved Hide resolved
nml/expression/spritegroup_ref.py Outdated Show resolved Hide resolved
@glx22 glx22 force-pushed the glx22:switch_param branch from e22958c to 84c2cdb Aug 29, 2020
store_tmp = VarAction2StoreCallParam(target.register_map[self.feature][i])
self.parse_expr(reduce_varaction2_expr(param, self.feature))
self.var_list.append(nmlop.STO_TMP)
self.var_list.append(store_tmp)

This comment has been minimized.

@FLHerne

FLHerne Aug 29, 2020
Contributor

This could be self.var_list += (nmlop.STO_TMP, store_tmp), and similarly below. Current way might be clearer, not sure.

@glx22 glx22 requested a review from LordAro Aug 29, 2020
@glx22 glx22 force-pushed the glx22:switch_param branch from 84c2cdb to 9ce7edf Oct 2, 2020
Copy link
Member

@LordAro LordAro left a comment

Code looks good to me

@glx22 glx22 force-pushed the glx22:switch_param branch from 9ce7edf to 3ffb366 Oct 3, 2020
@LordAro
LordAro approved these changes Oct 3, 2020
@glx22 glx22 merged commit c6ea111 into OpenTTD:master Oct 3, 2020
19 checks passed
19 checks passed
Commit checker
Details
Python 3.5 on ubuntu-latest
Details
Security and Quality
Details
Python 3.6 on ubuntu-latest
Details
Python 3.7 on ubuntu-latest
Details
Python 3.8 on ubuntu-latest
Details
Python pypy3 on ubuntu-latest
Details
Python 3.5 on macOS-latest
Details
Python 3.6 on macOS-latest
Details
Python 3.7 on macOS-latest
Details
Python 3.8 on macOS-latest
Details
Python 3.5 on windows-2016
Details
Python 3.6 on windows-2016
Details
Python 3.7 on windows-2016
Details
Python 3.8 on windows-2016
Details
Python 3.x on ubuntu-latest
Details
Python 3.x on macOS-latest
Details
Python 3.x on windows-2016
Details
CodeQL 1 warning
Details
@glx22 glx22 deleted the glx22:switch_param branch Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants