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

[Feature] Add UnaryExpression and Negate #86

Merged
merged 6 commits into from
Apr 5, 2024

Conversation

matthew-mccall
Copy link
Collaborator

This PR adds UnaryExpression. An abstract node for expressions with a single operand such as negation, square roots, etc.

This PR also adds the Negate node, a convenience node to make tree insertion and balancing easier, for instance dealing with Add. This addresses #12.

@matthew-mccall matthew-mccall self-assigned this Apr 5, 2024
@matthew-mccall matthew-mccall added the enhancement New feature or request label Apr 5, 2024
@matthew-mccall matthew-mccall linked an issue Apr 5, 2024 that may be closed by this pull request
2 tasks
@matthew-mccall matthew-mccall mentioned this pull request Apr 5, 2024
6 tasks
Copy link

github-actions bot commented Apr 5, 2024

Filename                               Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
src/Expression.cpp                         132                13    90.15%          19                 4    78.95%         252                26    89.68%         102                15    85.29%
src/Imaginary.cpp                           10                 4    60.00%           4                 1    75.00%          12                 3    75.00%           4                 2    50.00%
src/Log.cpp                                 44                10    77.27%           6                 3    50.00%          56                17    69.64%          28                 8    71.43%
src/Real.cpp                                14                 1    92.86%           6                 0   100.00%          17                 0   100.00%           8                 1    87.50%
src/Undefined.cpp                            9                 9     0.00%           3                 3     0.00%           9                 9     0.00%           4                 4     0.00%
src/Exponent.cpp                            81                26    67.90%          10                 6    40.00%         143                72    49.65%          54                19    64.81%
src/Add.cpp                                148                43    70.95%          10                 1    90.00%         229                58    74.67%         110                42    61.82%
src/Divide.cpp                             170                62    63.53%          10                 2    80.00%         255                86    66.27%         132                60    54.55%
src/Subtract.cpp                            61                20    67.21%          10                 3    70.00%         118                31    73.73%          38                18    52.63%
src/Multiply.cpp                           171                29    83.04%          10                 1    90.00%         276                63    77.17%         132                35    73.48%
src/Variable.cpp                            14                 4    71.43%           6                 1    83.33%          17                 3    82.35%           8                 2    75.00%
include/Oasis/Log.hpp                        6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/Divide.hpp                     6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/Subtract.hpp                   6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/Add.hpp                        6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/LeafExpression.hpp             4                 0   100.00%           4                 0   100.00%          12                 0   100.00%           0                 0         -
include/Oasis/BinaryExpression.hpp         183                12    93.44%          41                 0   100.00%         395                19    95.19%         110                43    60.91%
include/Oasis/Expression.hpp                 7                 1    85.71%           7                 1    85.71%          19                 3    84.21%           0                 0         -
include/Oasis/Imaginary.hpp                  2                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
include/Oasis/Exponent.hpp                   6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/Multiply.hpp                   6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/Undefined.hpp                  3                 1    66.67%           3                 1    66.67%           3                 1    66.67%           0                 0         -
include/Oasis/UnaryExpression.hpp           20                15    25.00%          12                 9    25.00%          47                34    27.66%           4                 4     0.00%
include/Oasis/Negate.hpp                     5                 3    40.00%           5                 3    40.00%          21                12    42.86%           0                 0         -
include/Oasis/Variable.hpp                   1                 0   100.00%           1                 0   100.00%           1                 0   100.00%           0                 0         -
include/Oasis/Real.hpp                       2                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                     1117               259    76.81%         207                45    78.26%        1946               455    76.62%         734               253    65.53%

Generated by llvm-cov -- llvm version 17.0.6

Copy link

github-actions bot commented Apr 5, 2024

Filename                               Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
src/Expression.cpp                         132                13    90.15%          19                 4    78.95%         252                26    89.68%         102                15    85.29%
src/Imaginary.cpp                           10                 4    60.00%           4                 1    75.00%          12                 3    75.00%           4                 2    50.00%
src/Log.cpp                                 44                10    77.27%           6                 3    50.00%          56                17    69.64%          28                 8    71.43%
src/Real.cpp                                14                 1    92.86%           6                 0   100.00%          17                 0   100.00%           8                 1    87.50%
src/Undefined.cpp                            9                 9     0.00%           3                 3     0.00%           9                 9     0.00%           4                 4     0.00%
src/Exponent.cpp                            81                26    67.90%          10                 6    40.00%         143                72    49.65%          54                19    64.81%
src/Add.cpp                                148                43    70.95%          10                 1    90.00%         229                58    74.67%         110                42    61.82%
src/Divide.cpp                             170                62    63.53%          10                 2    80.00%         255                86    66.27%         132                60    54.55%
src/Subtract.cpp                            61                20    67.21%          10                 3    70.00%         118                31    73.73%          38                18    52.63%
src/Multiply.cpp                           171                29    83.04%          10                 1    90.00%         276                63    77.17%         132                35    73.48%
src/Variable.cpp                            14                 4    71.43%           6                 1    83.33%          17                 3    82.35%           8                 2    75.00%
include/Oasis/Log.hpp                        6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/Divide.hpp                     6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/Subtract.hpp                   6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/Add.hpp                        6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/LeafExpression.hpp             4                 0   100.00%           4                 0   100.00%          12                 0   100.00%           0                 0         -
include/Oasis/BinaryExpression.hpp         183                12    93.44%          41                 0   100.00%         395                19    95.19%         110                43    60.91%
include/Oasis/Expression.hpp                 7                 1    85.71%           7                 1    85.71%          19                 3    84.21%           0                 0         -
include/Oasis/Imaginary.hpp                  2                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
include/Oasis/Exponent.hpp                   6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/Multiply.hpp                   6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/Undefined.hpp                  3                 1    66.67%           3                 1    66.67%           3                 1    66.67%           0                 0         -
include/Oasis/UnaryExpression.hpp           20                15    25.00%          12                 9    25.00%          47                34    27.66%           4                 4     0.00%
include/Oasis/Negate.hpp                     5                 3    40.00%           5                 3    40.00%          21                12    42.86%           0                 0         -
include/Oasis/Variable.hpp                   1                 0   100.00%           1                 0   100.00%           1                 0   100.00%           0                 0         -
include/Oasis/Real.hpp                       2                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                     1117               259    76.81%         207                45    78.26%        1946               455    76.62%         734               253    65.53%

Generated by llvm-cov -- llvm version 17.0.6

Copy link

github-actions bot commented Apr 5, 2024

Filename                               Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
src/Expression.cpp                         132                13    90.15%          19                 4    78.95%         252                26    89.68%         102                15    85.29%
src/Imaginary.cpp                           10                 4    60.00%           4                 1    75.00%          12                 3    75.00%           4                 2    50.00%
src/Log.cpp                                 44                10    77.27%           6                 3    50.00%          56                17    69.64%          28                 8    71.43%
src/Real.cpp                                14                 1    92.86%           6                 0   100.00%          17                 0   100.00%           8                 1    87.50%
src/Undefined.cpp                            9                 9     0.00%           3                 3     0.00%           9                 9     0.00%           4                 4     0.00%
src/Exponent.cpp                            81                26    67.90%          10                 6    40.00%         143                72    49.65%          54                19    64.81%
src/Add.cpp                                148                43    70.95%          10                 1    90.00%         229                58    74.67%         110                42    61.82%
src/Divide.cpp                             170                62    63.53%          10                 2    80.00%         255                86    66.27%         132                60    54.55%
src/Subtract.cpp                            61                20    67.21%          10                 3    70.00%         118                31    73.73%          38                18    52.63%
src/Multiply.cpp                           171                29    83.04%          10                 1    90.00%         276                63    77.17%         132                35    73.48%
src/Variable.cpp                            14                 4    71.43%           6                 1    83.33%          17                 3    82.35%           8                 2    75.00%
include/Oasis/Log.hpp                        6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/Divide.hpp                     6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/Subtract.hpp                   6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/Add.hpp                        6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/LeafExpression.hpp             4                 0   100.00%           4                 0   100.00%          12                 0   100.00%           0                 0         -
include/Oasis/BinaryExpression.hpp         183                12    93.44%          41                 0   100.00%         395                19    95.19%         110                43    60.91%
include/Oasis/Expression.hpp                 7                 1    85.71%           7                 1    85.71%          19                 3    84.21%           0                 0         -
include/Oasis/Imaginary.hpp                  2                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
include/Oasis/Exponent.hpp                   6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/Multiply.hpp                   6                 1    83.33%           6                 1    83.33%          10                 3    70.00%           0                 0         -
include/Oasis/Undefined.hpp                  3                 1    66.67%           3                 1    66.67%           3                 1    66.67%           0                 0         -
include/Oasis/UnaryExpression.hpp           20                15    25.00%          12                 9    25.00%          47                34    27.66%           4                 4     0.00%
include/Oasis/Negate.hpp                     5                 3    40.00%           5                 3    40.00%          21                12    42.86%           0                 0         -
include/Oasis/Variable.hpp                   1                 0   100.00%           1                 0   100.00%           1                 0   100.00%           0                 0         -
include/Oasis/Real.hpp                       2                 0   100.00%           2                 0   100.00%           2                 0   100.00%           0                 0         -
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                     1117               259    76.81%         207                45    78.26%        1946               455    76.62%         734               253    65.53%

Generated by llvm-cov -- llvm version 17.0.6

@matthew-mccall matthew-mccall merged commit dc52199 into master Apr 5, 2024
5 checks passed
@matthew-mccall matthew-mccall deleted the feature-covenience-nodes branch April 7, 2024 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Negation
2 participants