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

Commit

Permalink
Merge pull request #24 from juanjux/memory_issue
Browse files Browse the repository at this point in the history
Native + annotations fixes, sdk update.
  • Loading branch information
juanjux authored Feb 7, 2019
2 parents 05b5a19 + 74753eb commit 503a06d
Show file tree
Hide file tree
Showing 120 changed files with 40,546 additions and 387 deletions.
47 changes: 26 additions & 21 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 42 additions & 14 deletions driver/normalizer/normalizer.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package normalizer

import (
"strings"

"gopkg.in/bblfsh/sdk.v2/uast"
"gopkg.in/bblfsh/sdk.v2/uast/nodes"
. "gopkg.in/bblfsh/sdk.v2/uast/transformer"
"strings"
)

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

{Name: "Prop_DeclSpecifier", Op: Cases("retTypeCase",
// FIXME XXX: use an Or("void", "unspecified") or the equivalent
// void
Fields{
{Name: uast.KeyType, Op: String("CPPASTSimpleDeclSpecifier")},
{Name: uast.KeyPos, Op: Any()},
Expand Down Expand Up @@ -411,7 +410,7 @@ var Normalizers = []Mapping{
{Name: "DeclaresParameterPack", Op: Any()},
{Name: "Prop_PointerOperators", Optional: "optPointerOps", Op: Any()},
{Name: "Prop_Initializer", Optional: "optInitializer", Op: Var("ainit")},
{Name: "ExpandedFromMacro", Optional: "optMacro7", Op: Any()},
{Name: "ExpandedFromMacro", Optional: "optMacro", Op: Any()},
{Name: "Prop_PointerOperators", Optional: "optPointerOps", Op: Any()},
},
Fields{
Expand All @@ -422,9 +421,27 @@ var Normalizers = []Mapping{
{Name: "DeclaresParameterPack", Op: Any()},
{Name: "Prop_ArrayModifiers", Op: Any()},
{Name: "Prop_Initializer", Optional: "optInitializer", Op: Var("ainit")},
{Name: "ExpandedFromMacro", Optional: "optMacro8", Op: Any()},
{Name: "ExpandedFromMacro", Optional: "optMacro", Op: Any()},
{Name: "Prop_PointerOperators", Optional: "optPointerOps", Op: Any()},
},
Fields{
{Name: uast.KeyType, Op: String("CPPASTElaboratedTypeSpecifier")},
{Name: uast.KeyPos, Op: Var("parampos")},
{Name: "Prop_Name", Op: Var("aname")},
{Name: "Prop_Initializer", Optional: "optInitializer", Op: Var("ainit")},
{Name: "Kind", Op: Var("eltype")},
{Name: "IsConst", Op: Any()},
{Name: "IsConstExpr", Op: Any()},
{Name: "IsExplicit", Op: Any()},
{Name: "IsFriend", Op: Any()},
{Name: "IsInline", Op: Any()},
{Name: "IsRestrict", Op: Any()},
{Name: "IsThreadLocal", Op: Any()},
{Name: "IsVirtual", Op: Any()},
{Name: "IsVolatile", Op: Any()},
{Name: "StorageClass", Op: Any()},
{Name: "ExpandedFromMacro", Optional: "optMacro", Op: Any()},
},
))},
}},
},
Expand Down Expand Up @@ -471,15 +488,26 @@ var Normalizers = []Mapping{

{Name: "Arguments", Optional: "optArgs", Op: Cases("takesVarArgs",
// False, no varargs
Each("args", UASTType(uast.Argument{}, Obj{
"Name": Var("aname"),
//"Name": Cases("caseParamsName",
// Var("aname"),
// Is(nil),
//),
"Type": Var("atype"),
"Init": If("optInitializer", Var("ainit"), Is(nil)),
})),
Each("args", Cases("caseParams",
UASTType(uast.Argument{}, Obj{
"Name": Var("aname"),
"Type": Var("atype"),
"Init": If("optInitializer", Var("ainit"), Is(nil)),
}),
UASTType(uast.Argument{}, Obj{
"Name": Var("aname"),
"Type": Var("atype"),
"Init": If("optInitializer", Var("ainit"), Is(nil)),
}),
UASTType(uast.Argument{}, Obj{
"Name": Var("aname"),
"Type": UASTType(uast.Identifier{}, Obj{
"Name": Var("eltype"),
}),
"Init": If("optInitializer", Var("ainit"), Is(nil)),
})),
),

// True, the last arg is variadic
Append(
Each("args", UASTType(uast.Argument{}, Obj{
Expand Down
11 changes: 6 additions & 5 deletions driver/normalizer/transforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package normalizer
import "gopkg.in/bblfsh/sdk.v2/driver"

var Transforms = driver.Transforms{
Namespace: "cpp",
Preprocess: Preprocess,
Normalize: Normalize,
Annotations: Native,
Code: Code,
Namespace: "cpp",
Preprocess: Preprocess,
PreprocessCode: PreprocessCode,
Normalize: Normalize,
Annotations: Native,
Code: Code,
}
81 changes: 81 additions & 0 deletions fixtures/bench_accumulator_factory.cpp.native
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,41 @@
IASTClass: "CPPASTSimpleDeclaration",
LocOffsetEnd: 781,
LocOffsetStart: 749,
'Prop_DeclSpecifier': {
IASTClass: "CPPASTEnumerationSpecifier",
IsConst: false,
IsConstExpr: false,
IsExplicit: false,
IsFriend: false,
IsInline: false,
IsOpaque: false,
IsRestrict: false,
IsScoped: false,
IsThreadLocal: false,
IsVirtual: false,
IsVolatile: false,
LocOffsetEnd: 774,
LocOffsetStart: 749,
'Prop_Enumerators': [
{
IASTClass: "CPPASTName",
LocOffsetEnd: 764,
LocOffsetStart: 755,
Name: "floatType",
},
{
IASTClass: "CPPASTName",
LocOffsetEnd: 773,
LocOffsetStart: 766,
Name: "intType",
},
],
'Prop_Name': {
IASTClass: "CPPASTName",
Name: "",
},
StorageClass: "unspecified",
},
'Prop_Declarators': [
{
DeclaresParameterPack: false,
Expand All @@ -1634,6 +1669,29 @@
IASTClass: "CPPASTSimpleDeclaration",
LocOffsetEnd: 802,
LocOffsetStart: 786,
'Prop_DeclSpecifier': {
IASTClass: "CPPASTSimpleDeclSpecifier",
IsComplex: false,
IsConst: false,
IsConstExpr: false,
IsExplicit: false,
IsFriend: false,
IsImaginary: false,
IsInline: false,
IsLong: false,
IsLongLong: false,
IsRestrict: false,
IsShort: false,
IsSigned: false,
IsThreadLocal: false,
IsUnsigned: false,
IsVirtual: false,
IsVolatile: false,
LocOffsetEnd: 791,
LocOffsetStart: 786,
StorageClass: "unspecified",
Type: "float",
},
'Prop_Declarators': [
{
DeclaresParameterPack: false,
Expand All @@ -1654,6 +1712,29 @@
IASTClass: "CPPASTSimpleDeclaration",
LocOffsetEnd: 819,
LocOffsetStart: 807,
'Prop_DeclSpecifier': {
IASTClass: "CPPASTSimpleDeclSpecifier",
IsComplex: false,
IsConst: false,
IsConstExpr: false,
IsExplicit: false,
IsFriend: false,
IsImaginary: false,
IsInline: false,
IsLong: false,
IsLongLong: false,
IsRestrict: false,
IsShort: false,
IsSigned: false,
IsThreadLocal: false,
IsUnsigned: false,
IsVirtual: false,
IsVolatile: false,
LocOffsetEnd: 810,
LocOffsetStart: 807,
StorageClass: "unspecified",
Type: "int",
},
'Prop_Declarators': [
{
DeclaresParameterPack: false,
Expand Down
Loading

0 comments on commit 503a06d

Please sign in to comment.