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

[Test] C-API #4

Draft
wants to merge 91 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
bcf8aa2
Allocate lexer inside `alloc_parser()`
amomchilov Feb 13, 2025
5f8e833
Add new arena allocator
amomchilov Feb 13, 2025
a51d08c
Enable unused-result warnings
Morriar Nov 28, 2024
c2da259
Move away from using VALUE and other Ruby data structs
Morriar Oct 30, 2024
6fcb89e
Do not test inner type for shitlist
Morriar Nov 8, 2024
cd901ba
Move away from Ruby data types
Morriar Nov 8, 2024
f6753f7
Move `constants.c`/`.h` to `rbs_extension/`
amomchilov Nov 28, 2024
7110ba4
Replace `rbs_abort`
Morriar Jan 3, 2025
b396faf
Do not raise for syntax errors
amomchilov Dec 6, 2024
1ab4c32
Make `parse_type_params` return a NODISCARD bool
Morriar Nov 28, 2024
62e7e79
Rename `syntax_error` to `set_syntax_error`
Morriar Nov 28, 2024
57f9a5e
Merge `aborted` and `syntax_error`
Morriar Nov 29, 2024
0fab17e
Introduce `rbs_buffer`
Morriar Nov 29, 2024
547bb0b
Move extension parsing functions out of `parser.c`
Morriar Nov 29, 2024
eecf824
Remove a few more `ruby.h`
Morriar Nov 29, 2024
ae31edf
Use a bare `char *` for type_name error
Morriar Nov 29, 2024
52f201e
Add `rbs_translation_context_t` to `rbs_loc_to_ruby_location`
amomchilov Nov 29, 2024
2a67c96
Set locations’ `buffer` in translation layer
amomchilov Nov 29, 2024
b239f86
Remove `cached_ruby_object` from `rbs_location_t`
amomchilov Nov 29, 2024
3ca4117
Dedupe `rbs_loc_add_required_child` body
amomchilov Nov 29, 2024
2f136c5
misc cleanup
amomchilov Nov 29, 2024
aad46c1
Migrate remaining uses of `rbs_unquote_string`
amomchilov Nov 29, 2024
c998ecf
Apply `rbs_parser_get_current_token()`
amomchilov Nov 29, 2024
7c72570
Delete `rbs_other_ruby_value_t`
amomchilov Dec 2, 2024
869a1a2
Import encoding handling from Prism
Morriar Nov 29, 2024
0984a4a
Store encoding in the lexer state
Morriar Jan 3, 2025
08b4a7a
Migrate `lexerstate` string to `rbs_string`
amomchilov Jan 10, 2025
efa6646
Remove useless includes
Morriar Dec 2, 2024
89b4e4b
Remove last `ruby/encoding` dependencies from parser.h
Morriar Dec 2, 2024
c87a436
Move lexer out of the extension directory
Morriar Dec 3, 2024
4b76214
Extract `alloc_lexer_from_buffer`
Morriar Dec 3, 2024
5dab633
Move the Ruby out of `alloc_lexer`
Morriar Dec 3, 2024
87cbbf5
Does not pass `parserstate` around for node translation
Morriar Dec 3, 2024
1ec4c47
Do not store `rb_encoding` in `parserstate`
Morriar Dec 3, 2024
f266000
Delete `parser_advance_assert`
Morriar Dec 3, 2024
e9eaed6
Raise errors without using parser state
amomchilov Jan 10, 2025
11dd363
Do not use parserstate's buffer to parse comments
Morriar Dec 3, 2024
c7faf00
Remove buffer from parserstate
Morriar Dec 3, 2024
1ff65c6
Rework some includes
Morriar Dec 3, 2024
3b7aaa4
Un-nest and use early return
amomchilov Dec 2, 2024
9ff49b7
Add typecheck to prevent segfault
amomchilov Dec 2, 2024
9027738
Extract function to populate type var table
amomchilov Dec 3, 2024
ac9db92
Use `c_name` to rename C++ keywords
Morriar Dec 3, 2024
b33b6f5
Move `declare_type_variables` to `main.c`
amomchilov Dec 4, 2024
9a28ef6
Replace Ruby’s `PRINTF_ARGS`
amomchilov Dec 4, 2024
6a51147
Remove `ruby.h` from `parserstate.h`
amomchilov Dec 4, 2024
6826520
Move parser and parserstate out of `rbs_extension/`
Morriar Dec 4, 2024
9308358
Move `NODISCARD` macro out of `parser.c`
amomchilov Dec 4, 2024
0f59bf6
Remove `rb_raise` from typevar table functions
amomchilov Dec 4, 2024
c6830cf
Clean some `.h` includes
Morriar Dec 4, 2024
3a1c658
Enable implicit fall-through errors
amomchilov Jan 7, 2025
3182320
Extract `raise_error_if_any()`
amomchilov Dec 4, 2024
12ee0a7
Add reverse lookup for nodes
Morriar Dec 5, 2024
bf51108
Silence warning on missing range initializer
Morriar Dec 5, 2024
1753f87
Give all nodes a location field
Morriar Jan 3, 2025
1a2294b
Don’t copy Ruby strings into extension
amomchilov Dec 17, 2024
7704c78
Add `rbs_string_copy_slice()`
amomchilov Dec 17, 2024
9c7d8da
Fix string handling in preperation for `free()`
amomchilov Jan 3, 2025
91e40ff
Delete `rbs_string_offset()`
amomchilov Dec 17, 2024
8d5aeb4
`rbs_string_strip_whitespace()` without copying
amomchilov Dec 17, 2024
1607efd
`rbs_parser_peek_current_token()` without copying
amomchilov Dec 17, 2024
e5cc95a
Copy RBS Strings into Ruby
amomchilov Dec 17, 2024
0af6a57
Delete `rbs_string_offset()`
amomchilov Dec 17, 2024
1b021fe
Free intermediate strings in `parser.c`
amomchilov Dec 17, 2024
7cc7a7d
Add `rbs_node_destroy()`
amomchilov Feb 14, 2025
590c100
Delete `rbs_string_offset()`
amomchilov Dec 17, 2024
b2de7f1
Call `rbs_node_destroy()` on list and hash members
amomchilov Feb 14, 2025
edadf9f
Add VSCode debugger configuration
amomchilov Jan 13, 2025
71eca45
Add scripts for profiling in Instruments
amomchilov Jan 13, 2025
2221f5f
Add missing stdint import
st0012 Feb 24, 2025
c5f0459
Remove unused local to please RuboCop
st0012 Feb 24, 2025
f785525
Avoid using vasprintf
st0012 Feb 24, 2025
5037054
Fix MSVC compatibility issues
st0012 Feb 25, 2025
98d0ebc
Assert ids always gets assigned
st0012 Feb 25, 2025
8f8b05a
Avoid using rb_raise in parser
st0012 Feb 24, 2025
823c4d1
Fix incorrect Qtrue usage and remove unnecessary import
st0012 Feb 24, 2025
ead4c20
Remove debugging assignment
st0012 Mar 6, 2025
6f475a7
Simplify rbs_location_current_token
st0012 Mar 6, 2025
4ecb007
Allocate location with allocator
st0012 Mar 6, 2025
5320431
Fix comment
st0012 Mar 7, 2025
ae4d316
Fix location child memory leak (#10)
st0012 Mar 11, 2025
10cd075
Remove unused rbs_constant_id_list and related functions (#12)
st0012 Mar 11, 2025
0fb8494
Remove unnecessary re-allocations from child-adding functions (#11)
st0012 Mar 11, 2025
63c0730
Allocate parser error and result with allocator (#15)
st0012 Mar 12, 2025
01cdcb2
Allocate owned rbs_string_t using allocator
st0012 Mar 11, 2025
fcb65f6
Remove string type enum
st0012 Mar 11, 2025
40fb219
Allocate `rbs_buffer_t` with allocator (#13)
st0012 Mar 12, 2025
b5ebb62
Free parser before raising Ruby exceptions
st0012 Mar 12, 2025
b28e38b
Merge pull request #17 from Shopify/add-allocate-many-function
st0012 Mar 12, 2025
5afb879
Fix code that triggers warnings when compiled with Sorbet (#19)
st0012 Mar 12, 2025
2c74261
Replace `assert` with `rbs_assert` for better assertion message (#23)
st0012 Mar 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

342 changes: 342 additions & 0 deletions .idea/rbs.iml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

118 changes: 118 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// Running these tasks does not trigger a recompile, so you'll need to do that yourself.
//
// Make sure you're using a debug build when debugging.
// Add `append_cflags ['-O0', '-g']` to extconf.rb to enable this.
//
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug all tests in LLDB",
"program": "/opt/rubies/3.3.4/bin/ruby",
"args": [
"-w",
"-Ilib",
"-Itest",
"/Users/alex/.gem/ruby/3.3.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb",
"test/rbs/ancestor_builder_test.rb",
"test/rbs/ancestor_graph_test.rb",
"test/rbs/annotate/annotations_test.rb",
"test/rbs/annotate/rdoc_annotator_test.rb",
"test/rbs/annotate/rdoc_source_test.rb",
"test/rbs/ast/type_param_test.rb",
"test/rbs/ast/visitor_test.rb",
"test/rbs/buffer_test.rb",
"test/rbs/cli_test.rb",
"test/rbs/collection/cleaner_test.rb",
"test/rbs/collection/config_test.rb",
"test/rbs/collection/installer_test.rb",
"test/rbs/collection/sources/git_test.rb",
"test/rbs/collection/sources/local_test.rb",
"test/rbs/collection/sources/stdlib_test.rb",
"test/rbs/definition_builder_test.rb",
"test/rbs/diff_test.rb",
"test/rbs/environment_loader_test.rb",
"test/rbs/environment_test.rb",
"test/rbs/environment_walker_test.rb",
"test/rbs/errors_test.rb",
"test/rbs/factory_test.rb",
"test/rbs/file_finder_test.rb",
"test/rbs/location_test.rb",
"test/rbs/locator_test.rb",
"test/rbs/method_builder_test.rb",
"test/rbs/method_type_parsing_test.rb",
"test/rbs/node_usage_test.rb",
"test/rbs/parser_test.rb",
"test/rbs/rb_prototype_test.rb",
"test/rbs/rbi_prototype_test.rb",
"test/rbs/rdoc/rbs_parser_test.rb",
"test/rbs/repository_test.rb",
"test/rbs/resolver/constant_resolver_test.rb",
"test/rbs/resolver/type_name_resolver_test.rb",
"test/rbs/runtime_prototype_test.rb",
"test/rbs/schema_test.rb",
"test/rbs/signature_parsing_test.rb",
"test/rbs/sorter_test.rb",
"test/rbs/subtractor_test.rb",
"test/rbs/test/hook_test.rb",
"test/rbs/test/runtime_test_test.rb",
"test/rbs/test/setup_helper_test.rb",
"test/rbs/test/tester_test.rb",
"test/rbs/test/type_check_test.rb",
"test/rbs/type_alias_dependency_test.rb",
"test/rbs/type_alias_regulartiry_test.rb",
"test/rbs/type_parsing_test.rb",
],
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
},
{
"type": "lldb",
"request": "launch",
"name": "Debug test in LLDB",
"program": "/opt/rubies/3.3.4/bin/ruby",
"args": [
"-Ilib",
"-Itest",
"${workspaceFolder}/bin/test_runner.rb",
"${workspaceFolder}/test/rbs/location_test.rb"
],
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
},
{
"type": "lldb",
"request": "launch",
"name": "Debug test/rbs/location_test.rb",
"program": "/opt/rubies/3.3.4/bin/ruby",
"args": [
"-Ilib",
"-Itest",
"${workspaceFolder}/bin/test_runner.rb",
"${workspaceFolder}/test/rbs/location_test.rb"
],
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
},
{
"type": "lldb",
"request": "launch",
"name": "Debug test/rbs/ancestor_builder_test.rb",
"program": "/opt/rubies/3.3.4/bin/ruby",
"args": [
"-Ilib",
"-Itest",
"${workspaceFolder}/bin/test_runner.rb",
"${workspaceFolder}/test/rbs/ancestor_builder_test.rb"
],
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
},

]
}
24 changes: 13 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ end
multitask :default => [:test, :stdlib_test, :typecheck_test, :rubocop, :validate, :test_doc]

task :lexer do
sh "re2c -W --no-generation-date -o ext/rbs_extension/lexer.c ext/rbs_extension/lexer.re"
sh "re2c -W --no-generation-date -o src/lexer.c src/lexer.re"
end

task :confirm_lexer => :lexer do
puts "Testing if lexer.c is updated with respect to lexer.re"
sh "git diff --exit-code ext/rbs_extension/lexer.c"
sh "git diff --exit-code src/lexer.c"
end

task :confirm_templates => :templates do
Expand Down Expand Up @@ -56,17 +56,19 @@ task :confirm_annotation do
end

task :templates do
sh "#{ruby} templates/template.rb include/rbs/constants.h"
sh "#{ruby} templates/template.rb include/rbs/ruby_objs.h"
sh "#{ruby} templates/template.rb src/constants.c"
sh "#{ruby} templates/template.rb src/ruby_objs.c"
sh "#{ruby} templates/template.rb ext/rbs_extension/ast_translation.h"
sh "#{ruby} templates/template.rb ext/rbs_extension/ast_translation.c"

sh "#{ruby} templates/template.rb ext/rbs_extension/class_constants.h"
sh "#{ruby} templates/template.rb ext/rbs_extension/class_constants.c"

sh "#{ruby} templates/template.rb include/rbs/ast.h"
sh "#{ruby} templates/template.rb src/ast.c"
end

task :compile => "ext/rbs_extension/lexer.c"
task :compile => "include/rbs/constants.h"
task :compile => "include/rbs/ruby_objs.h"
task :compile => "src/constants.c"
task :compile => "src/ruby_objs.c"
task :compile => "ext/rbs_extension/class_constants.h"
task :compile => "ext/rbs_extension/class_constants.c"
task :compile => "src/lexer.c"

task :test_doc do
files = Dir.chdir(File.expand_path('..', __FILE__)) do
Expand Down
Loading