llcppsigfetch:Scope Context

This commit is contained in:
luoliwoshang
2024-08-15 11:26:34 +08:00
parent f613316046
commit 2c8a9d1160
4 changed files with 236 additions and 59 deletions

View File

@@ -7,6 +7,7 @@ import (
func main() {
TestFuncDecl()
TestScope()
}
func TestFuncDecl() {
@@ -35,7 +36,38 @@ func TestFuncDecl() {
}
json := converter.GetFilesJSON()
c.Printf(c.Str("Test Case %d:\n%s\n\n"), c.Int(i+1), json.Print())
c.Printf(c.Str("TestFuncDecl Case %d:\n%s\n\n"), c.Int(i+1), json.Print())
converter.Dispose()
}
}
func TestScope() {
testCases := []string{
`void foo();`,
`namespace a {
void foo();
}`,
`namespace a {
namespace b {
void foo();
}
}`,
}
for i, content := range testCases {
converter, err := parse.NewConverter(content, true)
if err != nil {
panic(err)
}
_, err = converter.Convert()
if err != nil {
panic(err)
}
json := converter.GetFilesJSON()
c.Printf(c.Str("TestScope Case %d:\n%s\n\n"), c.Int(i+1), json.Print())
converter.Dispose()
}

View File

@@ -1,10 +1,12 @@
#stdout
Test Case 1:
TestFuncDecl Case 1:
{
"temp.h": {
"path": "temp.h",
"decls": [{
"Loc": null,
"Loc": {
"File": "temp.h"
},
"Doc": null,
"Parent": null,
"Name": {
@@ -25,12 +27,14 @@ Test Case 1:
}
}
Test Case 2:
TestFuncDecl Case 2:
{
"temp.h": {
"path": "temp.h",
"decls": [{
"Loc": null,
"Loc": {
"File": "temp.h"
},
"Doc": null,
"Parent": null,
"Name": {
@@ -61,12 +65,14 @@ Test Case 2:
}
}
Test Case 3:
TestFuncDecl Case 3:
{
"temp.h": {
"path": "temp.h",
"decls": [{
"Loc": null,
"Loc": {
"File": "temp.h"
},
"Doc": null,
"Parent": null,
"Name": {
@@ -107,12 +113,14 @@ Test Case 3:
}
}
Test Case 4:
TestFuncDecl Case 4:
{
"temp.h": {
"path": "temp.h",
"decls": [{
"Loc": null,
"Loc": {
"File": "temp.h"
},
"Doc": null,
"Parent": null,
"Name": {
@@ -155,12 +163,14 @@ Test Case 4:
}
}
Test Case 5:
TestFuncDecl Case 5:
{
"temp.h": {
"path": "temp.h",
"decls": [{
"Loc": null,
"Loc": {
"File": "temp.h"
},
"Doc": null,
"Parent": null,
"Name": {
@@ -205,12 +215,14 @@ Test Case 5:
}
}
Test Case 6:
TestFuncDecl Case 6:
{
"temp.h": {
"path": "temp.h",
"decls": [{
"Loc": null,
"Loc": {
"File": "temp.h"
},
"Doc": null,
"Parent": null,
"Name": {
@@ -259,12 +271,14 @@ Test Case 6:
}
}
Test Case 7:
TestFuncDecl Case 7:
{
"temp.h": {
"path": "temp.h",
"decls": [{
"Loc": null,
"Loc": {
"File": "temp.h"
},
"Doc": null,
"Parent": null,
"Name": {
@@ -310,12 +324,14 @@ Test Case 7:
}
}
Test Case 8:
TestFuncDecl Case 8:
{
"temp.h": {
"path": "temp.h",
"decls": [{
"Loc": null,
"Loc": {
"File": "temp.h"
},
"Doc": null,
"Parent": null,
"Name": {
@@ -360,6 +376,99 @@ Test Case 8:
}
}
TestScope Case 1:
{
"temp.h": {
"path": "temp.h",
"decls": [{
"Loc": {
"File": "temp.h"
},
"Doc": null,
"Parent": null,
"Name": {
"Name": "foo"
},
"Type": {
"Params": {
"List": []
},
"Ret": {
"Kind": 0,
"Flags": 0
}
}
}],
"includes": [],
"macros": []
}
}
TestScope Case 2:
{
"temp.h": {
"path": "temp.h",
"decls": [{
"Loc": {
"File": "temp.h"
},
"Doc": null,
"Parent": {
"Name": "a"
},
"Name": {
"Name": "foo"
},
"Type": {
"Params": {
"List": []
},
"Ret": {
"Kind": 0,
"Flags": 0
}
}
}],
"includes": [],
"macros": []
}
}
TestScope Case 3:
{
"temp.h": {
"path": "temp.h",
"decls": [{
"Loc": {
"File": "temp.h"
},
"Doc": null,
"Parent": {
"X": {
"Name": "b"
},
"Parent": {
"Name": "a"
}
},
"Name": {
"Name": "foo"
},
"Type": {
"Params": {
"List": []
},
"Ret": {
"Kind": 0,
"Flags": 0
}
}
}],
"includes": [],
"macros": []
}
}
#stderr