Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit 503a06d

Browse files
authored
Merge pull request #24 from juanjux/memory_issue
Native + annotations fixes, sdk update.
2 parents 05b5a19 + 74753eb commit 503a06d

File tree

120 files changed

+40546
-387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+40546
-387
lines changed

Gopkg.lock

Lines changed: 26 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

driver/normalizer/normalizer.go

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package normalizer
22

33
import (
4+
"strings"
5+
46
"gopkg.in/bblfsh/sdk.v2/uast"
57
"gopkg.in/bblfsh/sdk.v2/uast/nodes"
68
. "gopkg.in/bblfsh/sdk.v2/uast/transformer"
7-
"strings"
89
)
910

1011
var Preprocess = Transformers([][]Transformer{
@@ -274,8 +275,6 @@ var Normalizers = []Mapping{
274275
{Name: "Prop_Body", Optional: "optBody", Op: Var("body")},
275276

276277
{Name: "Prop_DeclSpecifier", Op: Cases("retTypeCase",
277-
// FIXME XXX: use an Or("void", "unspecified") or the equivalent
278-
// void
279278
Fields{
280279
{Name: uast.KeyType, Op: String("CPPASTSimpleDeclSpecifier")},
281280
{Name: uast.KeyPos, Op: Any()},
@@ -411,7 +410,7 @@ var Normalizers = []Mapping{
411410
{Name: "DeclaresParameterPack", Op: Any()},
412411
{Name: "Prop_PointerOperators", Optional: "optPointerOps", Op: Any()},
413412
{Name: "Prop_Initializer", Optional: "optInitializer", Op: Var("ainit")},
414-
{Name: "ExpandedFromMacro", Optional: "optMacro7", Op: Any()},
413+
{Name: "ExpandedFromMacro", Optional: "optMacro", Op: Any()},
415414
{Name: "Prop_PointerOperators", Optional: "optPointerOps", Op: Any()},
416415
},
417416
Fields{
@@ -422,9 +421,27 @@ var Normalizers = []Mapping{
422421
{Name: "DeclaresParameterPack", Op: Any()},
423422
{Name: "Prop_ArrayModifiers", Op: Any()},
424423
{Name: "Prop_Initializer", Optional: "optInitializer", Op: Var("ainit")},
425-
{Name: "ExpandedFromMacro", Optional: "optMacro8", Op: Any()},
424+
{Name: "ExpandedFromMacro", Optional: "optMacro", Op: Any()},
426425
{Name: "Prop_PointerOperators", Optional: "optPointerOps", Op: Any()},
427426
},
427+
Fields{
428+
{Name: uast.KeyType, Op: String("CPPASTElaboratedTypeSpecifier")},
429+
{Name: uast.KeyPos, Op: Var("parampos")},
430+
{Name: "Prop_Name", Op: Var("aname")},
431+
{Name: "Prop_Initializer", Optional: "optInitializer", Op: Var("ainit")},
432+
{Name: "Kind", Op: Var("eltype")},
433+
{Name: "IsConst", Op: Any()},
434+
{Name: "IsConstExpr", Op: Any()},
435+
{Name: "IsExplicit", Op: Any()},
436+
{Name: "IsFriend", Op: Any()},
437+
{Name: "IsInline", Op: Any()},
438+
{Name: "IsRestrict", Op: Any()},
439+
{Name: "IsThreadLocal", Op: Any()},
440+
{Name: "IsVirtual", Op: Any()},
441+
{Name: "IsVolatile", Op: Any()},
442+
{Name: "StorageClass", Op: Any()},
443+
{Name: "ExpandedFromMacro", Optional: "optMacro", Op: Any()},
444+
},
428445
))},
429446
}},
430447
},
@@ -471,15 +488,26 @@ var Normalizers = []Mapping{
471488

472489
{Name: "Arguments", Optional: "optArgs", Op: Cases("takesVarArgs",
473490
// False, no varargs
474-
Each("args", UASTType(uast.Argument{}, Obj{
475-
"Name": Var("aname"),
476-
//"Name": Cases("caseParamsName",
477-
// Var("aname"),
478-
// Is(nil),
479-
//),
480-
"Type": Var("atype"),
481-
"Init": If("optInitializer", Var("ainit"), Is(nil)),
482-
})),
491+
Each("args", Cases("caseParams",
492+
UASTType(uast.Argument{}, Obj{
493+
"Name": Var("aname"),
494+
"Type": Var("atype"),
495+
"Init": If("optInitializer", Var("ainit"), Is(nil)),
496+
}),
497+
UASTType(uast.Argument{}, Obj{
498+
"Name": Var("aname"),
499+
"Type": Var("atype"),
500+
"Init": If("optInitializer", Var("ainit"), Is(nil)),
501+
}),
502+
UASTType(uast.Argument{}, Obj{
503+
"Name": Var("aname"),
504+
"Type": UASTType(uast.Identifier{}, Obj{
505+
"Name": Var("eltype"),
506+
}),
507+
"Init": If("optInitializer", Var("ainit"), Is(nil)),
508+
})),
509+
),
510+
483511
// True, the last arg is variadic
484512
Append(
485513
Each("args", UASTType(uast.Argument{}, Obj{

driver/normalizer/transforms.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package normalizer
33
import "gopkg.in/bblfsh/sdk.v2/driver"
44

55
var Transforms = driver.Transforms{
6-
Namespace: "cpp",
7-
Preprocess: Preprocess,
8-
Normalize: Normalize,
9-
Annotations: Native,
10-
Code: Code,
6+
Namespace: "cpp",
7+
Preprocess: Preprocess,
8+
PreprocessCode: PreprocessCode,
9+
Normalize: Normalize,
10+
Annotations: Native,
11+
Code: Code,
1112
}

fixtures/bench_accumulator_factory.cpp.native

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,41 @@
16141614
IASTClass: "CPPASTSimpleDeclaration",
16151615
LocOffsetEnd: 781,
16161616
LocOffsetStart: 749,
1617+
'Prop_DeclSpecifier': {
1618+
IASTClass: "CPPASTEnumerationSpecifier",
1619+
IsConst: false,
1620+
IsConstExpr: false,
1621+
IsExplicit: false,
1622+
IsFriend: false,
1623+
IsInline: false,
1624+
IsOpaque: false,
1625+
IsRestrict: false,
1626+
IsScoped: false,
1627+
IsThreadLocal: false,
1628+
IsVirtual: false,
1629+
IsVolatile: false,
1630+
LocOffsetEnd: 774,
1631+
LocOffsetStart: 749,
1632+
'Prop_Enumerators': [
1633+
{
1634+
IASTClass: "CPPASTName",
1635+
LocOffsetEnd: 764,
1636+
LocOffsetStart: 755,
1637+
Name: "floatType",
1638+
},
1639+
{
1640+
IASTClass: "CPPASTName",
1641+
LocOffsetEnd: 773,
1642+
LocOffsetStart: 766,
1643+
Name: "intType",
1644+
},
1645+
],
1646+
'Prop_Name': {
1647+
IASTClass: "CPPASTName",
1648+
Name: "",
1649+
},
1650+
StorageClass: "unspecified",
1651+
},
16171652
'Prop_Declarators': [
16181653
{
16191654
DeclaresParameterPack: false,
@@ -1634,6 +1669,29 @@
16341669
IASTClass: "CPPASTSimpleDeclaration",
16351670
LocOffsetEnd: 802,
16361671
LocOffsetStart: 786,
1672+
'Prop_DeclSpecifier': {
1673+
IASTClass: "CPPASTSimpleDeclSpecifier",
1674+
IsComplex: false,
1675+
IsConst: false,
1676+
IsConstExpr: false,
1677+
IsExplicit: false,
1678+
IsFriend: false,
1679+
IsImaginary: false,
1680+
IsInline: false,
1681+
IsLong: false,
1682+
IsLongLong: false,
1683+
IsRestrict: false,
1684+
IsShort: false,
1685+
IsSigned: false,
1686+
IsThreadLocal: false,
1687+
IsUnsigned: false,
1688+
IsVirtual: false,
1689+
IsVolatile: false,
1690+
LocOffsetEnd: 791,
1691+
LocOffsetStart: 786,
1692+
StorageClass: "unspecified",
1693+
Type: "float",
1694+
},
16371695
'Prop_Declarators': [
16381696
{
16391697
DeclaresParameterPack: false,
@@ -1654,6 +1712,29 @@
16541712
IASTClass: "CPPASTSimpleDeclaration",
16551713
LocOffsetEnd: 819,
16561714
LocOffsetStart: 807,
1715+
'Prop_DeclSpecifier': {
1716+
IASTClass: "CPPASTSimpleDeclSpecifier",
1717+
IsComplex: false,
1718+
IsConst: false,
1719+
IsConstExpr: false,
1720+
IsExplicit: false,
1721+
IsFriend: false,
1722+
IsImaginary: false,
1723+
IsInline: false,
1724+
IsLong: false,
1725+
IsLongLong: false,
1726+
IsRestrict: false,
1727+
IsShort: false,
1728+
IsSigned: false,
1729+
IsThreadLocal: false,
1730+
IsUnsigned: false,
1731+
IsVirtual: false,
1732+
IsVolatile: false,
1733+
LocOffsetEnd: 810,
1734+
LocOffsetStart: 807,
1735+
StorageClass: "unspecified",
1736+
Type: "int",
1737+
},
16571738
'Prop_Declarators': [
16581739
{
16591740
DeclaresParameterPack: false,

0 commit comments

Comments
 (0)