File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ! scripts
Original file line number Diff line number Diff line change 1+ const debugInfoPath = process . argv [ 2 ] ;
2+ const function_id = Number ( process . argv [ 3 ] ) ;
3+ const pc_index = Number ( process . argv [ 4 ] - 1 ) ;
4+
5+ if ( ! debugInfoPath ) {
6+ console . error ( 'Please provide the debug info path as the first argument.' ) ;
7+ process . exit ( 1 ) ;
8+ }
9+ if ( isNaN ( function_id ) || isNaN ( pc_index ) ) {
10+ console . error ( 'Please provide the valid function_id and pc_index as the second and third arguments.' ) ;
11+ process . exit ( 1 ) ;
12+ }
13+
14+ const debugInfo = await import ( debugInfoPath , {
15+ with : { type : 'json' } ,
16+ } ) ;
17+
18+ /** @typedef {{line: number, column: number} } Position */
19+ /**@typedef {{line_col: Position[], function_id: number, function_name: string} } FunctionInfo */
20+ /**@typedef {{function_info: FunctionInfo[]} } DebugInfo */
21+
22+ /** @type {DebugInfo } */
23+ const { function_info } = debugInfo . default . lepusNG_debug_info ;
24+
25+ // Find the `function_id` is `function_id`
26+ const functionInfo = function_info . find ( ( info ) => info . function_id === function_id ) ;
27+ if ( ! functionInfo ) {
28+ console . error ( `Can not find the function_info with function_id: ${ function_id } ` ) ;
29+ process . exit ( 1 ) ;
30+ }
31+
32+ // Find the `pc_index` is `pc_index`
33+ const position = functionInfo . line_col [ pc_index ] ;
34+ if ( ! position ) {
35+ console . error ( `Can not find the position with pc_index: ${ pc_index } ` ) ;
36+ process . exit ( 1 ) ;
37+ }
38+
39+ console . log ( `The position of function_id: ${ function_id } , pc_index: ${ pc_index } is ${ position . line } :${ position . column } ` ) ;
Original file line number Diff line number Diff line change 11{
22 "name" : " @lynx-js/skill-reactlynx-best-practice" ,
33 "version" : " 1.0.0" ,
4- "private" : true ,
54 "type" : " module" ,
65 "files" : [
76 " SKILL.md" ,
You can’t perform that action at this time.
0 commit comments