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
Copy link
Contributor Author

glx22 commented Jun 5, 2020

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

@andythenorth
Copy link
Contributor

Works for me in Iron Horse.

@glx22 glx22 force-pushed the switch_param branch 2 times, most recently from 0ecc64c to 6816a40 Compare June 9, 2020 12:04
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
Copy link
Contributor

@FLHerne FLHerne left a comment

Choose a reason for hiding this comment

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

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

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

Choose a reason for hiding this comment

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

Code looks good to me

@glx22 glx22 merged commit c6ea111 into OpenTTD:master Oct 3, 2020
@glx22 glx22 deleted the switch_param branch October 3, 2020 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants