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 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 switch_param branch 2 times, most recently from 0ecc64c to 6816a40 Jun 9, 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 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
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)
Copy link
Contributor

@FLHerne FLHerne Aug 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

FLHerne
FLHerne previously approved these changes Aug 29, 2020
LordAro
LordAro previously approved these changes Oct 3, 2020
Copy link
Member

@LordAro LordAro left a comment

Code looks good to me

LordAro
LordAro approved these changes Oct 3, 2020
@glx22 glx22 merged commit c6ea111 into OpenTTD:master Oct 3, 2020
19 checks passed
@glx22 glx22 deleted the switch_param branch Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants