@@ -22,14 +22,14 @@ pub struct CIntrinsic<'a> {
2222}
2323
2424impl < ' a > CIntrinsic < ' a > {
25- pub fn new ( node : Node , source : & ' a String ) -> Self {
25+ pub fn new ( node : Node , source : & ' a str ) -> Self {
2626 // Take an intrinsic definition for example:
27- //
27+ //
2828 // static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_make(uint32_t __c0, uint32_t __c1, uint32_t __c2, uint32_t __c3) {...}
29- //
29+ //
3030 // For a C intrinsic, the immediate children
3131 // would have their grammar names as:
32- //
32+ //
3333 // "storage_class_specifier" (which is `static`)
3434 // "storage_class_specifier" (which is `__inline__`)
3535 // "identifier" (which is `v128_t`. The parser doesn't recognize that it is a type, instead thinks that it is an identifier)
@@ -54,7 +54,7 @@ impl<'a> CIntrinsic<'a> {
5454
5555 // The immediate children of the `function_declarator` node would have
5656 // their grammar as follows:
57- //
57+ //
5858 // "identifier" (which is the intrinsic name)
5959 // "parameter_list" (which is the arguments to the intrinsic)
6060 let declarator_node = node
@@ -64,27 +64,27 @@ impl<'a> CIntrinsic<'a> {
6464
6565 // The immediate children of a `parameter_list` node would have
6666 // their grammar as follows (assuming 2 arguments):
67- //
67+ //
6868 // "(" -> The opening bracket that denotes the start of the arguments definition
6969 // "parameter_declaration" -> The definition for the first argument
7070 // "," -> The comma that separates the first and the second arguments
7171 // "parameter_declaration" -> The definition for the first argument
7272 // ")" -> The closing bracket that denotes the start of the arguments definition
73- //
73+ //
7474 // Each node with grammar name as `parameter_declaration` could have their children as
7575 // (incase of `int x`):
7676 // 1. "primitive_type" -> Points to `int`
7777 // 2. "indentifier" -> Points to `x`
78- //
78+ //
7979 // or have (incase of `v128_t x`):
8080 // 1. "identifier" -> Points to `v128_t` which is actually a type (but the parser is unaware of it)
8181 // 2. "identifier" -> Points to `x`
82- //
82+ //
8383 // or have (incase of `const void *__mem`):
8484 // 1. "type_qualifier" -> Points to `const`
8585 // 2. "primitive_type" -> Points to `void`
8686 // 3. "pointer_declarator" -> breaks down into "*" and "identifier" (which is `__mem`)
87- //
87+ //
8888 let intrinsic_name = source
8989 . get (
9090 declarator_node
@@ -108,9 +108,9 @@ impl<'a> CIntrinsic<'a> {
108108 // Since the type could be identified as either `primitive_type, `indentifier`,
109109 // or a combination of `type_qualifier`, `primitive_type` and `*` (in the case of "const void *")
110110 // this approach first calculates the end index (which is right before the start of an argument variable)
111- //
111+ //
112112 // And then searches backwards until it finds a break (either a comma
113- // or the opening bracket). The entire portion contained within this range
113+ // or the opening bracket). The entire portion contained within this range
114114 // is then considered as the type of the argument.
115115 let end_index = arg_name_node. byte_range ( ) . start ;
116116 let start_index = source
@@ -149,10 +149,10 @@ impl<'a> CIntrinsic<'a> {
149149}
150150
151151impl < ' a > RustIntrinsic < ' a > {
152- pub fn new ( node : Node , source : & ' a String ) -> Self {
152+ pub fn new ( node : Node , source : & ' a str ) -> Self {
153153 // For a Rust intrinsic, the immediate children
154154 // would have their grammar names as:
155- //
155+ //
156156 // 1. "visibility_modifier" (for `pub`)
157157 // 2. "function_modifiers" (for `unsafe`. May not always be present)
158158 // 3. "fn" (the actual keyword `fn`)
@@ -162,7 +162,7 @@ impl<'a> RustIntrinsic<'a> {
162162 // 7. "->" (the arrow used to specify return type)
163163 // 8. "identifier" (the return type of the function)
164164 // 9. "block" (the body of the function)
165- //
165+ //
166166 let mut cursor = node. walk ( ) ;
167167 let intrinsic_name = source
168168 . get (
@@ -196,14 +196,13 @@ impl<'a> RustIntrinsic<'a> {
196196 if let Some ( generic_args) = generic_args {
197197 // The children of this node have their grammar_names as the following
198198 // (assuming 2 generic arguments):
199- //
199+ //
200200 // "<" (The opening angle bracket that starts the generic arguments definition)
201201 // "const_parameter" (The first const generic argument)
202202 // "," (The comma that denotes the end of definition of the first const generic argument)
203203 // "const_parameter" (The second const generic argument)
204204 // ">" (The closing angle bracket that concludes the generic arguments definition)
205- //
206-
205+ //
207206 ( generic_arg_names, generic_arg_types) = generic_args
208207 . children ( & mut cursor)
209208 . filter ( |arg| arg. grammar_name ( ) == "const_parameter" )
@@ -225,13 +224,12 @@ impl<'a> RustIntrinsic<'a> {
225224 if let Some ( args) = args {
226225 // The children of this node have their grammar_names as the following
227226 // (assuming 2 generic arguments):
228- //
227+ //
229228 // "(" (The opening circular bracket that starts the arguments definition)
230229 // "parameter" (The first argument)
231230 // "," (The comma that denotes the end of definition of the first argument)
232231 // "parameter" (The second argument)
233232 // ")" (The closing circular bracket that concludes the arguments definition)
234- //
235233 ( arg_names, arg_types) = args
236234 . children ( & mut cursor)
237235 . filter ( |arg| arg. grammar_name ( ) == "parameter" )
0 commit comments