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

Pointer and reference support #242

Merged
merged 19 commits into from
Aug 26, 2021
Merged

Pointer and reference support #242

merged 19 commits into from
Aug 26, 2021

Conversation

ghaith
Copy link
Collaborator

@ghaith ghaith commented Aug 16, 2021

Closes #177

Add support for REF_TO and POINTER_TO
The types are interchangeable

TODO:

  • Lexer
  • Parser
  • Indexing
  • Annotations
  • Codegen
  • Null

@ghaith ghaith self-assigned this Aug 16, 2021
@codecov
Copy link

codecov bot commented Aug 16, 2021

Codecov Report

Merging #242 (409aaba) into master (cd8ae14) will increase coverage by 0.10%.
The diff coverage is 96.26%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #242      +/-   ##
==========================================
+ Coverage   95.19%   95.29%   +0.10%     
==========================================
  Files          39       40       +1     
  Lines       10555    10760     +205     
==========================================
+ Hits        10048    10254     +206     
+ Misses        507      506       -1     
Impacted Files Coverage Δ
tests/tests.rs 100.00% <ø> (ø)
src/ast.rs 89.74% <89.74%> (-0.13%) ⬇️
src/codegen/generators/expression_generator.rs 87.54% <92.72%> (+0.04%) ⬆️
src/parser/expressions_parser.rs 96.94% <97.05%> (-0.05%) ⬇️
src/codegen/generators/llvm.rs 92.44% <100.00%> (+0.51%) ⬆️
src/index/visitor.rs 96.15% <100.00%> (+0.21%) ⬆️
src/lexer.rs 98.36% <100.00%> (+2.80%) ⬆️
src/parser.rs 97.91% <100.00%> (+0.10%) ⬆️
src/resolver.rs 95.90% <100.00%> (+0.14%) ⬆️
tests/correctness/pointers.rs 100.00% <100.00%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd8ae14...409aaba. Read the comment docs.

@@ -221,6 +221,19 @@ impl<'a> Llvm<'a> {
}
}

/// create a null pointer
pub fn create_null_ptr(&self) -> Result<TypeAndValue<'a>, CompileError> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Review: I don't know how much I like this. I have no type information at this position, so I assumed i32, which does not matter since it's a null pointer.
I also returned type information on the fly, but it might make more sense to have a NULL type in the index.

@ghaith
Copy link
Collaborator Author

ghaith commented Aug 20, 2021

Assigning a value to NULL then dereferencing it currently never ends (on windows).
I don't know if we should be adding some protection here, or if we should scrap the whole null idea

Looks like it segfaults, we need to test more examples, however as I had at least one example where it never stopped, and I can't reproduce it anymore.

@ghaith ghaith marked this pull request as ready for review August 20, 2021 09:48
@ghaith ghaith requested a review from riederm August 20, 2021 09:48
_ improve location information
_ Null now is of type VOID
_ better recovery on missing TO keyword in POINTER TO ...
@ghaith ghaith merged commit 7f86951 into master Aug 26, 2021
@ghaith ghaith deleted the pointers branch August 26, 2021 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Support for Pointer and Reference types
2 participants