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

Support for Exponents #484

Merged
merged 47 commits into from
Aug 11, 2022
Merged

Support for Exponents #484

merged 47 commits into from
Aug 11, 2022

Conversation

ghaith
Copy link
Collaborator

@ghaith ghaith commented Apr 28, 2022

Adds support for exponents as defined in the norm (3**2 is 3 to the power of 2)

The implementation will call the appropriate EXPT function from the standard functions
It attempts to find the most efficient function for the input (int powers, or real powers)
The actual methods are implemented in the standard functions :
PLC-lang/StandardFunctions#48

ghaith and others added 30 commits February 16, 2022 15:27
If one of the types is generics (because it was builtin)
it will not be cast.
Added the variadics to the index members to allow the resolver
to correctly address them / modify them once a generic type needs to be
replaced
@codecov-commenter
Copy link

codecov-commenter commented Jul 26, 2022

Codecov Report

Merging #484 (1a3364e) into master (528fd89) will increase coverage by 0.05%.
The diff coverage is 94.77%.

@@            Coverage Diff             @@
##           master     #484      +/-   ##
==========================================
+ Coverage   89.01%   89.07%   +0.05%     
==========================================
  Files          42       42              
  Lines       15261    15366     +105     
==========================================
+ Hits        13585    13687     +102     
- Misses       1676     1679       +3     
Impacted Files Coverage Δ
src/ast.rs 92.38% <50.00%> (-0.14%) ⬇️
src/builtins.rs 87.96% <88.09%> (+0.05%) ⬆️
src/parser/expressions_parser.rs 94.34% <96.00%> (+0.05%) ⬆️
src/codegen/generators/expression_generator.rs 87.28% <100.00%> (+0.01%) ⬆️
src/resolver.rs 97.05% <100.00%> (+0.43%) ⬆️
src/resolver/generics.rs 96.25% <100.00%> (+0.27%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@ghaith ghaith marked this pull request as ready for review July 26, 2022 11:21
@ghaith ghaith requested a review from riederm July 26, 2022 11:21
Copy link
Collaborator

@riederm riederm left a comment

Choose a reason for hiding this comment

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

2 tiny things, rest looks good to me!

generics_candidates.insert("U".to_string(), vec![element_type.to_string()]);
generics_candidates.insert("V".to_string(), vec![exponant_type.to_string()]);
annotator.update_generic_call_statement(generics_candidates, "EXPT", operator, parameters, ctx)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

is an else here unreachable? can we add an !impossible with explanation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added an unreachable here, but I'm not sure this is the best way.
Theoratically these types exist, and if not it's the resolver's / validator's job to say so.

@ghaith ghaith requested a review from riederm August 11, 2022 09:12
@ghaith ghaith merged commit 3b10bb8 into master Aug 11, 2022
@ghaith ghaith deleted the expt branch August 11, 2022 16:41
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.

3 participants