@@ -217,10 +217,6 @@ func (f *cgoFile) createASTNode(name string, c clangCursor) (ast.Node, any) {
217217 case C .CXCursor_FunctionDecl :
218218 cursorType := C .tinygo_clang_getCursorType (c )
219219 numArgs := int (C .tinygo_clang_Cursor_getNumArguments (c ))
220- obj := & ast.Object {
221- Kind : ast .Fun ,
222- Name : "_Cgo_" + name ,
223- }
224220 exportName := name
225221 localName := name
226222 var stringSignature string
@@ -258,7 +254,6 @@ func (f *cgoFile) createASTNode(name string, c clangCursor) (ast.Node, any) {
258254 Name : & ast.Ident {
259255 NamePos : pos ,
260256 Name : "_Cgo_" + localName ,
261- Obj : obj ,
262257 },
263258 Type : & ast.FuncType {
264259 Func : pos ,
@@ -295,11 +290,6 @@ func (f *cgoFile) createASTNode(name string, c clangCursor) (ast.Node, any) {
295290 {
296291 NamePos : pos ,
297292 Name : argName ,
298- Obj : & ast.Object {
299- Kind : ast .Var ,
300- Name : argName ,
301- Decl : decl ,
302- },
303293 },
304294 },
305295 Type : f .makeDecayingASTType (argType , pos ),
@@ -315,7 +305,6 @@ func (f *cgoFile) createASTNode(name string, c clangCursor) (ast.Node, any) {
315305 },
316306 }
317307 }
318- obj .Decl = decl
319308 return decl , stringSignature
320309 case C .CXCursor_StructDecl , C .CXCursor_UnionDecl :
321310 typ := f .makeASTRecordType (c , pos )
@@ -325,39 +314,27 @@ func (f *cgoFile) createASTNode(name string, c clangCursor) (ast.Node, any) {
325314 // Convert to a single-field struct type.
326315 typeExpr = f .makeUnionField (typ )
327316 }
328- obj := & ast.Object {
329- Kind : ast .Typ ,
330- Name : typeName ,
331- }
332317 typeSpec := & ast.TypeSpec {
333318 Name : & ast.Ident {
334319 NamePos : typ .pos ,
335320 Name : typeName ,
336- Obj : obj ,
337321 },
338322 Type : typeExpr ,
339323 }
340- obj .Decl = typeSpec
341324 return typeSpec , typ
342325 case C .CXCursor_TypedefDecl :
343326 typeName := "_Cgo_" + name
344327 underlyingType := C .tinygo_clang_getTypedefDeclUnderlyingType (c )
345- obj := & ast.Object {
346- Kind : ast .Typ ,
347- Name : typeName ,
348- }
349328 typeSpec := & ast.TypeSpec {
350329 Name : & ast.Ident {
351330 NamePos : pos ,
352331 Name : typeName ,
353- Obj : obj ,
354332 },
355333 Type : f .makeASTType (underlyingType , pos ),
356334 }
357335 if underlyingType .kind != C .CXType_Enum {
358336 typeSpec .Assign = pos
359337 }
360- obj .Decl = typeSpec
361338 return typeSpec , nil
362339 case C .CXCursor_VarDecl :
363340 cursorType := C .tinygo_clang_getCursorType (c )
@@ -376,19 +353,13 @@ func (f *cgoFile) createASTNode(name string, c clangCursor) (ast.Node, any) {
376353 },
377354 },
378355 }
379- obj := & ast.Object {
380- Kind : ast .Var ,
381- Name : "_Cgo_" + name ,
382- }
383356 valueSpec := & ast.ValueSpec {
384357 Names : []* ast.Ident {{
385358 NamePos : pos ,
386359 Name : "_Cgo_" + name ,
387- Obj : obj ,
388360 }},
389361 Type : typeExpr ,
390362 }
391- obj .Decl = valueSpec
392363 gen .Specs = append (gen .Specs , valueSpec )
393364 return gen , nil
394365 case C .CXCursor_MacroDefinition :
@@ -405,39 +376,27 @@ func (f *cgoFile) createASTNode(name string, c clangCursor) (ast.Node, any) {
405376 Lparen : token .NoPos ,
406377 Rparen : token .NoPos ,
407378 }
408- obj := & ast.Object {
409- Kind : ast .Con ,
410- Name : "_Cgo_" + name ,
411- }
412379 valueSpec := & ast.ValueSpec {
413380 Names : []* ast.Ident {{
414381 NamePos : pos ,
415382 Name : "_Cgo_" + name ,
416- Obj : obj ,
417383 }},
418384 Values : []ast.Expr {expr },
419385 }
420- obj .Decl = valueSpec
421386 gen .Specs = append (gen .Specs , valueSpec )
422387 return gen , nil
423388 case C .CXCursor_EnumDecl :
424- obj := & ast.Object {
425- Kind : ast .Typ ,
426- Name : "_Cgo_" + name ,
427- }
428389 underlying := C .tinygo_clang_getEnumDeclIntegerType (c )
429390 // TODO: gc's CGo implementation uses types such as `uint32` for enums
430391 // instead of types such as C.int, which are used here.
431392 typeSpec := & ast.TypeSpec {
432393 Name : & ast.Ident {
433394 NamePos : pos ,
434395 Name : "_Cgo_" + name ,
435- Obj : obj ,
436396 },
437397 Assign : pos ,
438398 Type : f .makeASTType (underlying , pos ),
439399 }
440- obj .Decl = typeSpec
441400 return typeSpec , nil
442401 case C .CXCursor_EnumConstantDecl :
443402 value := C .tinygo_clang_getEnumConstantDeclValue (c )
@@ -452,19 +411,13 @@ func (f *cgoFile) createASTNode(name string, c clangCursor) (ast.Node, any) {
452411 Lparen : token .NoPos ,
453412 Rparen : token .NoPos ,
454413 }
455- obj := & ast.Object {
456- Kind : ast .Con ,
457- Name : "_Cgo_" + name ,
458- }
459414 valueSpec := & ast.ValueSpec {
460415 Names : []* ast.Ident {{
461416 NamePos : pos ,
462417 Name : "_Cgo_" + name ,
463- Obj : obj ,
464418 }},
465419 Values : []ast.Expr {expr },
466420 }
467- obj .Decl = valueSpec
468421 gen .Specs = append (gen .Specs , valueSpec )
469422 return gen , nil
470423 default :
@@ -956,22 +909,16 @@ func (p *cgoPackage) getIntegerType(name string, cursor clangCursor) *ast.TypeSp
956909 }
957910
958911 // Construct an *ast.TypeSpec for this type.
959- obj := & ast.Object {
960- Kind : ast .Typ ,
961- Name : name ,
962- }
963912 spec := & ast.TypeSpec {
964913 Name : & ast.Ident {
965914 NamePos : pos ,
966915 Name : name ,
967- Obj : obj ,
968916 },
969917 Type : & ast.Ident {
970918 NamePos : pos ,
971919 Name : goName ,
972920 },
973921 }
974- obj .Decl = spec
975922 return spec
976923}
977924
@@ -1104,7 +1051,6 @@ func tinygo_clang_struct_visitor(c, parent C.GoCXCursor, client_data C.CXClientD
11041051 pos : prevField .Names [0 ].NamePos ,
11051052 })
11061053 prevField .Names [0 ].Name = bitfieldName
1107- prevField .Names [0 ].Obj .Name = bitfieldName
11081054 }
11091055 prevBitfield := & (* bitfieldList )[len (* bitfieldList )- 1 ]
11101056 prevBitfield .endBit = bitfieldOffset
@@ -1121,11 +1067,6 @@ func tinygo_clang_struct_visitor(c, parent C.GoCXCursor, client_data C.CXClientD
11211067 {
11221068 NamePos : pos ,
11231069 Name : name ,
1124- Obj : & ast.Object {
1125- Kind : ast .Var ,
1126- Name : name ,
1127- Decl : field ,
1128- },
11291070 },
11301071 }
11311072 fieldList .List = append (fieldList .List , field )
0 commit comments