-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add solutions for advent of code 2024 day 1 to examples/
.
#4673
base: trunk
Are you sure you want to change the base?
Conversation
- Remove repeated definitions of `i32` operations that were causing duplicate name errors. - Build object files for the prelude and link against them when building `carbon_binary` rules.
Set their parent as the current package and mark them as being closed so that we can later recognize them as packages. Fixes pretty-printing of an indirectly imported `Core.Int`.
This adds two new builtins to the toolchain: `print.char` and `read.char`, which map to the libc functions `putchar` and `getchar`. Also fixes a bug where global variables would create LLVM variable declarations, not definitions, resulting in link errors.
Depends on #4644. |
var EOF: i32 = -(1 as i32); | ||
var push_back: i32 = EOF; | ||
|
||
fn ReadCharRaw() -> i32 = "read.char"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these be moved out of examples/
and into a library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
return from - 1; | ||
} | ||
|
||
fn Quicksort(p: [i32; 1000]*, from: i32, to: i32) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had you considered moving Quicksort
out to a library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had, but import_ref
can't import array types yet, so this is blocked on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#4675 for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And now moved out into a library.
@@ -0,0 +1,142 @@ | |||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These files don't really have much in terms of documentation. Would it be worth at least adding a README.md explaining what you're doing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the return type question you just asked -- consider me now neutral, the narrow delta of this change doesn't seem that bad to review. But, maybe fixing global variables should be in the PR title?
Split the bugfix out to #4674. |
prelude. Move the existing `Print` there too.
In order to support these examples, this adds two new builtins to the toolchain:
print.char
andread.char
, which map to the libc functionsputchar
andgetchar
.