Skip to content

Enable conditional expressions and switch statements in the CSEC machine #71

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

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

AprupKale
Copy link
Contributor

Enable switch statements to support code as follows:

public class Main {
    public static void main(String[] args) {
        int x = 2;
        String y;
        
        switch (x) {
            case 1:
                y = "One";
                break;
            case 2:
                y = "Two";
                break;
            case 3:
                y = "Three";
                break;
            default:
                y = "Default";
        }
    }
}

Enable conditional expressions to support code as follows:

int sign = x >= 0 ? 1 : -1;

Add a new instruction for the CSEC machine: cond
Add a new instruction for the CSEC machine: switch
@AprupKale AprupKale self-assigned this Apr 7, 2025
@AprupKale AprupKale added the enhancement New feature or request label Apr 7, 2025
Copy link

github-actions bot commented Apr 7, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
74.31% (+0.36% 🔼)
7634/10273
🟡 Branches
60.61% (+0.22% 🔼)
2553/4212
🟡 Functions
70.24% (+0.78% 🔼)
1357/1932
🟡 Lines
75.19% (+0.25% 🔼)
7185/9556
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / assignmentExpression.test.ts
100% 100% 100% 100%
🟢
... / castExpression.test.ts
100% 100% 100% 100%
🟢
... / switch.test.ts
100% 100% 100% 100%
🟢
... / methodOverloading.test.ts
100% 100% 100% 100%
🟢
... / methodOverriding.test.ts
100% 100% 100% 100%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / interpreter.ts
88.07% (-10.97% 🔻)
74.73% (-17.17% 🔻)
88.33% (-9.81% 🔻)
88.24% (-11.07% 🔻)
🟢
... / instrCreator.ts
96.36% (-3.64% 🔻)
100%
88.89% (-11.11% 🔻)
94.59% (-5.41% 🔻)
🟢
... / utils.ts
94.53% (-2.27% 🔻)
82.22% (-12.65% 🔻)
94.44%
94.2% (-2.81% 🔻)
🟡
... / index.ts
70.8% (-3.57% 🔻)
48% (-5.01% 🔻)
91.67% (-3.99% 🔻)
79.3% (-4.94% 🔻)
🟢
... / symbol-table.ts
93.07% (-0.83% 🔻)
76.09% (-3.32% 🔻)
100%
92.67% (-0.96% 🔻)
🟢
... / code-generator.ts
92.84% (-1.57% 🔻)
80.39% (-4.27% 🔻)
96.34% (+3.16% 🔼)
92.86% (-1.89% 🔻)

Test suite run success

1182 tests passing in 64 suites.

Report generated by 🧪jest coverage report action from a29402b

…itch statements fallthrough logic and evaluation in the CSEC machine
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.

1 participant