llcppsigfetch:dump node type for unmarshal

This commit is contained in:
luoliwoshang
2024-08-28 18:50:05 +08:00
parent 7d0b47c5cb
commit 021ddefb10
11 changed files with 761 additions and 1 deletions

View File

@@ -2,50 +2,67 @@
TestClassDecl Case 1: TestClassDecl Case 1:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "A" "Name": "A"
}, },
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 3, "Tag": 3,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "a" "Name": "a"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "b" "Name": "b"
}] }]
}] }]
@@ -61,104 +78,139 @@ TestClassDecl Case 1:
TestClassDecl Case 2: TestClassDecl Case 2:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "A" "Name": "A"
}, },
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 3, "Tag": 3,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": true, "IsStatic": true,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "a" "Name": "a"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "b" "Name": "b"
}] }]
}] }]
}, },
"Methods": [{ "Methods": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "A" "Name": "A"
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 0, "Access": 0,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "a" "Name": "a"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 8, "Kind": 8,
"Flags": 16 "Flags": 16
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 0, "Access": 0,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "b" "Name": "b"
}] }]
}] }]
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 8, "Kind": 8,
"Flags": 0 "Flags": 0
} }
@@ -182,40 +234,55 @@ TestClassDecl Case 2:
TestClassDecl Case 3: TestClassDecl Case 3:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "A" "Name": "A"
}, },
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 3, "Tag": 3,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Methods": [{ "Methods": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "A" "Name": "A"
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "A" "Name": "A"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -229,23 +296,31 @@ TestClassDecl Case 3:
"IsVirtual": false, "IsVirtual": false,
"IsOverride": false "IsOverride": false
}, { }, {
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "A" "Name": "A"
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "A" "Name": "A"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -259,23 +334,31 @@ TestClassDecl Case 3:
"IsVirtual": false, "IsVirtual": false,
"IsOverride": false "IsOverride": false
}, { }, {
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "A" "Name": "A"
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "~A" "Name": "~A"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -289,23 +372,31 @@ TestClassDecl Case 3:
"IsVirtual": false, "IsVirtual": false,
"IsOverride": false "IsOverride": false
}, { }, {
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "A" "Name": "A"
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -329,40 +420,55 @@ TestClassDecl Case 3:
TestClassDecl Case 4: TestClassDecl Case 4:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "Base" "Name": "Base"
}, },
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 3, "Tag": 3,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Methods": [{ "Methods": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "Base" "Name": "Base"
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "Base" "Name": "Base"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -376,23 +482,31 @@ TestClassDecl Case 4:
"IsVirtual": false, "IsVirtual": false,
"IsOverride": false "IsOverride": false
}, { }, {
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "Base" "Name": "Base"
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "~Base" "Name": "~Base"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -406,23 +520,31 @@ TestClassDecl Case 4:
"IsVirtual": true, "IsVirtual": true,
"IsOverride": false "IsOverride": false
}, { }, {
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "Base" "Name": "Base"
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -438,39 +560,53 @@ TestClassDecl Case 4:
}] }]
} }
}, { }, {
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "Derived" "Name": "Derived"
}, },
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 3, "Tag": 3,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Methods": [{ "Methods": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "Derived" "Name": "Derived"
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "Derived" "Name": "Derived"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -484,23 +620,31 @@ TestClassDecl Case 4:
"IsVirtual": false, "IsVirtual": false,
"IsOverride": false "IsOverride": false
}, { }, {
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "Derived" "Name": "Derived"
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "~Derived" "Name": "~Derived"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -514,23 +658,31 @@ TestClassDecl Case 4:
"IsVirtual": true, "IsVirtual": true,
"IsOverride": true "IsOverride": true
}, { }, {
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "Derived" "Name": "Derived"
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -554,49 +706,67 @@ TestClassDecl Case 4:
TestClassDecl Case 5: TestClassDecl Case 5:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "A" "Name": "A"
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "Foo" "Name": "Foo"
}, },
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 3, "Tag": 3,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Methods": [] "Methods": []
} }
}, { }, {
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "ScopingExpr",
"X": { "X": {
"_Type": "Ident",
"Name": "Foo" "Name": "Foo"
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "A" "Name": "A"
} }
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "bar" "Name": "bar"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }

View File

@@ -2,22 +2,30 @@
TestDoc Case 1: TestDoc Case 1:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -39,22 +47,30 @@ TestDoc Case 1:
TestDoc Case 2: TestDoc Case 2:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -76,24 +92,33 @@ TestDoc Case 2:
TestDoc Case 3: TestDoc Case 3:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [{ "List": [{
"_Type": "Comment",
"Text": "/// doc" "Text": "/// doc"
}] }]
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -115,24 +140,33 @@ TestDoc Case 3:
TestDoc Case 4: TestDoc Case 4:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [{ "List": [{
"_Type": "Comment",
"Text": "/** doc */" "Text": "/** doc */"
}] }]
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -154,24 +188,33 @@ TestDoc Case 4:
TestDoc Case 5: TestDoc Case 5:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [{ "List": [{
"_Type": "Comment",
"Text": "/*! doc */" "Text": "/*! doc */"
}] }]
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -193,26 +236,36 @@ TestDoc Case 5:
TestDoc Case 6: TestDoc Case 6:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [{ "List": [{
"_Type": "Comment",
"Text": "/// doc 1" "Text": "/// doc 1"
}, { }, {
"_Type": "Comment",
"Text": "/// doc 2" "Text": "/// doc 2"
}] }]
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -234,26 +287,36 @@ TestDoc Case 6:
TestDoc Case 7: TestDoc Case 7:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [{ "List": [{
"_Type": "Comment",
"Text": "/*! doc 1 */" "Text": "/*! doc 1 */"
}, { }, {
"_Type": "Comment",
"Text": "/*! doc 2 */" "Text": "/*! doc 2 */"
}] }]
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -275,26 +338,36 @@ TestDoc Case 7:
TestDoc Case 8: TestDoc Case 8:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [{ "List": [{
"_Type": "Comment",
"Text": "/** doc 1 */" "Text": "/** doc 1 */"
}, { }, {
"_Type": "Comment",
"Text": "/** doc 1 */" "Text": "/** doc 1 */"
}] }]
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -316,30 +389,42 @@ TestDoc Case 8:
TestDoc Case 9: TestDoc Case 9:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [{ "List": [{
"_Type": "Comment",
"Text": "/**" "Text": "/**"
}, { }, {
"_Type": "Comment",
"Text": " * doc 1" "Text": " * doc 1"
}, { }, {
"_Type": "Comment",
"Text": " * doc 2" "Text": " * doc 2"
}, { }, {
"_Type": "Comment",
"Text": " */" "Text": " */"
}] }]
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }

View File

@@ -2,39 +2,54 @@
TestEnumDecl Case 1: TestEnumDecl Case 1:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "EnumTypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "Foo" "Name": "Foo"
}, },
"Type": { "Type": {
"_Type": "EnumType",
"Items": [{ "Items": [{
"_Type": "EnumItem",
"Name": { "Name": {
"_Type": "Ident",
"Name": "a" "Name": "a"
}, },
"Value": { "Value": {
"_Type": "BasicLit",
"Kind": 0, "Kind": 0,
"Value": "0" "Value": "0"
} }
}, { }, {
"_Type": "EnumItem",
"Name": { "Name": {
"_Type": "Ident",
"Name": "b" "Name": "b"
}, },
"Value": { "Value": {
"_Type": "BasicLit",
"Kind": 0, "Kind": 0,
"Value": "1" "Value": "1"
} }
}, { }, {
"_Type": "EnumItem",
"Name": { "Name": {
"_Type": "Ident",
"Name": "c" "Name": "c"
}, },
"Value": { "Value": {
"_Type": "BasicLit",
"Kind": 0, "Kind": 0,
"Value": "2" "Value": "2"
} }
@@ -49,39 +64,54 @@ TestEnumDecl Case 1:
TestEnumDecl Case 2: TestEnumDecl Case 2:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "EnumTypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "Foo" "Name": "Foo"
}, },
"Type": { "Type": {
"_Type": "EnumType",
"Items": [{ "Items": [{
"_Type": "EnumItem",
"Name": { "Name": {
"_Type": "Ident",
"Name": "a" "Name": "a"
}, },
"Value": { "Value": {
"_Type": "BasicLit",
"Kind": 0, "Kind": 0,
"Value": "1" "Value": "1"
} }
}, { }, {
"_Type": "EnumItem",
"Name": { "Name": {
"_Type": "Ident",
"Name": "b" "Name": "b"
}, },
"Value": { "Value": {
"_Type": "BasicLit",
"Kind": 0, "Kind": 0,
"Value": "2" "Value": "2"
} }
}, { }, {
"_Type": "EnumItem",
"Name": { "Name": {
"_Type": "Ident",
"Name": "c" "Name": "c"
}, },
"Value": { "Value": {
"_Type": "BasicLit",
"Kind": 0, "Kind": 0,
"Value": "4" "Value": "4"
} }
@@ -96,39 +126,54 @@ TestEnumDecl Case 2:
TestEnumDecl Case 3: TestEnumDecl Case 3:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "EnumTypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "Foo" "Name": "Foo"
}, },
"Type": { "Type": {
"_Type": "EnumType",
"Items": [{ "Items": [{
"_Type": "EnumItem",
"Name": { "Name": {
"_Type": "Ident",
"Name": "a" "Name": "a"
}, },
"Value": { "Value": {
"_Type": "BasicLit",
"Kind": 0, "Kind": 0,
"Value": "1" "Value": "1"
} }
}, { }, {
"_Type": "EnumItem",
"Name": { "Name": {
"_Type": "Ident",
"Name": "b" "Name": "b"
}, },
"Value": { "Value": {
"_Type": "BasicLit",
"Kind": 0, "Kind": 0,
"Value": "2" "Value": "2"
} }
}, { }, {
"_Type": "EnumItem",
"Name": { "Name": {
"_Type": "Ident",
"Name": "c" "Name": "c"
}, },
"Value": { "Value": {
"_Type": "BasicLit",
"Kind": 0, "Kind": 0,
"Value": "3" "Value": "3"
} }

View File

@@ -2,22 +2,30 @@
TestFuncDecl Case 1: TestFuncDecl Case 1:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -39,38 +47,51 @@ TestFuncDecl Case 1:
TestFuncDecl Case 2: TestFuncDecl Case 2:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 0, "Access": 0,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "a" "Name": "a"
}] }]
}] }]
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -92,21 +113,30 @@ TestFuncDecl Case 2:
TestFuncDecl Case 3: TestFuncDecl Case 3:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "Variadic"
}, },
"Doc": null, "Doc": null,
"Comment": null, "Comment": null,
@@ -114,24 +144,30 @@ TestFuncDecl Case 3:
"Access": 0, "Access": 0,
"Names": [] "Names": []
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 0, "Access": 0,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "a" "Name": "a"
}] }]
}] }]
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -153,55 +189,74 @@ TestFuncDecl Case 3:
TestFuncDecl Case 4: TestFuncDecl Case 4:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 0, "Access": 0,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "a" "Name": "a"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 8, "Kind": 8,
"Flags": 16 "Flags": 16
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 0, "Access": 0,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "b" "Name": "b"
}] }]
}] }]
}, },
"Ret": { "Ret": {
"_Type": "PointerType",
"X": { "X": {
"_Type": "BuiltinType",
"Kind": 8, "Kind": 8,
"Flags": 0 "Flags": 0
} }
@@ -224,54 +279,72 @@ TestFuncDecl Case 4:
TestFuncDecl Case 5: TestFuncDecl Case 5:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "add" "Name": "add"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 0, "Access": 0,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "a" "Name": "a"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 0, "Access": 0,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "b" "Name": "b"
}] }]
}] }]
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
} }

View File

@@ -2,22 +2,30 @@
TestScope Case 1: TestScope Case 1:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -39,24 +47,33 @@ TestScope Case 1:
TestScope Case 2: TestScope Case 2:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "a" "Name": "a"
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -78,29 +95,40 @@ TestScope Case 2:
TestScope Case 3: TestScope Case 3:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "ScopingExpr",
"X": { "X": {
"_Type": "Ident",
"Name": "b" "Name": "b"
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "a" "Name": "a"
} }
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -122,40 +150,55 @@ TestScope Case 3:
TestScope Case 4: TestScope Case 4:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "a" "Name": "a"
}, },
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 3, "Tag": 3,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Methods": [{ "Methods": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "a" "Name": "a"
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }
@@ -179,47 +222,65 @@ TestScope Case 4:
TestScope Case 5: TestScope Case 5:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "a" "Name": "a"
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "b" "Name": "b"
}, },
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 3, "Tag": 3,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Methods": [{ "Methods": [{
"_Type": "FuncDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": { "Parent": {
"_Type": "ScopingExpr",
"X": { "X": {
"_Type": "Ident",
"Name": "b" "Name": "b"
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "a" "Name": "a"
} }
}, },
"Name": { "Name": {
"_Type": "Ident",
"Name": "foo" "Name": "foo"
}, },
"Type": { "Type": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [] "List": []
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 0, "Kind": 0,
"Flags": 0 "Flags": 0
} }

View File

@@ -2,32 +2,43 @@
TestStructDecl Case 1: TestStructDecl Case 1:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": null, "Name": null,
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 0, "Tag": 0,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "a" "Name": "a"
}] }]
}] }]
@@ -43,50 +54,67 @@ TestStructDecl Case 1:
TestStructDecl Case 2: TestStructDecl Case 2:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "A" "Name": "A"
}, },
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 0, "Tag": 0,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "a" "Name": "a"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "b" "Name": "b"
}] }]
}] }]
@@ -102,50 +130,67 @@ TestStructDecl Case 2:
TestStructDecl Case 3: TestStructDecl Case 3:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "A" "Name": "A"
}, },
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 0, "Tag": 0,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "a" "Name": "a"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "b" "Name": "b"
}] }]
}] }]
@@ -161,42 +206,60 @@ TestStructDecl Case 3:
TestStructDecl Case 4: TestStructDecl Case 4:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "A" "Name": "A"
}, },
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 0, "Tag": 0,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "a" "Name": "a"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "PointerType",
"X": { "X": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
@@ -206,7 +269,9 @@ TestStructDecl Case 4:
"Access": 0, "Access": 0,
"Names": [] "Names": []
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
@@ -218,20 +283,24 @@ TestStructDecl Case 4:
}] }]
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
} }
} }
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "Foo" "Name": "Foo"
}] }]
}] }]
@@ -247,86 +316,116 @@ TestStructDecl Case 4:
TestStructDecl Case 5: TestStructDecl Case 5:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "Person" "Name": "Person"
}, },
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 0, "Tag": 0,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "age" "Name": "age"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 0, "Tag": 0,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "year" "Name": "year"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "day" "Name": "day"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "month" "Name": "month"
}] }]
}] }]
@@ -334,14 +433,17 @@ TestStructDecl Case 5:
"Methods": [] "Methods": []
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "birthday" "Name": "birthday"
}] }]
}] }]

View File

@@ -2,18 +2,24 @@
TestTypeDefDecl Case 1: TestTypeDefDecl Case 1:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypedefDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "INT" "Name": "INT"
}, },
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
} }
@@ -26,33 +32,44 @@ TestTypeDefDecl Case 1:
TestTypeDefDecl Case 2: TestTypeDefDecl Case 2:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypedefDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "INT" "Name": "INT"
}, },
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
} }
}, { }, {
"_Type": "TypedefDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "STANDARD_INT" "Name": "STANDARD_INT"
}, },
"Type": { "Type": {
"_Type": "Ident",
"Name": "INT" "Name": "INT"
} }
}], }],
@@ -64,22 +81,32 @@ TestTypeDefDecl Case 2:
TestTypeDefDecl Case 3: TestTypeDefDecl Case 3:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypedefDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "Foo" "Name": "Foo"
}, },
"Type": { "Type": {
"_Type": "PointerType",
"X": { "X": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
@@ -89,7 +116,9 @@ TestTypeDefDecl Case 3:
"Access": 0, "Access": 0,
"Names": [] "Names": []
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
@@ -99,7 +128,9 @@ TestTypeDefDecl Case 3:
"Access": 0, "Access": 0,
"Names": [] "Names": []
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "Variadic"
}, },
"Doc": null, "Doc": null,
"Comment": null, "Comment": null,
@@ -109,6 +140,7 @@ TestTypeDefDecl Case 3:
}] }]
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
} }

View File

@@ -2,48 +2,64 @@
TestUnionDecl Case 1: TestUnionDecl Case 1:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": null, "Name": null,
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 1, "Tag": 1,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "a" "Name": "a"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "b" "Name": "b"
}] }]
}] }]
@@ -59,50 +75,67 @@ TestUnionDecl Case 1:
TestUnionDecl Case 2: TestUnionDecl Case 2:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "A" "Name": "A"
}, },
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 1, "Tag": 1,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "a" "Name": "a"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "b" "Name": "b"
}] }]
}] }]
@@ -118,86 +151,116 @@ TestUnionDecl Case 2:
TestUnionDecl Case 3: TestUnionDecl Case 3:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [{ "decls": [{
"_Type": "TypeDecl",
"Loc": { "Loc": {
"_Type": "Location",
"File": "temp.h" "File": "temp.h"
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Parent": null, "Parent": null,
"Name": { "Name": {
"_Type": "Ident",
"Name": "OuterUnion" "Name": "OuterUnion"
}, },
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 1, "Tag": 1,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "i" "Name": "i"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 8, "Kind": 8,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "f" "Name": "f"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "RecordType",
"Tag": 1, "Tag": 1,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 2, "Kind": 2,
"Flags": 1 "Flags": 1
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "c" "Name": "c"
}] }]
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 32 "Flags": 32
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "s" "Name": "s"
}] }]
}] }]
@@ -205,14 +268,17 @@ TestUnionDecl Case 3:
"Methods": [] "Methods": []
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "inner" "Name": "inner"
}] }]
}] }]

View File

@@ -2,11 +2,14 @@
TestDefine Case 1: TestDefine Case 1:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [], "decls": [],
"includes": [], "includes": [],
"macros": [{ "macros": [{
"_Type": "Macro",
"Name": "DEBUG", "Name": "DEBUG",
"Tokens": [{ "Tokens": [{
"_Type": "Token",
"Token": 3, "Token": 3,
"Lit": "DEBUG" "Lit": "DEBUG"
}] }]
@@ -17,14 +20,18 @@ TestDefine Case 1:
TestDefine Case 2: TestDefine Case 2:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [], "decls": [],
"includes": [], "includes": [],
"macros": [{ "macros": [{
"_Type": "Macro",
"Name": "OK", "Name": "OK",
"Tokens": [{ "Tokens": [{
"_Type": "Token",
"Token": 3, "Token": 3,
"Lit": "OK" "Lit": "OK"
}, { }, {
"_Type": "Token",
"Token": 4, "Token": 4,
"Lit": "1" "Lit": "1"
}] }]
@@ -35,47 +42,62 @@ TestDefine Case 2:
TestDefine Case 3: TestDefine Case 3:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [], "decls": [],
"includes": [], "includes": [],
"macros": [{ "macros": [{
"_Type": "Macro",
"Name": "SQUARE", "Name": "SQUARE",
"Tokens": [{ "Tokens": [{
"_Type": "Token",
"Token": 3, "Token": 3,
"Lit": "SQUARE" "Lit": "SQUARE"
}, { }, {
"_Type": "Token",
"Token": 1, "Token": 1,
"Lit": "(" "Lit": "("
}, { }, {
"_Type": "Token",
"Token": 3, "Token": 3,
"Lit": "x" "Lit": "x"
}, { }, {
"_Type": "Token",
"Token": 1, "Token": 1,
"Lit": ")" "Lit": ")"
}, { }, {
"_Type": "Token",
"Token": 1, "Token": 1,
"Lit": "(" "Lit": "("
}, { }, {
"_Type": "Token",
"Token": 1, "Token": 1,
"Lit": "(" "Lit": "("
}, { }, {
"_Type": "Token",
"Token": 3, "Token": 3,
"Lit": "x" "Lit": "x"
}, { }, {
"_Type": "Token",
"Token": 1, "Token": 1,
"Lit": ")" "Lit": ")"
}, { }, {
"_Type": "Token",
"Token": 1, "Token": 1,
"Lit": "*" "Lit": "*"
}, { }, {
"_Type": "Token",
"Token": 1, "Token": 1,
"Lit": "(" "Lit": "("
}, { }, {
"_Type": "Token",
"Token": 3, "Token": 3,
"Lit": "x" "Lit": "x"
}, { }, {
"_Type": "Token",
"Token": 1, "Token": 1,
"Lit": ")" "Lit": ")"
}, { }, {
"_Type": "Token",
"Token": 1, "Token": 1,
"Lit": ")" "Lit": ")"
}] }]
@@ -86,8 +108,10 @@ TestDefine Case 3:
TestInclude Case 1: TestInclude Case 1:
{ {
"temp.h": { "temp.h": {
"_Type": "File",
"decls": [], "decls": [],
"includes": [{ "includes": [{
"_Type": "Include",
"Path": "foo.h" "Path": "foo.h"
}], }],
"macros": [] "macros": []

View File

@@ -28,16 +28,22 @@ Complex:flags:20 kind:11
Unknown:flags:0 kind:0 Unknown:flags:0 kind:0
Type: char *: Type: char *:
{ {
"_Type": "PointerType",
"X": { "X": {
"_Type": "BuiltinType",
"Kind": 2, "Kind": 2,
"Flags": 1 "Flags": 1
} }
} }
Type: char ***: Type: char ***:
{ {
"_Type": "PointerType",
"X": { "X": {
"_Type": "PointerType",
"X": { "X": {
"_Type": "PointerType",
"X": { "X": {
"_Type": "BuiltinType",
"Kind": 2, "Kind": 2,
"Flags": 1 "Flags": 1
} }
@@ -46,7 +52,9 @@ Type: char ***:
} }
Type: char[]: Type: char[]:
{ {
"_Type": "ArrayType",
"Elt": { "Elt": {
"_Type": "BuiltinType",
"Kind": 2, "Kind": 2,
"Flags": 1 "Flags": 1
}, },
@@ -54,75 +62,97 @@ Type: char[]:
} }
Type: char[10]: Type: char[10]:
{ {
"_Type": "ArrayType",
"Elt": { "Elt": {
"_Type": "BuiltinType",
"Kind": 2, "Kind": 2,
"Flags": 1 "Flags": 1
}, },
"Len": { "Len": {
"_Type": "BasicLit",
"Kind": 0, "Kind": 0,
"Value": "10" "Value": "10"
} }
} }
Type: char[3][4]: Type: char[3][4]:
{ {
"_Type": "ArrayType",
"Elt": { "Elt": {
"_Type": "ArrayType",
"Elt": { "Elt": {
"_Type": "BuiltinType",
"Kind": 2, "Kind": 2,
"Flags": 1 "Flags": 1
}, },
"Len": { "Len": {
"_Type": "BasicLit",
"Kind": 0, "Kind": 0,
"Value": "4" "Value": "4"
} }
}, },
"Len": { "Len": {
"_Type": "BasicLit",
"Kind": 0, "Kind": 0,
"Value": "3" "Value": "3"
} }
} }
Type: int &: Type: int &:
{ {
"_Type": "LvalueRefType",
"X": { "X": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
} }
} }
Type: int &&: Type: int &&:
{ {
"_Type": "LvalueRefType",
"X": { "X": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
} }
} }
Type: Foo: Type: Foo:
{ {
"_Type": "Ident",
"Name": "Foo" "Name": "Foo"
} }
Type: struct Foo: Type: struct Foo:
{ {
"_Type": "TagExpr",
"Name": { "Name": {
"_Type": "Ident",
"Name": "Foo" "Name": "Foo"
}, },
"Tag": 0 "Tag": 0
} }
Type: struct (unnamed struct at temp.h:1:1): Type: struct (unnamed struct at temp.h:1:1):
{ {
"_Type": "RecordType",
"Tag": 0, "Tag": 0,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "x" "Name": "x"
}] }]
}] }]
@@ -131,33 +161,43 @@ Type: struct (unnamed struct at temp.h:1:1):
} }
Type: Foo: Type: Foo:
{ {
"_Type": "Ident",
"Name": "Foo" "Name": "Foo"
} }
Type: union Foo: Type: union Foo:
{ {
"_Type": "TagExpr",
"Name": { "Name": {
"_Type": "Ident",
"Name": "Foo" "Name": "Foo"
}, },
"Tag": 1 "Tag": 1
} }
Type: union (unnamed union at temp.h:1:1): Type: union (unnamed union at temp.h:1:1):
{ {
"_Type": "RecordType",
"Tag": 1, "Tag": 1,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 1, "Access": 1,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "x" "Name": "x"
}] }]
}] }]
@@ -166,22 +206,29 @@ Type: union (unnamed union at temp.h:1:1):
} }
Type: Foo: Type: Foo:
{ {
"_Type": "Ident",
"Name": "Foo" "Name": "Foo"
} }
Type: enum Foo: Type: enum Foo:
{ {
"_Type": "TagExpr",
"Name": { "Name": {
"_Type": "Ident",
"Name": "Foo" "Name": "Foo"
}, },
"Tag": 2 "Tag": 2
} }
Type: enum (unnamed enum at temp.h:1:1): Type: enum (unnamed enum at temp.h:1:1):
{ {
"_Type": "EnumType",
"Items": [{ "Items": [{
"_Type": "EnumItem",
"Name": { "Name": {
"_Type": "Ident",
"Name": "x" "Name": "x"
}, },
"Value": { "Value": {
"_Type": "BasicLit",
"Kind": 0, "Kind": 0,
"Value": "42" "Value": "42"
} }
@@ -189,33 +236,43 @@ Type: enum (unnamed enum at temp.h:1:1):
} }
Type: Foo: Type: Foo:
{ {
"_Type": "Ident",
"Name": "Foo" "Name": "Foo"
} }
Type: class Foo: Type: class Foo:
{ {
"_Type": "TagExpr",
"Name": { "Name": {
"_Type": "Ident",
"Name": "Foo" "Name": "Foo"
}, },
"Tag": 3 "Tag": 3
} }
Type: class (unnamed class at temp.h:1:1): Type: class (unnamed class at temp.h:1:1):
{ {
"_Type": "RecordType",
"Tag": 3, "Tag": 3,
"Fields": { "Fields": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
"Doc": { "Doc": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"Comment": { "Comment": {
"_Type": "CommentGroup",
"List": [] "List": []
}, },
"IsStatic": false, "IsStatic": false,
"Access": 3, "Access": 3,
"Names": [{ "Names": [{
"_Type": "Ident",
"Name": "x" "Name": "x"
}] }]
}] }]
@@ -224,29 +281,40 @@ Type: class (unnamed class at temp.h:1:1):
} }
Type: a::b::c: Type: a::b::c:
{ {
"_Type": "ScopingExpr",
"X": { "X": {
"_Type": "Ident",
"Name": "c" "Name": "c"
}, },
"Parent": { "Parent": {
"_Type": "ScopingExpr",
"X": { "X": {
"_Type": "Ident",
"Name": "b" "Name": "b"
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "a" "Name": "a"
} }
} }
} }
Type: class a::b::c: Type: class a::b::c:
{ {
"_Type": "TagExpr",
"Name": { "Name": {
"_Type": "ScopingExpr",
"X": { "X": {
"_Type": "Ident",
"Name": "c" "Name": "c"
}, },
"Parent": { "Parent": {
"_Type": "ScopingExpr",
"X": { "X": {
"_Type": "Ident",
"Name": "b" "Name": "b"
}, },
"Parent": { "Parent": {
"_Type": "Ident",
"Name": "a" "Name": "a"
} }
} }
@@ -255,10 +323,15 @@ Type: class a::b::c:
} }
Type: int (*)(int, char): Type: int (*)(int, char):
{ {
"_Type": "PointerType",
"X": { "X": {
"_Type": "FuncType",
"Params": { "Params": {
"_Type": "FieldList",
"List": [{ "List": [{
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
}, },
@@ -268,7 +341,9 @@ Type: int (*)(int, char):
"Access": 0, "Access": 0,
"Names": [] "Names": []
}, { }, {
"_Type": "Field",
"Type": { "Type": {
"_Type": "BuiltinType",
"Kind": 2, "Kind": 2,
"Flags": 1 "Flags": 1
}, },
@@ -280,6 +355,7 @@ Type: int (*)(int, char):
}] }]
}, },
"Ret": { "Ret": {
"_Type": "BuiltinType",
"Kind": 6, "Kind": 6,
"Flags": 0 "Flags": 0
} }

View File

@@ -21,7 +21,7 @@ func MarshalASTFile(file *ast.File) *cjson.JSON {
for _, decl := range file.Decls { for _, decl := range file.Decls {
decls.AddItem(MarshalASTDecl(decl)) decls.AddItem(MarshalASTDecl(decl))
} }
root.SetItem(c.Str("_Type"), stringField("File"))
root.SetItem(c.Str("decls"), decls) root.SetItem(c.Str("decls"), decls)
// json:includes,omitempty // json:includes,omitempty
@@ -29,6 +29,7 @@ func MarshalASTFile(file *ast.File) *cjson.JSON {
includes := cjson.Array() includes := cjson.Array()
for _, i := range file.Includes { for _, i := range file.Includes {
include := cjson.Object() include := cjson.Object()
include.SetItem(c.Str("_Type"), stringField("Include"))
include.SetItem(c.Str("Path"), stringField(i.Path)) include.SetItem(c.Str("Path"), stringField(i.Path))
includes.AddItem(include) includes.AddItem(include)
} }
@@ -40,6 +41,7 @@ func MarshalASTFile(file *ast.File) *cjson.JSON {
macros := cjson.Array() macros := cjson.Array()
for _, m := range file.Macros { for _, m := range file.Macros {
marco := cjson.Object() marco := cjson.Object()
marco.SetItem(c.Str("_Type"), stringField("Macro"))
marco.SetItem(c.Str("Name"), stringField(m.Name)) marco.SetItem(c.Str("Name"), stringField(m.Name))
tokens := cjson.Array() tokens := cjson.Array()
for _, tok := range m.Tokens { for _, tok := range m.Tokens {
@@ -54,6 +56,7 @@ func MarshalASTFile(file *ast.File) *cjson.JSON {
} }
func Token(tok *ast.Token) *cjson.JSON { func Token(tok *ast.Token) *cjson.JSON {
root := cjson.Object() root := cjson.Object()
root.SetItem(c.Str("_Type"), stringField("Token"))
root.SetItem(c.Str("Token"), numberField(uint(tok.Token))) root.SetItem(c.Str("Token"), numberField(uint(tok.Token)))
root.SetItem(c.Str("Lit"), stringField(tok.Lit)) root.SetItem(c.Str("Lit"), stringField(tok.Lit))
return root return root
@@ -66,14 +69,17 @@ func MarshalASTDecl(decl ast.Decl) *cjson.JSON {
root := cjson.Object() root := cjson.Object()
switch d := decl.(type) { switch d := decl.(type) {
case *ast.EnumTypeDecl: case *ast.EnumTypeDecl:
root.SetItem(c.Str("_Type"), stringField("EnumTypeDecl"))
MarshalASTDeclBase(d.DeclBase, root) MarshalASTDeclBase(d.DeclBase, root)
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name)) root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
root.SetItem(c.Str("Type"), MarshalASTExpr(d.Type)) root.SetItem(c.Str("Type"), MarshalASTExpr(d.Type))
case *ast.TypedefDecl: case *ast.TypedefDecl:
root.SetItem(c.Str("_Type"), stringField("TypedefDecl"))
MarshalASTDeclBase(d.DeclBase, root) MarshalASTDeclBase(d.DeclBase, root)
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name)) root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
root.SetItem(c.Str("Type"), MarshalASTExpr(d.Type)) root.SetItem(c.Str("Type"), MarshalASTExpr(d.Type))
case *ast.FuncDecl: case *ast.FuncDecl:
root.SetItem(c.Str("_Type"), stringField("FuncDecl"))
MarshalASTDeclBase(d.DeclBase, root) MarshalASTDeclBase(d.DeclBase, root)
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name)) root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
root.SetItem(c.Str("Type"), MarshalASTExpr(d.Type)) root.SetItem(c.Str("Type"), MarshalASTExpr(d.Type))
@@ -86,6 +92,7 @@ func MarshalASTDecl(decl ast.Decl) *cjson.JSON {
root.SetItem(c.Str("IsVirtual"), boolField(d.IsVirtual)) root.SetItem(c.Str("IsVirtual"), boolField(d.IsVirtual))
root.SetItem(c.Str("IsOverride"), boolField(d.IsOverride)) root.SetItem(c.Str("IsOverride"), boolField(d.IsOverride))
case *ast.TypeDecl: case *ast.TypeDecl:
root.SetItem(c.Str("_Type"), stringField("TypeDecl"))
MarshalASTDeclBase(d.DeclBase, root) MarshalASTDeclBase(d.DeclBase, root)
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name)) root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
root.SetItem(c.Str("Type"), MarshalASTExpr(d.Type)) root.SetItem(c.Str("Type"), MarshalASTExpr(d.Type))
@@ -95,6 +102,7 @@ func MarshalASTDecl(decl ast.Decl) *cjson.JSON {
func MarshalASTDeclBase(decl ast.DeclBase, root *cjson.JSON) { func MarshalASTDeclBase(decl ast.DeclBase, root *cjson.JSON) {
loc := cjson.Object() loc := cjson.Object()
loc.SetItem(c.Str("_Type"), stringField("Location"))
loc.SetItem(c.Str("File"), stringField(decl.Loc.File)) loc.SetItem(c.Str("File"), stringField(decl.Loc.File))
root.SetItem(c.Str("Loc"), loc) root.SetItem(c.Str("Loc"), loc)
@@ -111,15 +119,18 @@ func MarshalASTExpr(t ast.Expr) *cjson.JSON {
switch d := t.(type) { switch d := t.(type) {
case *ast.EnumType: case *ast.EnumType:
root.SetItem(c.Str("_Type"), stringField("EnumType"))
items := cjson.Array() items := cjson.Array()
for _, e := range d.Items { for _, e := range d.Items {
items.AddItem(MarshalASTExpr(e)) items.AddItem(MarshalASTExpr(e))
} }
root.SetItem(c.Str("Items"), items) root.SetItem(c.Str("Items"), items)
case *ast.EnumItem: case *ast.EnumItem:
root.SetItem(c.Str("_Type"), stringField("EnumItem"))
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name)) root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
root.SetItem(c.Str("Value"), MarshalASTExpr(d.Value)) root.SetItem(c.Str("Value"), MarshalASTExpr(d.Value))
case *ast.RecordType: case *ast.RecordType:
root.SetItem(c.Str("_Type"), stringField("RecordType"))
root.SetItem(c.Str("Tag"), numberField(uint(d.Tag))) root.SetItem(c.Str("Tag"), numberField(uint(d.Tag)))
root.SetItem(c.Str("Fields"), MarshalASTExpr(d.Fields)) root.SetItem(c.Str("Fields"), MarshalASTExpr(d.Fields))
methods := cjson.Array() methods := cjson.Array()
@@ -128,9 +139,11 @@ func MarshalASTExpr(t ast.Expr) *cjson.JSON {
} }
root.SetItem(c.Str("Methods"), methods) root.SetItem(c.Str("Methods"), methods)
case *ast.FuncType: case *ast.FuncType:
root.SetItem(c.Str("_Type"), stringField("FuncType"))
root.SetItem(c.Str("Params"), MarshalASTExpr(d.Params)) root.SetItem(c.Str("Params"), MarshalASTExpr(d.Params))
root.SetItem(c.Str("Ret"), MarshalASTExpr(d.Ret)) root.SetItem(c.Str("Ret"), MarshalASTExpr(d.Ret))
case *ast.FieldList: case *ast.FieldList:
root.SetItem(c.Str("_Type"), stringField("FieldList"))
if d == nil { if d == nil {
return cjson.Null() return cjson.Null()
} }
@@ -140,6 +153,7 @@ func MarshalASTExpr(t ast.Expr) *cjson.JSON {
} }
root.SetItem(c.Str("List"), list) root.SetItem(c.Str("List"), list)
case *ast.Field: case *ast.Field:
root.SetItem(c.Str("_Type"), stringField("Field"))
root.SetItem(c.Str("Type"), MarshalASTExpr(d.Type)) root.SetItem(c.Str("Type"), MarshalASTExpr(d.Type))
root.SetItem(c.Str("Doc"), MarshalASTExpr(d.Doc)) root.SetItem(c.Str("Doc"), MarshalASTExpr(d.Doc))
root.SetItem(c.Str("Comment"), MarshalASTExpr(d.Comment)) root.SetItem(c.Str("Comment"), MarshalASTExpr(d.Comment))
@@ -151,35 +165,46 @@ func MarshalASTExpr(t ast.Expr) *cjson.JSON {
} }
root.SetItem(c.Str("Names"), names) root.SetItem(c.Str("Names"), names)
case *ast.Variadic: case *ast.Variadic:
root.SetItem(c.Str("_Type"), stringField("Variadic"))
case *ast.Ident: case *ast.Ident:
root.SetItem(c.Str("_Type"), stringField("Ident"))
if d == nil { if d == nil {
return cjson.Null() return cjson.Null()
} }
root.SetItem(c.Str("Name"), stringField(d.Name)) root.SetItem(c.Str("Name"), stringField(d.Name))
case *ast.TagExpr: case *ast.TagExpr:
root.SetItem(c.Str("_Type"), stringField("TagExpr"))
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name)) root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
root.SetItem(c.Str("Tag"), numberField(uint(d.Tag))) root.SetItem(c.Str("Tag"), numberField(uint(d.Tag)))
case *ast.BasicLit: case *ast.BasicLit:
root.SetItem(c.Str("_Type"), stringField("BasicLit"))
root.SetItem(c.Str("Kind"), numberField(uint(d.Kind))) root.SetItem(c.Str("Kind"), numberField(uint(d.Kind)))
root.SetItem(c.Str("Value"), stringField(d.Value)) root.SetItem(c.Str("Value"), stringField(d.Value))
case *ast.LvalueRefType: case *ast.LvalueRefType:
root.SetItem(c.Str("_Type"), stringField("LvalueRefType"))
root.SetItem(c.Str("X"), MarshalASTExpr(d.X)) root.SetItem(c.Str("X"), MarshalASTExpr(d.X))
case *ast.RvalueRefType: case *ast.RvalueRefType:
root.SetItem(c.Str("_Type"), stringField("RvalueRefType"))
root.SetItem(c.Str("X"), MarshalASTExpr(d.X)) root.SetItem(c.Str("X"), MarshalASTExpr(d.X))
case *ast.PointerType: case *ast.PointerType:
root.SetItem(c.Str("_Type"), stringField("PointerType"))
root.SetItem(c.Str("X"), MarshalASTExpr(d.X)) root.SetItem(c.Str("X"), MarshalASTExpr(d.X))
case *ast.ArrayType: case *ast.ArrayType:
root.SetItem(c.Str("_Type"), stringField("ArrayType"))
root.SetItem(c.Str("Elt"), MarshalASTExpr(d.Elt)) root.SetItem(c.Str("Elt"), MarshalASTExpr(d.Elt))
root.SetItem(c.Str("Len"), MarshalASTExpr(d.Len)) root.SetItem(c.Str("Len"), MarshalASTExpr(d.Len))
case *ast.BuiltinType: case *ast.BuiltinType:
root.SetItem(c.Str("_Type"), stringField("BuiltinType"))
root.SetItem(c.Str("Kind"), numberField(uint(d.Kind))) root.SetItem(c.Str("Kind"), numberField(uint(d.Kind)))
root.SetItem(c.Str("Flags"), numberField(uint(d.Flags))) root.SetItem(c.Str("Flags"), numberField(uint(d.Flags)))
case *ast.Comment: case *ast.Comment:
root.SetItem(c.Str("_Type"), stringField("Comment"))
if d == nil { if d == nil {
return cjson.Null() return cjson.Null()
} }
root.SetItem(c.Str("Text"), stringField(d.Text)) root.SetItem(c.Str("Text"), stringField(d.Text))
case *ast.CommentGroup: case *ast.CommentGroup:
root.SetItem(c.Str("_Type"), stringField("CommentGroup"))
if d == nil { if d == nil {
return cjson.Null() return cjson.Null()
} }
@@ -189,6 +214,7 @@ func MarshalASTExpr(t ast.Expr) *cjson.JSON {
} }
root.SetItem(c.Str("List"), list) root.SetItem(c.Str("List"), list)
case *ast.ScopingExpr: case *ast.ScopingExpr:
root.SetItem(c.Str("_Type"), stringField("ScopingExpr"))
root.SetItem(c.Str("X"), MarshalASTExpr(d.X)) root.SetItem(c.Str("X"), MarshalASTExpr(d.X))
root.SetItem(c.Str("Parent"), MarshalASTExpr(d.Parent)) root.SetItem(c.Str("Parent"), MarshalASTExpr(d.Parent))
default: default: