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

Fix function scope #120

Merged
merged 2 commits into from
Feb 7, 2025
Merged

Fix function scope #120

merged 2 commits into from
Feb 7, 2025

Conversation

SIGMazer
Copy link
Contributor

@SIGMazer SIGMazer commented Feb 7, 2025

Description

This pull request introduces several enhancements and fixes to the codebase, primarily focusing on function handling, scope management, and debugging capabilities. The most important changes include adding a debug build target, improving function call handling, and updating test cases to reflect new functionality.

Build System Improvements:

  • Added DEBUG_FLAGS := -g to Makefile and introduced a new debug target for compiling debug builds with GDB support. [1] [2]

Function Handling Enhancements:

  • Added support for function calls in get_expression_type by looking up the function's return type in the symbol table.
  • Implemented enter_function_scope to handle function scope entry and parameter assignment, replacing the previous manual parameter handling in execute_function_call. [1] [2]
  • Modified handle_return_statement to clean up all scopes until the function scope is reached.

Scope Management:

  • Updated get_variable to return NULL if the current scope is a function scope, ensuring proper variable resolution.
  • Added is_function_scope to the Scope structure to differentiate function scopes from other scopes.

Test Case Updates:

  • Added new test cases fib.brainrot and func_scope.brainrot to verify the correct behavior of recursive functions and function scope handling. [1] [2]
  • Updated expected_results.json to include expected outputs for the new test cases.

Related Issue

#115

Fixes #<issue_number>

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Performance improvement
  • Refactor

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have documented my changes in the code or documentation
  • I have added tests that prove my changes work (if applicable)
  • I have run the unit tests locally
  • I have run the valgrind memory tests locally
  • All new and existing tests pass

@SIGMazer SIGMazer requested a review from araujo88 as a code owner February 7, 2025 15:19
@SIGMazer SIGMazer added the bugfix Fix for something that wasn't working label Feb 7, 2025
@SIGMazer SIGMazer linked an issue Feb 7, 2025 that may be closed by this pull request
@SIGMazer SIGMazer merged commit 3f312e7 into main Feb 7, 2025
2 checks passed
@SIGMazer SIGMazer deleted the feat/func_scope branch February 7, 2025 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fix for something that wasn't working
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Function Scope
2 participants