v / vlib / v2 / gen / arm64 / tests / flat_ast_import_edges.v
29 lines · 28 sloc · 531 bytes · 34038bec7b93f4e3ddbbdcbe88ea21f4693eee43
Raw
1import v2.ast
2
3fn main() {
4 file := ast.File{
5 name: @FILE
6 mod: 'main'
7 imports: [
8 ast.ImportStmt{
9 name: 'v2.pref'
10 alias: 'pref'
11 },
12 ]
13 stmts: [
14 ast.Stmt(ast.ImportStmt{
15 name: 'v2.pref'
16 alias: 'pref'
17 }),
18 ]
19 }
20 flat := ast.flatten_files([file])
21 file_node := flat.nodes[flat.files[0].file_id]
22 imports := flat.file_cursor(0).imports().import_stmts()
23 println(file_node.edge_count)
24 println(imports.len)
25 if imports.len > 0 {
26 println(imports[0].name)
27 println(imports[0].alias)
28 }
29}
30