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 global character initialization and initialization with logical and equality operators #173

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

AW-AlanWu
Copy link
Contributor

This PR fixes the issue where global assignments cannot assign characters and do not support logical and equality operators. Corresponding tests have been added to ensure these changes.

Copy link
Collaborator

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Check https://cbea.ms/git-commit/ carefully and refine.

src/parser.c Outdated
res = op1 || op2;
break;
case OP_eq:
res = op1 == op2 ? 1 : 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If possible, directly rewrite it as res = op1 == op2 to avoid generating branch instructions.

src/parser.c Outdated
res = op1 == op2 ? 1 : 0;
break;
case OP_neq:
res = op1 != op2 ? 1 : 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto.

- Refactor read_numeric_sconstant function:
  - Support character initialization.
  - Support brackets with primary values only.
  - Rename to read_primary_constant for clarity.

- Refactor eval_expression_imm:
  - Add support for logical and equality operators:
    - OP_log_and, OP_log_or, OP_eq, OP_neq.

- Add tests:
  - Global character initialization.
  - Global initialization with logical and equality operations.
@jserv jserv merged commit 07adb41 into sysprog21:master Dec 18, 2024
6 checks passed
@jserv
Copy link
Collaborator

jserv commented Dec 18, 2024

Thank @AW-AlanWu for contributing!

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.

5 participants