File tree 3 files changed +25
-5
lines changed
3 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import os
5
5
6
6
type Decls = FuncDecl | GenDecl
7
7
8
+ type MapVal = Ident | InterfaceType | SelectorExpr
9
+
8
10
type Expr = InvalidExpr
9
11
| ArrayType
10
12
| FuncType
@@ -108,7 +110,7 @@ struct ArrayType {
108
110
struct MapType {
109
111
node_type string @[json: '_type' ]
110
112
key Expr @[json: 'Key' ]
111
- val Expr @[json: 'Value' ]
113
+ val MapVal @[json: 'Value' ]
112
114
}
113
115
114
116
struct ChanType {
Original file line number Diff line number Diff line change @@ -188,7 +188,14 @@ fn (mut app App) map_type(node MapType) {
188
188
app.gen ('map[' )
189
189
app.expr (node.key)
190
190
app.gen (']' )
191
- app.expr (node.val)
191
+ match node.val {
192
+ Ident, InterfaceType {
193
+ app.typ (node.val)
194
+ }
195
+ SelectorExpr {
196
+ app.expr (node.val)
197
+ }
198
+ }
192
199
}
193
200
194
201
fn (mut app App) chan_type (node ChanType) {
Original file line number Diff line number Diff line change @@ -112,21 +112,32 @@ fn (mut app App) const_decl(spec ValueSpec) {
112
112
const master_module_path = 'g.yxqyang.asia.evanw.esbuild.internal' // TODO hardcoded
113
113
114
114
fn (mut app App) import_spec (spec ImportSpec) {
115
- name := spec.path.value.replace ('"' , '' ).replace ('/' , '.' )
115
+ mut name := spec.path.value.replace ('"' , '' ).replace ('/' , '.' )
116
116
// Skip modules that don't exist in V (fmt, strings etc)
117
117
if name in nonexistent_modules {
118
118
return
119
119
}
120
+ if name == 'archive.zip' {
121
+ name = 'compress.zip'
122
+ }
120
123
if name.starts_with (master_module_path) {
121
124
n := name.replace (master_module_path, '' )
122
- app.genln ('import ${n[1..]} // local module' )
125
+ app.gen ('import ${n[1..]} ' )
126
+ if spec.name.name != '' {
127
+ app.gen (' as ${spec.name.name} ' )
128
+ }
129
+ app.genln (' // local module' )
123
130
return
124
131
}
125
132
// TODO a temp hack
126
133
if name.starts_with ('github' ) {
127
134
return
128
135
}
129
- app.genln ('import ${name} ' )
136
+ app.gen ('import ${name} ' )
137
+ if spec.name.name != '' {
138
+ app.gen (' as ${spec.name.name} ' )
139
+ }
140
+ app.genln ('' )
130
141
}
131
142
132
143
fn (mut app App) struct_decl (struct_name string , spec StructType) {
You can’t perform that action at this time.
0 commit comments