Skip to content

Add parameter type inline annotation #2443

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

Draft
wants to merge 122 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
122 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
1ca7576
Strip whitespace without allocation
amomchilov Mar 24, 2025
10075ee
Remove all string slice copying
amomchilov Mar 24, 2025
b6005bf
Merge branch 'master' into c-api-merge-master
st0012 Mar 17, 2025
5ccb540
Merge `ruby/rbs` master into `c-api` (#22)
st0012 Mar 24, 2025
a8cdc87
Prefix internal lexer and encoding functions and types (#25)
st0012 Mar 26, 2025
334c277
Merge `parserstate.c` and `.h` files into respective `parser` files +…
st0012 Mar 27, 2025
bb5e560
Hide `id_table` struct (#27)
st0012 Mar 28, 2025
61b3e4a
Rename parser related structs (#28)
st0012 Mar 28, 2025
67b2fe1
Rename `position`, `token`, and `range`types (#30)
st0012 Mar 28, 2025
e2fb38b
Rename parser functions with `rbs_` prefix (#29)
st0012 Mar 31, 2025
cc33f9b
Correctly convert camel case to snake case when generating names in C…
st0012 Apr 1, 2025
5c7885e
Move more internal components into `util` folder (#33)
st0012 Apr 1, 2025
496bfef
Rename `rbs_location.*` and `rbs_string.*` to `location.*` and `strin…
st0012 Apr 1, 2025
e6e7900
Rename lexer struct, param, and functions (#35)
st0012 Apr 1, 2025
91dfbbd
Always define the `is_power_of_two` function (#36)
st0012 Apr 2, 2025
ed97906
Make it easier to switch between allocator implementations
tekknolagi Apr 3, 2025
477ad58
Use one massive slice of virtual memory per arena
tekknolagi Apr 3, 2025
da91a88
Merge branch 'master' into c-api
st0012 Apr 10, 2025
afc0f98
Merge branch 'master' into merge-master
st0012 Apr 23, 2025
73060a6
Remove unnecessary freeing functions (#40)
st0012 Apr 25, 2025
b5e5032
Merge branch 'c-api' into merge-master
st0012 Apr 25, 2025
563e081
Remove files that won't be upstreamed (#42)
st0012 Apr 29, 2025
0a8a4c5
Apply suggestions from code review
st0012 Apr 30, 2025
a9e7702
Update src/parser.c
st0012 Apr 30, 2025
514745b
Update src/parser.c
st0012 Apr 30, 2025
9e6b6ae
Merge branch 'merge-master' into c-api
st0012 Apr 30, 2025
f032275
Merge branch 'master' into c-api
st0012 May 1, 2025
fe32f21
Add ParamTypeAnnotation
soutaro May 2, 2025
e853fd0
Update AST
soutaro May 2, 2025
3e50e9f
Implement parser
soutaro May 2, 2025
8746b6c
Allow `skip` as the param name
soutaro May 2, 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
Prev Previous commit
Next Next commit
Hide id_table struct (#27)
  • Loading branch information
st0012 authored Mar 28, 2025
commit bb5e560ad3f48f838df24a215ae58ee7966d088f
15 changes: 2 additions & 13 deletions include/rbs/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@
#include <stdbool.h>
#include <stddef.h>

/**
* id_table represents a set of RBS constant IDs.
* This is used to manage the set of bound variables.
* */
typedef struct id_table {
size_t size;
size_t count;
rbs_constant_id_t *ids;
struct id_table *next;
} id_table;

/**
* comment represents a sequence of comment lines.
*
Expand Down Expand Up @@ -62,7 +51,7 @@ typedef struct {
token next_token2; /* The second lookahead token */
token next_token3; /* The third lookahead token */

id_table *vars; /* Known type variables */
struct id_table *vars; /* Known type variables */
comment *last_comment; /* Last read comment */

rbs_constant_pool_t constant_pool;
Expand All @@ -86,7 +75,7 @@ typedef struct {
* end
* ```
* */
id_table *parser_push_typevar_table(parserstate *state, bool reset);
void parser_push_typevar_table(parserstate *state, bool reset);

/**
* Insert new type variable into the latest table.
Expand Down
15 changes: 12 additions & 3 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ typedef struct {
rbs_node_t *rest_keywords;
} method_params;

/**
* id_table represents a set of RBS constant IDs.
* This is used to manage the set of bound variables.
* */
typedef struct id_table {
size_t size;
size_t count;
rbs_constant_id_t *ids;
struct id_table *next;
} id_table;

static bool rbs_is_untyped_params(method_params *params) {
return params->required_positionals == NULL;
}
Expand Down Expand Up @@ -3250,7 +3261,7 @@ id_table *alloc_reset_table(rbs_allocator_t *allocator) {
return table;
}

id_table *parser_push_typevar_table(parserstate *state, bool reset) {
void parser_push_typevar_table(parserstate *state, bool reset) {
if (reset) {
id_table *table = alloc_reset_table(&state->allocator);
table->next = state->vars;
Expand All @@ -3260,8 +3271,6 @@ id_table *parser_push_typevar_table(parserstate *state, bool reset) {
id_table *table = alloc_empty_table(&state->allocator);
table->next = state->vars;
state->vars = table;

return table;
}

NODISCARD
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy