Compare commits
15
Commits
d0654613ea
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2113215e9 | ||
|
|
e4f7e32887 | ||
|
|
f4a9dae250 | ||
|
|
0bc23404da | ||
|
|
1704be1cbc | ||
|
|
8b3a956bbe | ||
|
|
acc8cab583 | ||
|
|
b5773b5525 | ||
|
|
4aa1211d73 | ||
|
|
c8209dd260 | ||
|
|
e5c8e114bf | ||
|
|
79bb282188 | ||
|
|
ac9eecafd8 | ||
|
|
b0139b9aa8 | ||
|
|
9a4fabda24 |
+12
@@ -9,3 +9,15 @@ examples/foundation/foundation
|
|||||||
examples/foundation/ns
|
examples/foundation/ns
|
||||||
examples/simple/simple
|
examples/simple/simple
|
||||||
examples/simple/ClassOne
|
examples/simple/ClassOne
|
||||||
|
examples/memory/memory
|
||||||
|
examples/memory/ns
|
||||||
|
examples/gc/gc
|
||||||
|
examples/gc/ns
|
||||||
|
examples/functions/functions
|
||||||
|
examples/functions/ns
|
||||||
|
examples/subclass/ns
|
||||||
|
examples/subclass/subclass
|
||||||
|
examples/strings/strings
|
||||||
|
examples/strings/ns
|
||||||
|
ns-old
|
||||||
|
outputclang.txt
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ pragma [ clang diagnostic ignored "-Wformat-security" ]
|
|||||||
|
|
||||||
Regular expressions are permitted in the names of classes, functions,
|
Regular expressions are permitted in the names of classes, functions,
|
||||||
protocols and protocol methods, overridden superclass methods, and enums.
|
protocols and protocol methods, overridden superclass methods, and enums.
|
||||||
|
Since the `NSObject` class is necessary for memory management, NSWrap will
|
||||||
|
automatically include it if it is encountered in an input header file.
|
||||||
|
|
||||||
When invoked, NSWrap creates a subdirectory with the name of the package
|
When invoked, NSWrap creates a subdirectory with the name of the package
|
||||||
as specified in `nswrap.yaml` or, by default, `ns` if a package name is not
|
as specified in `nswrap.yaml` or, by default, `ns` if a package name is not
|
||||||
@@ -131,14 +133,14 @@ For example, `NSString` provides the folowing `compare` methods:
|
|||||||
These are translated into Go as:
|
These are translated into Go as:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (o NSString) Compare(string NSString) NSComparisonResult { }
|
func (o *NSString) Compare(string *NSString) NSComparisonResult { }
|
||||||
|
|
||||||
func (o NSString) CompareOptions(string NSString, mask NSStringCompareOptions) NSComparisonResult { }
|
func (o *NSString) CompareOptions(string *NSString, mask NSStringCompareOptions) NSComparisonResult { }
|
||||||
|
|
||||||
func (o NSString) CompareOptionsRange(string NSString, mask NSStringCompareOptions,
|
func (o *NSString) CompareOptionsRange(string *NSString, mask NSStringCompareOptions,
|
||||||
rangeOfReceiverToCompare NSRange) NSComparisonResult { }
|
rangeOfReceiverToCompare NSRange) NSComparisonResult { }
|
||||||
|
|
||||||
func (o NSString) CompareOptionsRangeLocale(string NSString, mask NSStringCompareOptions,
|
func (o *NSString) CompareOptionsRangeLocale(string *NSString, mask NSStringCompareOptions,
|
||||||
rangeOfReceiverToCompare NSRange, locale NSObject) NSComparisonResult { }
|
rangeOfReceiverToCompare NSRange, locale NSObject) NSComparisonResult { }
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -156,11 +158,45 @@ fmt.Printf("%s\n",str)
|
|||||||
NSWrap creates a `Char` Go type that is equivalent to a C `char`. A pointer to
|
NSWrap creates a `Char` Go type that is equivalent to a C `char`. A pointer to
|
||||||
`Char` in Go code can therefore be used with Objective-C functions and methods
|
`Char` in Go code can therefore be used with Objective-C functions and methods
|
||||||
that take a `char*` parameter.
|
that take a `char*` parameter.
|
||||||
|
|
||||||
|
When NSWrap binds a method that returns `*Char` (and is in garbage collected mode,
|
||||||
|
the default), it first calls `strdup`
|
||||||
|
on the output of the underlying Objective-C method. Therefore, the returned
|
||||||
|
pointer is manually allocated and will need to be freed later from Go. NSWrap
|
||||||
|
creates a
|
||||||
|
`(*Char).Free()` method for use when these pointers are no longer needed.
|
||||||
|
This copying is necessary because the Objective-C runtime will sometimes
|
||||||
|
return pointers to internal objects that are impossible to manage from the
|
||||||
|
Go side. NSWrap aims to cause any internal objects to be deallocated as soon
|
||||||
|
as possible so they do not cause memory leaks. This means that any returned
|
||||||
|
C strings need to be copied and memory managed manually from the Go side.
|
||||||
|
|
||||||
NSWrap provides the helper functions `CharWithGoString` and `CharWithBytes`
|
NSWrap provides the helper functions `CharWithGoString` and `CharWithBytes`
|
||||||
that take, respectively, Go strings and Go byte arrays (`[]byte`) and return
|
that take, respectively, Go strings and Go byte arrays (`[]byte`) and return
|
||||||
`*Char` in Go. As demonstrated above, NSWrap also provides a `String()`
|
`*Char` in Go. As demonstrated above, NSWrap also provides `String()`
|
||||||
methods so that the `*Char` and `NSString` types implement the `Stringer`
|
methods so that the `*Char` and `*NSString` types implement the `Stringer`
|
||||||
Go interface.
|
Go interface and therefore can be sent directly to functions like `fmt.Printf`.
|
||||||
|
The `String()` method on `*NSString` creates a temporary `*Char` internally
|
||||||
|
but frees it for you before returning. Since methods returning
|
||||||
|
`*Char` return a pointer that needs to be manually freed, it is important
|
||||||
|
to use these properly in order to avoid leaks:
|
||||||
|
|
||||||
|
```go
|
||||||
|
nst := ns.NSStringWithGoString("one string")
|
||||||
|
|
||||||
|
// NO: the next line leaks a *Char (UTF8String)
|
||||||
|
//mygostring := nst.UTF8String().String()
|
||||||
|
|
||||||
|
// OK: NSWrap creates a temporary *Char and frees it for you:
|
||||||
|
mygostring := nst.String()
|
||||||
|
|
||||||
|
// ALSO OK: manually free your own temporary *Char:
|
||||||
|
mytmpchar := nst.UTF8String()
|
||||||
|
mygostring = mytmpchar.String()
|
||||||
|
mytmpchar.Free()
|
||||||
|
```
|
||||||
|
In most cases it will be more convenient to convert directly to Go strings instead
|
||||||
|
of `*Char`.
|
||||||
|
|
||||||
## Working With NSObject and its Descendants
|
## Working With NSObject and its Descendants
|
||||||
|
|
||||||
@@ -171,14 +207,23 @@ follows:
|
|||||||
type Id struct {
|
type Id struct {
|
||||||
ptr unsafe.Pointer
|
ptr unsafe.Pointer
|
||||||
}
|
}
|
||||||
func (o Id) Ptr() unsafe.Pointer { return o.ptr }
|
func (o *Id) Ptr() unsafe.Pointer { if o == nil { return nil }; return o.ptr }
|
||||||
|
|
||||||
type NSObject interface {
|
type NSObject interface {
|
||||||
Ptr() unsafe.Pointer
|
Ptr() unsafe.Pointer
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Other object types in Go are structs that directly or indirectly embed `Id`
|
Other object types in Go are structs that directly or indirectly embed `Id`
|
||||||
and therefore implement `NSObject`.
|
and therefore contain an `unsafe.Pointer` to an Objective-C object, and
|
||||||
|
implement `NSObject` by inheriting the `Ptr()` method.
|
||||||
|
|
||||||
|
Because of this implementation, you will note that every Objective-C object
|
||||||
|
is represented by at least two pointers -- an underlying pointer to the
|
||||||
|
Objective-C object
|
||||||
|
in CGo memory (allocated by the Objective-C runtime), as well as a pointer
|
||||||
|
allocated by the Go runtime to an `Id` type, or to another type that directly
|
||||||
|
or indirectly embeds `Id`. This "dual pointer" approach is necessary to ensure
|
||||||
|
that memory management can be made to work correctly (see below for details).
|
||||||
|
|
||||||
* The NSObject Interface
|
* The NSObject Interface
|
||||||
|
|
||||||
@@ -190,7 +235,7 @@ embeds `Id` to be used with generic Objective-C functions. For example:
|
|||||||
|
|
||||||
```go
|
```go
|
||||||
o1 := ns.NSStringWithGoString("my string")
|
o1 := ns.NSStringWithGoString("my string")
|
||||||
s1 := ns.NSSetWithOBjects(o1)
|
s1 := ns.NSSetWithObjects(o1)
|
||||||
a := ns.NSMutableArrayWithObjects(o1,s1)
|
a := ns.NSMutableArrayWithObjects(o1,s1)
|
||||||
```
|
```
|
||||||
Since `NSString` and `NSSet` in Go both implement the `NSObject` interface,
|
Since `NSString` and `NSSet` in Go both implement the `NSObject` interface,
|
||||||
@@ -204,70 +249,73 @@ implements the required delegate protocol.
|
|||||||
|
|
||||||
* Inheritance
|
* Inheritance
|
||||||
|
|
||||||
Objective-C only provides single inheritance. In Go, this is modeled using
|
Objective-C allows single inheritance. NSWrap automatically adds
|
||||||
embedding. Top level objects that inherit from `NSObject` in Objective-C
|
inherited methods to classes that are includled in your binding.
|
||||||
|
|
||||||
|
Types created by NSWrap also "embed" their parent class. For example, top
|
||||||
|
level objects that inherit from `NSObject` in Objective-C
|
||||||
embed the Go type `Id` and therefore implement the `NSObject` Go interface.
|
embed the Go type `Id` and therefore implement the `NSObject` Go interface.
|
||||||
Other objects embed their superclass. For example:
|
Other objects embed their direct superclass. For example:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
type NSArray struct { Id }
|
type NSArray struct { Id }
|
||||||
func (o NSArray) Ptr() unsafe.Pointer { return o.ptr }
|
func (o *NSArray) Ptr() unsafe.Pointer { if o == nil { return nil }; return o.ptr }
|
||||||
func (o Id) NSArray() NSArray {
|
func (o *Id) NSArray() *NSArray {
|
||||||
ret := NSArray{}
|
return (*NSArray)(unsafe.Pointer(o))
|
||||||
ret.ptr = o.ptr
|
|
||||||
return ret
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type NSMutableArray struct { NSArray }
|
type NSMutableArray struct { NSArray }
|
||||||
func (o NSMutableArray) Ptr() unsafe.Pointer { return o.ptr }
|
func (o *NSMutableArray) Ptr() unsafe.Pointer { if o == nil { return nil }; return o.ptr }
|
||||||
func (o Id) NSMutableArray() NSMutableArray {...}
|
func (o *Id) NSMutableArray() *NSMutableArray {
|
||||||
|
return (*NSMutableArray)(unsafe.Pointer(o))
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Observe:
|
Observe:
|
||||||
```go
|
```go
|
||||||
b := ns.NSButtonAlloc() // NSButton > NSControl > NSView > NSResponder > NSObject
|
b := ns.NSButtonAlloc() // NSButton > NSControl > NSView > NSResponder > NSObject
|
||||||
b.InitWithFrame(ns.NSMakeRect(100,100,200,200)) // Method of NSView
|
b.InitWithFrame(ns.NSMakeRect(100,100,200,200))
|
||||||
b.SetTitle(nst("PUSH")) // Method of NSButton
|
b.SetTitle(nst("PUSH"))
|
||||||
vw := win.ContentView()
|
vw := win.ContentView()
|
||||||
vw.AddSubview(b.NSView) // Pass the button's embedded NSView
|
vw.AddSubview(&b.NSView) // Pass the button's embedded NSView
|
||||||
```
|
```
|
||||||
In Go, `NSButtonAlloc` returns a Go object of type `ns.NSButton`. However,
|
In Go, `NSButtonAlloc` returns a Go object of type `ns.NSButton`. However,
|
||||||
there is no `InitWithFrame` method for receivers of this type. This is
|
the `initWithFrame` method is defined in AppKit for `NSView`. NSWrap will find this
|
||||||
not necessary because `NSButton` embeds `NSControl` which in turn embeds
|
method and add it to the Go `NSButton` type when creating your wrapper because
|
||||||
`NSView`. The `InitWithFrame` method only needs to be implemented for `NSView`
|
`NSButton` inherits from `NSControl` which inherits from `NSView`.
|
||||||
receivers. Go will automatically find the indirectly embedded `NSView` and
|
|
||||||
call the right method.
|
|
||||||
|
|
||||||
Note that, since `InitWithFrame()` is defined only for `NSView` and returns
|
As of this
|
||||||
an `NSView` type,
|
writing, on MacOS 10.13.6, NSWrap binds 115 instance methods for `NSObject`,
|
||||||
the following will not work. Look out for this if you like to chain your
|
so things like `Hash()`, `IsEqualTo()`, `ClassName()`, `RespondsToSelector()`
|
||||||
`Alloc` and `Init` methods and are getting type errors:
|
|
||||||
|
|
||||||
```go
|
|
||||||
//DO NOT DO THIS -- InitWithFrame returns NSView, not NSButton
|
|
||||||
b := ns.NSButtonAlloc().InitWithFrame(ns.MakeRect(100,100,200,200))
|
|
||||||
```
|
|
||||||
|
|
||||||
Go has no trouble finding embedded methods for your `NSButton` and will
|
|
||||||
happily search up the chain through `NSControl`, `NSView`, `NSResponder` and
|
|
||||||
`NSObject` and all of their associated protocols and categories. As of this
|
|
||||||
writing, on MacOS 10.13.6, NSWrap binds 90 instance methods for `NSObject`,
|
|
||||||
so things like `Hash()`, `IsEqualTo()`, `ClassName()`, `RespondsToSelector`
|
|
||||||
and many many others are available and can be called on any object directly
|
and many many others are available and can be called on any object directly
|
||||||
from Go.
|
from Go.
|
||||||
|
|
||||||
Go does not perform the same type
|
All objects implement the `NSObject` interface, but from time to time you
|
||||||
magic when you use variables as function or method parameters.
|
will encounter a method that takes a parameter of a different type that may
|
||||||
If you want to pass your `NSButton` as a parameter to a method that accepts
|
not exactly match the type you have. For example, if you want to pass your
|
||||||
an `NSView` type, you need to explicitly pass the embedded `NSView`
|
`NSButton` as a parameter to a method that accepts an `NSView` type, you need
|
||||||
(`b.NSView` in the example above).
|
to explicitly pass its embedded `NSView` (`&b.NSView` in the example above).
|
||||||
|
This approach is safer than "converting" the button to an `NSView` (see below)
|
||||||
|
because it will only work on objects that directly or indirectly embed an
|
||||||
|
`NSView` Go type.
|
||||||
|
|
||||||
NSWrap creates a method for `Id` allowing objects to be converted
|
NSWrap creates a method for `Id` allowing objects to be converted
|
||||||
at run-time to any other class. You will need this for Enumerators, which
|
at run-time to any other class. You will need this for Enumerators and
|
||||||
always return `Id`. See below under Enumerators for an example, but make
|
functions like `NSArray`'s `GetObjects`, for example,
|
||||||
|
which always return `*Id`. Make
|
||||||
sure you know (or test) what type your objects are before converting them.
|
sure you know (or test) what type your objects are before converting them.
|
||||||
You can
|
You can implement a version of a Go type switch this way:
|
||||||
implement a somewhat less convenient version of a Go type switch this way.
|
|
||||||
|
```go
|
||||||
|
switch {
|
||||||
|
case o.IsKindOfClass(ns.NSStringClass()):
|
||||||
|
// do something with o.NSString()
|
||||||
|
case o.IsKindOfClass(ns.NSSetClass()):
|
||||||
|
// do something with o.NSSet()
|
||||||
|
default:
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Because `Id` can be converted to any type, and every object in the Foundation
|
Because `Id` can be converted to any type, and every object in the Foundation
|
||||||
classes inherits from `Id`, it is possible to send any message to any
|
classes inherits from `Id`, it is possible to send any message to any
|
||||||
@@ -314,11 +362,12 @@ functions.
|
|||||||
Pointers to pointers are sometimes passed to Objective-C methods or functions
|
Pointers to pointers are sometimes passed to Objective-C methods or functions
|
||||||
as a way of receiving output from those functions, especially because
|
as a way of receiving output from those functions, especially because
|
||||||
Objective-C does not allow for multiple return values. In those cases, after
|
Objective-C does not allow for multiple return values. In those cases, after
|
||||||
the CGo call, the method parameter will be treated as a nil-terminated array of
|
the CGo call, the method parameter will be treated as an array of
|
||||||
object pointers that may have been modified by the Objective-C function or
|
object pointers that may have been modified by the Objective-C function or
|
||||||
method. NSWrap will copy the object pointers back into the input Go slice, up
|
method. NSWrap will copy the object pointers back into the input Go slice, up
|
||||||
to its capacity (which will never be changed). The input Go slice is then
|
to its capacity (which will never be changed). The input Go slice is then
|
||||||
truncated to the appropriate length.
|
truncated to the appropriate length. If there is no output, the length will
|
||||||
|
be set to 0.
|
||||||
|
|
||||||
An example in Core Foundation is the `getObjects:andKeys:count` method for
|
An example in Core Foundation is the `getObjects:andKeys:count` method for
|
||||||
`NSDictionary`:
|
`NSDictionary`:
|
||||||
@@ -329,28 +378,31 @@ An example in Core Foundation is the `getObjects:andKeys:count` method for
|
|||||||
ns.NSArrayWithObjects(nst("obj1"),nst("obj2")),
|
ns.NSArrayWithObjects(nst("obj1"),nst("obj2")),
|
||||||
ns.NSArrayWithObjects(nst("key1"),nst("key2")),
|
ns.NSArrayWithObjects(nst("key1"),nst("key2")),
|
||||||
)
|
)
|
||||||
os,ks := make([]ns.Id,0,5), make([]ns.Id,0,5) // length 0, capacity 5 slices
|
va,ka := make([]*ns.Id,0,5), make([]*ns.Id,0,5) // length 0, capacity 5 slices
|
||||||
dict.GetObjects(&os,&ks,5)
|
dict.GetObjectsAndKeysCount(&va,&ka,5)
|
||||||
// last parameter is the count, must be less than or equal to the input slice capacity
|
// last parameter is the count, must be less than or equal to the input slice capacity
|
||||||
fmt.Printf("Length of os is now %d\n",len(os)) // os and ks slices are now length = 2
|
fmt.Printf("Length of va is now %d\n",len(va)) // va and ka slices are now length = 2
|
||||||
for i,k := range ks {
|
for i,k := range ka {
|
||||||
fmt.Printf("-- %s -> %s\n",k.NSString(),os[i].NSString())
|
fmt.Printf("-- %s -> %s\n",k.NSString(),va[i].NSString())
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
NSWrap will never check the "count" parameter, so the user will always need
|
NSWrap will not check the "count" parameter, so the user will always need
|
||||||
to make sure it is less than or equal to the capacity of the input
|
to make sure it is less than or equal to the capacity of the input
|
||||||
Go slices.
|
Go slices.
|
||||||
|
|
||||||
Using pointers to pointers is necessary in many Core Foundation situations
|
Using pointers to pointers is necessary in many Core Foundation situations
|
||||||
where you need to get an error message out of a function or method.
|
where you need to get an error message out of a function or method, or in other
|
||||||
|
cases where an Objective-C method wants to provide multiple return values.
|
||||||
Here is an example using `[NSString stringWithContentsOfURL...]`:
|
Here is an example using `[NSString stringWithContentsOfURL...]`:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
err := make([]ns.NSError,1)
|
err := make([]*ns.NSError,1)
|
||||||
n1 = ns.NSStringWithContentsOfURLEncoding(ns.NSURLWithGoString("htttypo://example.com"),0,&err)
|
n1 = ns.NSStringWithContentsOfURLEncoding(ns.NSURLWithGoString("htttypo://example.com"), 0, &err)
|
||||||
|
if len(err) > 0 {
|
||||||
fmt.Printf("err: %s\n",err[0].LocalizedDescription())
|
fmt.Printf("err: %s\n",err[0].LocalizedDescription())
|
||||||
//err: The file couldn’t be opened because URL type htttypo isn’t supported.
|
//err: The file couldn’t be opened because URL type htttypo isn’t supported.
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Selectors
|
## Selectors
|
||||||
@@ -370,15 +422,17 @@ appMenu.AddItemWithTitle(
|
|||||||
## Enumerators
|
## Enumerators
|
||||||
|
|
||||||
NSWrap provides a `ForIn` method for the `NSEnumerator` type. Call it with a
|
NSWrap provides a `ForIn` method for the `NSEnumerator` type. Call it with a
|
||||||
`func(ns.Id) bool` parameter that returns `true` to continue and `false` to
|
`func(*ns.Id) bool` parameter that returns `true` to continue and `false` to
|
||||||
stop the enumeration.
|
stop the enumeration.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
a := ns.NSArrayWithObjects(o1,o2,o3)
|
a := ns.NSArrayWithObjects(o1,o2,o3)
|
||||||
a.ObjectEnumerator().ForIn(func (o ns.Id) bool {
|
i := 0
|
||||||
|
a.ObjectEnumerator().ForIn(func (o *ns.Id) bool {
|
||||||
switch {
|
switch {
|
||||||
case o.IsKindOfClass(ns.NSStringClass()):
|
case o.IsKindOfClass(ns.NSStringClass()):
|
||||||
fmt.Println(o.NSString().UTF8String())
|
fmt.Printf("%d: %s\n", i, o.NSString())
|
||||||
|
i++
|
||||||
return true // continue enumeration
|
return true // continue enumeration
|
||||||
default:
|
default:
|
||||||
fmt.Println("Unknown class")
|
fmt.Println("Unknown class")
|
||||||
@@ -392,7 +446,7 @@ identification.
|
|||||||
|
|
||||||
## Enum Definitions
|
## Enum Definitions
|
||||||
|
|
||||||
NSWrap translates C `enum` values into Go constants. The enums you need are
|
NSWrap translates C `enum` values into Go constants. The enums you want are
|
||||||
specified in `nswrap.yaml` by regular expression, which, in the case of named
|
specified in `nswrap.yaml` by regular expression, which, in the case of named
|
||||||
enums, must match the name of the `enum` itself, or in the case of anonymous
|
enums, must match the name of the `enum` itself, or in the case of anonymous
|
||||||
enums, must match the name of the constant(s) you are looking for as declared
|
enums, must match the name of the constant(s) you are looking for as declared
|
||||||
@@ -415,10 +469,9 @@ results in:
|
|||||||
```go
|
```go
|
||||||
//ns/main.go
|
//ns/main.go
|
||||||
...
|
...
|
||||||
type NSWindowOrderingMode C.enum_NSWindowOrderingMode
|
const NSWindowAbove NSInteger = C.NSWindowAbove
|
||||||
const NSWindowAbove NSWindowOrderingMode = C.NSWindowAbove
|
const NSWindowBelow NSInteger = C.NSWindowBelow
|
||||||
const NSWindowBelow NSWindowOrderingMode = C.NSWindowBelow
|
const NSWindowOut NSInteger = C.NSWindowOut
|
||||||
const NSWindowOut NSWindowOrderingMode = C.NSWindowOut
|
|
||||||
|
|
||||||
const _CLOCK_REALTIME = C._CLOCK_REALTIME
|
const _CLOCK_REALTIME = C._CLOCK_REALTIME
|
||||||
const _CLOCK_MONOTONIC = C._CLOCK_MONOTONIC
|
const _CLOCK_MONOTONIC = C._CLOCK_MONOTONIC
|
||||||
@@ -426,70 +479,6 @@ const _CLOCK_MONOTONIC_RAW = C._CLOCK_MONOTONIC_RAW
|
|||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Memory management
|
|
||||||
|
|
||||||
Objective-C objects are always allocated and returned from CGo code, and
|
|
||||||
therefore these pointers are not garbage collected by Go. You can use any
|
|
||||||
of the standard Objective-C memory management techniques for those pointers,
|
|
||||||
which seem to work but have not been extensively tested.
|
|
||||||
|
|
||||||
Since everything inherits methods from `NSObject`, you can call `Retain()`,
|
|
||||||
`Release()` and `Autorelease()` on any object.
|
|
||||||
|
|
||||||
If the autorelease configuration directive is set to "true", all allocation functions
|
|
||||||
created by NSWrap (i.e. those ending in `Alloc`) will call `autorelease` before they
|
|
||||||
return an object. Alternately, objects can be manually sent an autorelease message.
|
|
||||||
If you are not working in an environment (such as an
|
|
||||||
Application Delegate callback) that provides an autorelease pool, you can
|
|
||||||
create your own:
|
|
||||||
|
|
||||||
* Work directly with `NSAutoreleasePool` objects
|
|
||||||
|
|
||||||
```go
|
|
||||||
swamp := ns.NSAutoreleasePoolAlloc().Init()
|
|
||||||
del := ns.AppDelegateAlloc()
|
|
||||||
//del.Autorelease() // if autorelease: true is not set in nswrap.yaml
|
|
||||||
menu := ns.NSMenuAlloc().InitWithTitle(nst("Main"))
|
|
||||||
//menu.Autorelease()
|
|
||||||
str := ns.NSStringWithGoString("these objects will be automatically deallocated when swamp is drained.")
|
|
||||||
...
|
|
||||||
swamp.Drain()
|
|
||||||
```
|
|
||||||
|
|
||||||
* ...or use the `AutoreleasePool()` helper function
|
|
||||||
|
|
||||||
NSWrap provides a helper function that can be passed a `func()` with no
|
|
||||||
parameters or return value. It is conventient to give it an anonymous function
|
|
||||||
and write your code in line, just like you would if you were using an
|
|
||||||
`@autoreleasepool { }` block.
|
|
||||||
|
|
||||||
```go
|
|
||||||
ns.AutoreleasePool(func() {
|
|
||||||
a := MyObjectAlloc().Init()
|
|
||||||
b := MyOtherObjectAlloc().Init()
|
|
||||||
...
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
You will need to make sure `NSAutoreleasePool` is included in the `classes`
|
|
||||||
directive in your configuration file before working with
|
|
||||||
`NSAutoreleasePool` objects or the `AutoreleasePool` helper function.
|
|
||||||
|
|
||||||
* Pitfalls
|
|
||||||
|
|
||||||
Go concurrency does not play well with Objective-C memory management. In particular,
|
|
||||||
an AutoreleasePool needs to be allocated and drained from the same thread, and
|
|
||||||
only objects allocated within that thread will be drained. Objects allocated and
|
|
||||||
autoreleased from a different goroutine in the same thread are at risk of being
|
|
||||||
prematurely drained. Therefore, you should only work with one AutoreleasePool at
|
|
||||||
a time, and only within a thread that is locked to the OS thread
|
|
||||||
(by calling `runtime.LockOSThread()`). If you will be allocating Objective-C objects
|
|
||||||
from multiple goroutines, it is best not to use the `autorelease: true` directive
|
|
||||||
as that will cause all objects to receive an `autorelease` message even if they are
|
|
||||||
created outside the thread where are using your autorelease pool.
|
|
||||||
See `examples/memory` for some basic tests and read the comments to larn what to avoid.
|
|
||||||
|
|
||||||
## Delegates
|
## Delegates
|
||||||
|
|
||||||
The `delegates` directive in `nswrap.yaml` creates a new Objective-C
|
The `delegates` directive in `nswrap.yaml` creates a new Objective-C
|
||||||
@@ -531,7 +520,8 @@ registered,
|
|||||||
it will be called with all of its parameters converted to their Go type
|
it will be called with all of its parameters converted to their Go type
|
||||||
equivalents. User-defined callbacks are registered by calling a function
|
equivalents. User-defined callbacks are registered by calling a function
|
||||||
with the method name in TitleCase + `Callback`, so in the example above,
|
with the method name in TitleCase + `Callback`, so in the example above,
|
||||||
you would call `ns.CentralManagerDidUpdateStateCallback(...)` with the name of
|
if your delegate was named `del`, you would call
|
||||||
|
`del.CentralManagerDidUpdateStateCallback(...)` with the name of
|
||||||
your callback function to register to receive notifications when your central
|
your callback function to register to receive notifications when your central
|
||||||
manager updates its state.
|
manager updates its state.
|
||||||
|
|
||||||
@@ -543,15 +533,20 @@ registers a callback for `centralManagerDidUpdateState`, allocates
|
|||||||
a `CBCentralManager` object, and installs our delegate:
|
a `CBCentralManager` object, and installs our delegate:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func cb(c ns.CBCentralManager) {
|
func cb(self ns.CBDelegate, c *ns.CBCentralManager) {
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
del *ns.CBDelegate // use global variables so these don't get garbage collected
|
||||||
|
cm *ns.CBCentralManager
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
...
|
...
|
||||||
del := ns.CBDelegateAlloc()
|
del = ns.CBDelegateAlloc()
|
||||||
del.CentralManagerDidUpdateStateCallback(cb)
|
del.CentralManagerDidUpdateStateCallback(cb)
|
||||||
cm := ns.CBCentralManagerAlloc().InitWithDelegateQueue(del,queue)
|
cm = ns.CBCentralManagerAlloc().InitWithDelegateQueue(del,queue)
|
||||||
```
|
```
|
||||||
|
|
||||||
When you provide user-defined callback functions, you will need to specify
|
When you provide user-defined callback functions, you will need to specify
|
||||||
@@ -562,12 +557,12 @@ messages will point you in the right direction.
|
|||||||
|
|
||||||
```
|
```
|
||||||
$ go build
|
$ go build
|
||||||
./main.go:127:43: cannot use didFinishLaunching (type func(ns.NSNotification, bool)) as type
|
./main.go:127:43: cannot use didFinishLaunching (type func(ns.CBDelegate, *ns.NSNotification, bool)) as type
|
||||||
func(ns.NSNotification) in argument to del.ApplicationDidFinishLaunchingCallback
|
func(ns.CBDelegate, *ns.NSNotification) in argument to del.ApplicationDidFinishLaunchingCallback
|
||||||
```
|
```
|
||||||
In the above example, the build failed because an extra `bool` parameter was
|
In the above example, the build failed because an extra `bool` parameter was
|
||||||
included in the callback function. The compiler is telling you that the right
|
included in the callback function. The compiler is telling you that the right
|
||||||
type for the callback is `func(ns.NSNotification)` with no return value.
|
type for the callback is `func(*ns.NSNotification)` with no return value.
|
||||||
|
|
||||||
## Working with AppKit
|
## Working with AppKit
|
||||||
|
|
||||||
@@ -576,8 +571,7 @@ Delegate. This allows you to build a Cocoa application entirely in Go.
|
|||||||
|
|
||||||
Because AppKit uses thread local storage, you will need to make sure all
|
Because AppKit uses thread local storage, you will need to make sure all
|
||||||
calls into it are done from the main OS thread. This can be a challenge in
|
calls into it are done from the main OS thread. This can be a challenge in
|
||||||
Go even though runtime.LockOSThread() is supposed to provide
|
Go and you will want to make use of `runtime.LockOSThread()`.
|
||||||
this functionality.
|
|
||||||
|
|
||||||
This is actually a full working Cocoa application:
|
This is actually a full working Cocoa application:
|
||||||
|
|
||||||
@@ -612,34 +606,43 @@ frameworks: [ Foundation, AppKit, CoreGraphics ]
|
|||||||
//go:generate nswrap
|
//go:generate nswrap
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
//go:generate nswrap
|
||||||
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
"git.wow.st/gmp/nswrap/examples/app/ns" // point to your own NSWrap output directory
|
"ns" // point to your own NSWrap output directory
|
||||||
)
|
)
|
||||||
|
|
||||||
func didFinishLaunching(n ns.NSNotification) {
|
func didFinishLaunching(self ns.AppDelegate, n *ns.NSNotification) {
|
||||||
fmt.Println("Go: did finish launching!")
|
fmt.Println("Go: did finish launching!")
|
||||||
}
|
}
|
||||||
|
|
||||||
func shouldTerminate(s ns.NSApplication) ns.BOOL {
|
func shouldTerminate(self ns.AppDelegate, s *ns.NSApplication) ns.BOOL {
|
||||||
return 1
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
a *ns.NSApplication // global vars so these are not garbage collected
|
||||||
|
del *ns.AppDelegate
|
||||||
|
win *ns.NSWindow
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
a := ns.NSApplicationSharedApplication()
|
a = ns.NSApplicationSharedApplication()
|
||||||
a.SetActivationPolicy(ns.NSApplicationActivationPolicyRegular)
|
a.SetActivationPolicy(ns.NSApplicationActivationPolicy(ns.NSApplicationActivationPolicyRegular))
|
||||||
del := ns.AppDelegateAlloc()
|
del = ns.AppDelegateAlloc()
|
||||||
del.ApplicationDidFinishLaunchingCallback(didFinishLaunching)
|
del.ApplicationDidFinishLaunchingCallback(didFinishLaunching)
|
||||||
del.ApplicationShouldTerminateAfterLastWindowClosedCallback(shouldTerminate)
|
del.ApplicationShouldTerminateAfterLastWindowClosedCallback(shouldTerminate)
|
||||||
a.SetDelegate(del)
|
a.SetDelegate(del)
|
||||||
|
|
||||||
win := ns.NSWindowAlloc().InitWithContentRectStyleMask(
|
win = ns.NSWindowAlloc().InitWithContentRectStyleMask(
|
||||||
ns.NSMakeRect(200,200,600,600),
|
ns.NSMakeRect(200,200,600,600),
|
||||||
ns.NSWindowStyleMaskTitled | ns.NSWindowStyleMaskClosable,
|
ns.NSWindowStyleMask(ns.NSWindowStyleMaskTitled | ns.NSWindowStyleMaskClosable),
|
||||||
ns.NSBackingStoreBuffered,
|
ns.NSBackingStoreType(ns.NSBackingStoreBuffered),
|
||||||
0,
|
false,
|
||||||
)
|
)
|
||||||
win.SetTitle(ns.NSStringWithGoString("Hi World"))
|
win.SetTitle(ns.NSStringWithGoString("Hi World"))
|
||||||
win.MakeKeyAndOrderFront(win)
|
win.MakeKeyAndOrderFront(win)
|
||||||
@@ -647,12 +650,14 @@ func main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Pretty simple right? Not really, NSWrap just generated almost 15,000 lines of
|
Pretty simple right? Not really, NSWrap just generated 114,000 lines of
|
||||||
code. See `examples/app` for a slightly more complex example with working
|
code. See `examples/app` for a slightly more complex example with working
|
||||||
menus, visual format-based auto layout, and a custom button class.
|
menus, visual format-based auto layout, and a custom button class.
|
||||||
|
|
||||||
## Subclasses
|
## Subclasses
|
||||||
|
|
||||||
|
### NOTE: SUBCLASS FUNCTIONALITY IS CURRENTLY PARTIALLY BROKEN
|
||||||
|
|
||||||
NSWrap includes functionality to generate subclasses as specified in
|
NSWrap includes functionality to generate subclasses as specified in
|
||||||
`nswrap.yaml`.
|
`nswrap.yaml`.
|
||||||
|
|
||||||
@@ -667,7 +672,7 @@ subclasses:
|
|||||||
yourClass: # the superclass to inherit from
|
yourClass: # the superclass to inherit from
|
||||||
- init.* # what methods to override
|
- init.* # what methods to override
|
||||||
- -(void)hi_there:(int)x # Objective-C prototype of your new method(s)
|
- -(void)hi_there:(int)x # Objective-C prototype of your new method(s)
|
||||||
# |--this hyphen indicates that this is an instance method
|
# \--the initial hyphen indicates that this is an instance method
|
||||||
```
|
```
|
||||||
|
|
||||||
In the example above, your new class will be named `myClass` in Objective-C
|
In the example above, your new class will be named `myClass` in Objective-C
|
||||||
@@ -682,12 +687,11 @@ name, its return type, and the names and types of its parameters if any.
|
|||||||
Since multiple inheritance is not permitted in Objective-C, it is not possible
|
Since multiple inheritance is not permitted in Objective-C, it is not possible
|
||||||
to specify more than one superclass in a `subclasses` entry.
|
to specify more than one superclass in a `subclasses` entry.
|
||||||
|
|
||||||
Go callbacks for overridden methods are passed a special struct
|
Go callbacks for overridden methods are passed a special struct filled with
|
||||||
as their first parameter. This struct is filled with superclass methods, which
|
superclass methods, which allows you to do things like this:
|
||||||
allows you to do things like this:
|
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func methodCallback(super ns.MyClassSupermethods, param NSString) {
|
func methodCallback(self ns.MyClass, super ns.MyClassSupermethods, param NSString) {
|
||||||
...
|
...
|
||||||
super.Method(param)
|
super.Method(param)
|
||||||
}
|
}
|
||||||
@@ -708,7 +712,7 @@ subclasses:
|
|||||||
```
|
```
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func pressed() {
|
func pressed(self ns.GButton, super ns.GButtonSupermethods) {
|
||||||
fmt.Println("Button pressed!")
|
fmt.Println("Button pressed!")
|
||||||
}
|
}
|
||||||
...
|
...
|
||||||
@@ -728,9 +732,109 @@ Later on you can add your new button to a view and tell Cocoa where to lay
|
|||||||
it out. It's all a little verbose, but that's because for some reason you
|
it out. It's all a little verbose, but that's because for some reason you
|
||||||
decided to write Objective-C code in Go.
|
decided to write Objective-C code in Go.
|
||||||
|
|
||||||
|
## Memory management
|
||||||
|
|
||||||
|
As mentioned above, NSWrap is designed for there to be at least one Go pointer
|
||||||
|
associated with each underlying Objective-C object pointer.
|
||||||
|
Since Objective-C memory
|
||||||
|
is always allocated by the Objective-C runtime, it is not possible for the Go
|
||||||
|
runtime to have visibility into these memory regions or to directly manage memory
|
||||||
|
used by the CGo code. However, Go will keep track of the associated Go pointer
|
||||||
|
that was created the first time the corresponding Objective-C object was passed
|
||||||
|
over to the Go side and an `Id` or other NSWrap struct type was allocated.
|
||||||
|
Because of this,
|
||||||
|
it is possible to hook into the Go garbage collection system in an attempt to
|
||||||
|
manage Objective-C memory strictly from the Go side. When there are no remaining Go
|
||||||
|
pointers to an NSWrap `Id` struct, it will be deallocated by the Go garbage collector
|
||||||
|
and a finalizer will be called that `release`es the corresponding Objective-C
|
||||||
|
object.
|
||||||
|
|
||||||
|
The memory management rules work as follows:
|
||||||
|
|
||||||
|
* Objects in Go are represented by pointers to types that implement the `NSObject`
|
||||||
|
interface
|
||||||
|
* NSObject has one method, `Ptr()`, which returns an `unsafe.Pointer` to an
|
||||||
|
Objective-C object.
|
||||||
|
* All methods that return objects to Go call `retain` except for `new`, `init`,
|
||||||
|
`alloc`, `copy` and `mutableCopy`, which already return retained objects from the
|
||||||
|
Objective-C runtime.
|
||||||
|
* Go wrappers for Objective-C methods call `runtime.SetFinalizer()`, which calls
|
||||||
|
`release` when the associated Go struct is garbage collected.
|
||||||
|
* All Objective-C methods are run inside an `@autoreleasepool {}` block to prevent
|
||||||
|
internal memory leaks within the Objective-C libraries and frameworks.
|
||||||
|
* Objects sent to you in callback functions are not memory managed by Go
|
||||||
|
and must be manually
|
||||||
|
managed using `Retain()` and `Release()` methods if you need to take ownership of them.
|
||||||
|
A rule of thumb is that if you assign such an object to a persistent Go variable for
|
||||||
|
use outside of the callback, call `Retain()`.
|
||||||
|
|
||||||
|
Because of the linkage with the Go garbage collector described above, there should be
|
||||||
|
no need for any memory management code to be written from the Go side, except in the
|
||||||
|
case mentioned above where your Go delegate receives objects that need to be kept
|
||||||
|
around outside of the callback.
|
||||||
|
|
||||||
|
Since everything in Objective C inherits methods from `NSObject`, you can call
|
||||||
|
`Retain()`, `Release()` and `Autorelease()` on any object. You can technically bind
|
||||||
|
the `NSAutoreleasePool` class and create and drain instances of it from the Go side,
|
||||||
|
but this is not recommended in the default, garbage collected mode and can run into
|
||||||
|
problems because the Go runtime is inherently multithreaded. See `examples/memory`
|
||||||
|
for an example of manual memory management, which should be possible to do reliably
|
||||||
|
but I'm not sure why you would go through the trouble.
|
||||||
|
|
||||||
|
NSWrap is doing a number of things behind the scenes to make garbage collection work.
|
||||||
|
As mentioned,
|
||||||
|
all Objective-C methods are called within an `@autorelease {}` block. This is
|
||||||
|
necessary because some foundation classes (notably `NSString`) create internal
|
||||||
|
objects that are `autoreleased` but never returned to the caller. These objects can
|
||||||
|
never be deallocated unless the method in question was called within an autorelease
|
||||||
|
pool.
|
||||||
|
|
||||||
|
NSWrap assumes you
|
||||||
|
are going to take ownership of every Objective-C object returned by a method, either
|
||||||
|
directly as a return value or through a pointer to a pointer given as a parameter.
|
||||||
|
Therefore, NSWrap calls `retain` on all of these objects before going back to the
|
||||||
|
Go side, unless the object is either `nil` or equivalent to the input object.
|
||||||
|
NSWrap also will not call `retain` on the return values of `init`, `new`, `copy`,
|
||||||
|
`mutableCopy` or `alloc` methods. If you do not want ownership of the object,
|
||||||
|
simply assign it to a local varable and the garbage collector will take care of
|
||||||
|
releasing it.
|
||||||
|
|
||||||
|
In
|
||||||
|
order for this to work on a pointer to a pointer parameter, NSWrap treats the
|
||||||
|
input
|
||||||
|
parameter as an array with a length specified by either a `range` parameter (of
|
||||||
|
type `NSRange`) or a `count` parameter of an integer type. If there is neither a
|
||||||
|
`range` or `count` parameter, NSWrap assumes the array is length 1.
|
||||||
|
|
||||||
|
As an example, in Objective-C, if you were to take an object out of an `NSArray`
|
||||||
|
and the array was later deallocated, there is no guarantee that the object you
|
||||||
|
obtained is still around unless you called `retain` on it. This is not necessary
|
||||||
|
with NSWrap, which automatically retains objects returned by methods like
|
||||||
|
`objectAtIndex:` and `getObjects:range` and manages them with the Go garbage
|
||||||
|
collector.
|
||||||
|
|
||||||
|
The methods described above work for methods that return Objective-C
|
||||||
|
objects, which can be `retain`ed, but not with methods that return other types of
|
||||||
|
pointers such as C strings. NSWrap has a special case for C strings (`*Char`
|
||||||
|
in Go), calling
|
||||||
|
`strdup` on the return value within the `@autoreleasepool` block. This
|
||||||
|
ensures that the string is preserved even if it points to a termporary
|
||||||
|
autoreleased
|
||||||
|
object. Since this behavior results in newly allocated memory, these pointers will
|
||||||
|
need to be freed from Go later on. Since these are pointers to C memory,
|
||||||
|
it is not possible to set a finalizer on these pointers for garbage collection
|
||||||
|
by Go.
|
||||||
|
|
||||||
|
Note that the Go garbage collector is lazy and will not activate unless your
|
||||||
|
application is running low on heap space. That means in practice that Objective-C
|
||||||
|
objects are going to stick around a lot longer than they might in a pure
|
||||||
|
Objective-C application. If this is an issue, simply run the Go GC manually with
|
||||||
|
`runtime.GC()`.
|
||||||
|
|
||||||
|
|
||||||
# Limitations
|
# Limitations
|
||||||
|
|
||||||
## Blocks
|
## Blocks and Function Pointers
|
||||||
|
|
||||||
NSWrap does not support methods or functions that take C functions or blocks
|
NSWrap does not support methods or functions that take C functions or blocks
|
||||||
as parameters or return values.
|
as parameters or return values.
|
||||||
@@ -742,7 +846,7 @@ and got carried away.
|
|||||||
|
|
||||||
# Acknowledgements
|
# Acknowledgements
|
||||||
|
|
||||||
This work was inspired by Maxim's excellent
|
This work was inspired by Maxim Kupriianov's excellent
|
||||||
[c-for-go](https://github.com/xlab/c-for-go). Much of the
|
[c-for-go](https://github.com/xlab/c-for-go). Much of the
|
||||||
infrastructure was lifted from Elliot Chance's equally excellent
|
infrastructure was lifted from Elliot Chance's equally excellent
|
||||||
[c2go](https://github.com/elliotchance/c2go). Kiyoshi Murata's
|
[c2go](https://github.com/elliotchance/c2go). Kiyoshi Murata's
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestAlignedAttr(t *testing.T) {
|
func TestAlignedAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f8a1d8ccfd0 <col:47, col:57> aligned`:
|
`0x7f8a1d8ccfd0 <col:47, col:57> aligned`: testNode{&AlignedAttr{
|
||||||
testNode{&AlignedAttr{
|
|
||||||
Addr: 0x7f8a1d8ccfd0,
|
Addr: 0x7f8a1d8ccfd0,
|
||||||
Pos: NewPositionFromString("col:47, col:57"),
|
Pos: NewPositionFromString("col:47, col:57"),
|
||||||
IsAligned: true,
|
IsAligned: true,
|
||||||
@@ -17,7 +16,7 @@ func TestAlignedAttr(t *testing.T) {
|
|||||||
NewPositionFromString("col:47, col:57"),
|
NewPositionFromString("col:47, col:57"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x2c8ba10 <col:42>`: testNode{ &AlignedAttr{
|
`0x2c8ba10 <col:42>`: testNode{&AlignedAttr{
|
||||||
Addr: 0x2c8ba10,
|
Addr: 0x2c8ba10,
|
||||||
Pos: NewPositionFromString("col:42"),
|
Pos: NewPositionFromString("col:42"),
|
||||||
IsAligned: false,
|
IsAligned: false,
|
||||||
@@ -31,4 +30,3 @@ func TestAlignedAttr(t *testing.T) {
|
|||||||
|
|
||||||
runNodeTests(t, nodes)
|
runNodeTests(t, nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package ast
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
//"git.wow.st/gmp/nswrap/util"
|
//"git.wow.st/gmp/nswrap/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestAllocSizeAttr(t *testing.T) {
|
func TestAllocSizeAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f8e390a5d38 <col:100, col:114> 1 2`:
|
`0x7f8e390a5d38 <col:100, col:114> 1 2`: testNode{&AllocSizeAttr{
|
||||||
testNode{&AllocSizeAttr{
|
|
||||||
Addr: 0x7f8e390a5d38,
|
Addr: 0x7f8e390a5d38,
|
||||||
Pos: NewPositionFromString("col:100, col:114"),
|
Pos: NewPositionFromString("col:100, col:114"),
|
||||||
A: "1",
|
A: "1",
|
||||||
@@ -18,8 +17,7 @@ func TestAllocSizeAttr(t *testing.T) {
|
|||||||
NewPositionFromString("col:100, col:114"),
|
NewPositionFromString("col:100, col:114"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fbd1a167f48 </usr/include/stdlib.h:342:37> Inherited 1 0`:
|
`0x7fbd1a167f48 </usr/include/stdlib.h:342:37> Inherited 1 0`: testNode{&AllocSizeAttr{
|
||||||
testNode{&AllocSizeAttr{
|
|
||||||
Addr: 0x7fbd1a167f48,
|
Addr: 0x7fbd1a167f48,
|
||||||
Pos: NewPositionFromString("/usr/include/stdlib.h:342:37"),
|
Pos: NewPositionFromString("/usr/include/stdlib.h:342:37"),
|
||||||
Inherited: true,
|
Inherited: true,
|
||||||
@@ -31,8 +29,7 @@ func TestAllocSizeAttr(t *testing.T) {
|
|||||||
NewPositionFromString("/usr/include/stdlib.h:342:37"),
|
NewPositionFromString("/usr/include/stdlib.h:342:37"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fbd1a167f48 </usr/include/stdlib.h:342:37> Inherited 1`:
|
`0x7fbd1a167f48 </usr/include/stdlib.h:342:37> Inherited 1`: testNode{&AllocSizeAttr{
|
||||||
testNode{&AllocSizeAttr{
|
|
||||||
Addr: 0x7fbd1a167f48,
|
Addr: 0x7fbd1a167f48,
|
||||||
Pos: NewPositionFromString("/usr/include/stdlib.h:342:37"),
|
Pos: NewPositionFromString("/usr/include/stdlib.h:342:37"),
|
||||||
Inherited: true,
|
Inherited: true,
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestAlwaysInlineAttr(t *testing.T) {
|
func TestAlwaysInlineAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fce780f5018 </usr/include/sys/cdefs.h:313:68> always_inline`:
|
`0x7fce780f5018 </usr/include/sys/cdefs.h:313:68> always_inline`: testNode{&AlwaysInlineAttr{
|
||||||
testNode{&AlwaysInlineAttr{
|
|
||||||
Addr: 0x7fce780f5018,
|
Addr: 0x7fce780f5018,
|
||||||
Pos: NewPositionFromString("/usr/include/sys/cdefs.h:313:68"),
|
Pos: NewPositionFromString("/usr/include/sys/cdefs.h:313:68"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestArcWeakrefUnavailableAttr(t *testing.T) {
|
func TestArcWeakrefUnavailableAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7>`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7>`: testNode{&ArcWeakrefUnavailableAttr{
|
||||||
testNode{&ArcWeakrefUnavailableAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
func TestArrayFiller(t *testing.T) {
|
func TestArrayFiller(t *testing.T) {
|
||||||
i := 0
|
i := 0
|
||||||
runNodeTest(t, Parse(`array filler`),
|
runNodeTest(t, Parse(`array filler`),
|
||||||
testNode{ &ArrayFiller{ ChildNodes: []Node{} },
|
testNode{&ArrayFiller{ChildNodes: []Node{}},
|
||||||
0,NewPositionFromString(""),[]Node{}},
|
0, NewPositionFromString(""), []Node{}},
|
||||||
&i)
|
&i)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestArraySubscriptExpr(t *testing.T) {
|
func TestArraySubscriptExpr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fe35b85d180 <col:63, col:69> 'char *' lvalue`:
|
`0x7fe35b85d180 <col:63, col:69> 'char *' lvalue`: testNode{&ArraySubscriptExpr{
|
||||||
testNode{&ArraySubscriptExpr{
|
|
||||||
Addr: 0x7fe35b85d180,
|
Addr: 0x7fe35b85d180,
|
||||||
Pos: NewPositionFromString("col:63, col:69"),
|
Pos: NewPositionFromString("col:63, col:69"),
|
||||||
Type: "char *",
|
Type: "char *",
|
||||||
@@ -19,8 +18,7 @@ func TestArraySubscriptExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:63, col:69"),
|
NewPositionFromString("col:63, col:69"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x2416660 <col:2, col:5> 'u32':'unsigned int' lvalue`:
|
`0x2416660 <col:2, col:5> 'u32':'unsigned int' lvalue`: testNode{&ArraySubscriptExpr{
|
||||||
testNode{&ArraySubscriptExpr{
|
|
||||||
Addr: 0x2416660,
|
Addr: 0x2416660,
|
||||||
Pos: NewPositionFromString("col:2, col:5"),
|
Pos: NewPositionFromString("col:2, col:5"),
|
||||||
Type: "u32",
|
Type: "u32",
|
||||||
@@ -32,8 +30,7 @@ func TestArraySubscriptExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:2, col:5"),
|
NewPositionFromString("col:2, col:5"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x3f147c0 <col:39, col:55> 'extCoord':'extCoord' lvalue`:
|
`0x3f147c0 <col:39, col:55> 'extCoord':'extCoord' lvalue`: testNode{&ArraySubscriptExpr{
|
||||||
testNode{&ArraySubscriptExpr{
|
|
||||||
Addr: 0x3f147c0,
|
Addr: 0x3f147c0,
|
||||||
Pos: NewPositionFromString("col:39, col:55"),
|
Pos: NewPositionFromString("col:39, col:55"),
|
||||||
Type: "extCoord",
|
Type: "extCoord",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ type AsmLabelAttr struct {
|
|||||||
Addr Address
|
Addr Address
|
||||||
Pos Position
|
Pos Position
|
||||||
Inherited bool
|
Inherited bool
|
||||||
|
LiteralLabel bool
|
||||||
FunctionName string
|
FunctionName string
|
||||||
ChildNodes []Node
|
ChildNodes []Node
|
||||||
}
|
}
|
||||||
@@ -13,7 +14,8 @@ func parseAsmLabelAttr(line string) Node {
|
|||||||
groups := groupsFromRegex(
|
groups := groupsFromRegex(
|
||||||
`<(?P<position>.*)>
|
`<(?P<position>.*)>
|
||||||
(?P<inherited> Inherited)?
|
(?P<inherited> Inherited)?
|
||||||
"(?P<function>.+)"`,
|
"(?P<function>.+)"
|
||||||
|
(?P<isliterallabel> IsLiteralLabel)?`,
|
||||||
line,
|
line,
|
||||||
)
|
)
|
||||||
if groups == nil {
|
if groups == nil {
|
||||||
@@ -24,6 +26,7 @@ func parseAsmLabelAttr(line string) Node {
|
|||||||
Addr: ParseAddress(groups["address"]),
|
Addr: ParseAddress(groups["address"]),
|
||||||
Pos: NewPositionFromString(groups["position"]),
|
Pos: NewPositionFromString(groups["position"]),
|
||||||
Inherited: len(groups["inherited"]) > 0,
|
Inherited: len(groups["inherited"]) > 0,
|
||||||
|
LiteralLabel: len(groups["isliterallabel"]) > 0,
|
||||||
FunctionName: groups["function"],
|
FunctionName: groups["function"],
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import (
|
|||||||
|
|
||||||
func TestAsmLabelAttr(t *testing.T) {
|
func TestAsmLabelAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7ff26d8224e8 </usr/include/sys/cdefs.h:569:36> "_fopen"`:
|
`0x7ff26d8224e8 </usr/include/sys/cdefs.h:569:36> "_fopen"`: testNode{&AsmLabelAttr{
|
||||||
testNode{&AsmLabelAttr{
|
|
||||||
Addr: 0x7ff26d8224e8,
|
Addr: 0x7ff26d8224e8,
|
||||||
Pos: NewPositionFromString("/usr/include/sys/cdefs.h:569:36"),
|
Pos: NewPositionFromString("/usr/include/sys/cdefs.h:569:36"),
|
||||||
Inherited: false,
|
Inherited: false,
|
||||||
|
LiteralLabel: false,
|
||||||
FunctionName: "_fopen",
|
FunctionName: "_fopen",
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
},
|
},
|
||||||
@@ -18,11 +18,11 @@ func TestAsmLabelAttr(t *testing.T) {
|
|||||||
NewPositionFromString("/usr/include/sys/cdefs.h:569:36"),
|
NewPositionFromString("/usr/include/sys/cdefs.h:569:36"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fd55a169318 </usr/include/stdio.h:325:47> Inherited "_popen"`:
|
`0x7fd55a169318 </usr/include/stdio.h:325:47> Inherited "_popen"`: testNode{&AsmLabelAttr{
|
||||||
testNode{&AsmLabelAttr{
|
|
||||||
Addr: 0x7fd55a169318,
|
Addr: 0x7fd55a169318,
|
||||||
Pos: NewPositionFromString("/usr/include/stdio.h:325:47"),
|
Pos: NewPositionFromString("/usr/include/stdio.h:325:47"),
|
||||||
Inherited: true,
|
Inherited: true,
|
||||||
|
LiteralLabel: false,
|
||||||
FunctionName: "_popen",
|
FunctionName: "_popen",
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
},
|
},
|
||||||
@@ -30,6 +30,18 @@ func TestAsmLabelAttr(t *testing.T) {
|
|||||||
NewPositionFromString("/usr/include/stdio.h:325:47"),
|
NewPositionFromString("/usr/include/stdio.h:325:47"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
|
`0x7fd55a169318 </usr/include/stdio.h:325:47> "_kill" IsLiteralLabel`: testNode{&AsmLabelAttr{
|
||||||
|
Addr: 0x7fd55a169318,
|
||||||
|
Pos: NewPositionFromString("/usr/include/stdio.h:325:47"),
|
||||||
|
Inherited: false,
|
||||||
|
LiteralLabel: true,
|
||||||
|
FunctionName: "_kill",
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
},
|
||||||
|
0x7fd55a169318,
|
||||||
|
NewPositionFromString("/usr/include/stdio.h:325:47"),
|
||||||
|
[]Node{},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
runNodeTests(t, nodes)
|
runNodeTests(t, nodes)
|
||||||
|
|||||||
+11
-3
@@ -89,10 +89,14 @@ func Parse(fullline string) Node {
|
|||||||
return parseBlockPointerType(line)
|
return parseBlockPointerType(line)
|
||||||
case "BreakStmt":
|
case "BreakStmt":
|
||||||
return parseBreakStmt(line)
|
return parseBreakStmt(line)
|
||||||
|
case "BuiltinAttr":
|
||||||
|
return parseBuiltinAttr(line)
|
||||||
case "BuiltinType":
|
case "BuiltinType":
|
||||||
return parseBuiltinType(line)
|
return parseBuiltinType(line)
|
||||||
case "CallExpr":
|
case "CallExpr":
|
||||||
return parseCallExpr(line)
|
return parseCallExpr(line)
|
||||||
|
case "ConstantExpr":
|
||||||
|
return parseConstantExpr(line)
|
||||||
case "ConvertVectorExpr":
|
case "ConvertVectorExpr":
|
||||||
return parseConvertVectorExpr(line)
|
return parseConvertVectorExpr(line)
|
||||||
case "CaseStmt":
|
case "CaseStmt":
|
||||||
@@ -107,6 +111,8 @@ func Parse(fullline string) Node {
|
|||||||
return parseCFReturnsNotRetainedAttr(line)
|
return parseCFReturnsNotRetainedAttr(line)
|
||||||
case "CharacterLiteral":
|
case "CharacterLiteral":
|
||||||
return parseCharacterLiteral(line)
|
return parseCharacterLiteral(line)
|
||||||
|
case "ColdAttr":
|
||||||
|
return parseColdAttr(line)
|
||||||
case "CompoundLiteralExpr":
|
case "CompoundLiteralExpr":
|
||||||
return parseCompoundLiteralExpr(line)
|
return parseCompoundLiteralExpr(line)
|
||||||
case "CompoundStmt":
|
case "CompoundStmt":
|
||||||
@@ -252,9 +258,9 @@ func Parse(fullline string) Node {
|
|||||||
case "ObjCIndependentClassAttr":
|
case "ObjCIndependentClassAttr":
|
||||||
return parseObjCIndependentClassAttr(line)
|
return parseObjCIndependentClassAttr(line)
|
||||||
case "ObjCInterface":
|
case "ObjCInterface":
|
||||||
return parseObjCInterface(line,false)
|
return parseObjCInterface(line, false)
|
||||||
case "super ObjCInterface":
|
case "super ObjCInterface":
|
||||||
return parseObjCInterface(line,true)
|
return parseObjCInterface(line, true)
|
||||||
case "ObjCInterfaceDecl":
|
case "ObjCInterfaceDecl":
|
||||||
return parseObjCInterfaceDecl(line)
|
return parseObjCInterfaceDecl(line)
|
||||||
case "ObjCInterfaceType":
|
case "ObjCInterfaceType":
|
||||||
@@ -285,6 +291,8 @@ func Parse(fullline string) Node {
|
|||||||
return parseObjCRootClassAttr(line)
|
return parseObjCRootClassAttr(line)
|
||||||
case "ObjCPropertyDecl":
|
case "ObjCPropertyDecl":
|
||||||
return parseObjCPropertyDecl(line)
|
return parseObjCPropertyDecl(line)
|
||||||
|
case "ObjCTypeParam":
|
||||||
|
return parseObjCTypeParam(line)
|
||||||
case "ObjCTypeParamDecl":
|
case "ObjCTypeParamDecl":
|
||||||
return parseObjCTypeParamDecl(line)
|
return parseObjCTypeParamDecl(line)
|
||||||
case "OffsetOfExpr":
|
case "OffsetOfExpr":
|
||||||
@@ -394,7 +402,7 @@ func Parse(fullline string) Node {
|
|||||||
case "NullStmt":
|
case "NullStmt":
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
return parseUnknown(nodeName,line)
|
return parseUnknown(nodeName, line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-9
@@ -30,24 +30,24 @@ func formatMultiLine(o interface{}) string {
|
|||||||
|
|
||||||
func runNodeTest(t *testing.T, actual Node, expected testNode, i *int) {
|
func runNodeTest(t *testing.T, actual Node, expected testNode, i *int) {
|
||||||
testName := fmt.Sprintf("Example%d", *i)
|
testName := fmt.Sprintf("Example%d", *i)
|
||||||
t.Run(testName + "a", func(t *testing.T) {
|
t.Run(testName+"a", func(t *testing.T) {
|
||||||
if !reflect.DeepEqual(expected.n, actual) {
|
if !reflect.DeepEqual(expected.n, actual) {
|
||||||
t.Errorf("%s", util.ShowDiff(formatMultiLine(expected.n),
|
t.Errorf("%s", util.ShowDiff(formatMultiLine(expected.n),
|
||||||
formatMultiLine(actual)))
|
formatMultiLine(actual)))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.Run(testName+"b", func(t *testing.T) {
|
t.Run(testName+"b", func(t *testing.T) {
|
||||||
if !reflect.DeepEqual(actual.Address(),expected.addr) {
|
if !reflect.DeepEqual(actual.Address(), expected.addr) {
|
||||||
t.Errorf("Address mismatch")
|
t.Errorf("Address mismatch")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.Run(testName+"c", func(t *testing.T) {
|
t.Run(testName+"c", func(t *testing.T) {
|
||||||
if !reflect.DeepEqual(actual.Position(),expected.pos) {
|
if !reflect.DeepEqual(actual.Position(), expected.pos) {
|
||||||
t.Errorf("Position mismatch")
|
t.Errorf("Position mismatch")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.Run(testName+"d", func(t *testing.T) {
|
t.Run(testName+"d", func(t *testing.T) {
|
||||||
if !reflect.DeepEqual(actual.Children(),expected.children) {
|
if !reflect.DeepEqual(actual.Children(), expected.children) {
|
||||||
t.Errorf("Children mismatch")
|
t.Errorf("Children mismatch")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -55,8 +55,8 @@ func runNodeTest(t *testing.T, actual Node, expected testNode, i *int) {
|
|||||||
cs := expected.children
|
cs := expected.children
|
||||||
node := &Unknown{}
|
node := &Unknown{}
|
||||||
actual.AddChild(node)
|
actual.AddChild(node)
|
||||||
cs = append(cs,node)
|
cs = append(cs, node)
|
||||||
if !reflect.DeepEqual(actual.Children(),cs) {
|
if !reflect.DeepEqual(actual.Children(), cs) {
|
||||||
t.Errorf("Children mismatch")
|
t.Errorf("Children mismatch")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -71,7 +71,7 @@ func runNodeTests(t *testing.T, tests map[string]testNode) {
|
|||||||
name := reflect.TypeOf(expected.n).Elem().Name()
|
name := reflect.TypeOf(expected.n).Elem().Name()
|
||||||
actual := Parse(name + " " + line)
|
actual := Parse(name + " " + line)
|
||||||
|
|
||||||
runNodeTest(t,actual,expected,&i)
|
runNodeTest(t, actual, expected, &i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ func TestPrint(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var lines = []string{
|
var lines = []string{
|
||||||
// c2go ast sqlite3.c | head -5000 | sed 's/^[ |`-]*//' | sed 's/<<<NULL>>>/NullStmt/g' | gawk 'length > 0 {print "`" $0 "`,"}'
|
// c2go ast sqlite3.c | head -5000 | sed 's/^[ |`-]*//' | sed 's/<<<NULL>>>/NullStmt/g' | gawk 'length > 0 {print "`" $0 "`,"}'
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkParse(b *testing.B) {
|
func BenchmarkParse(b *testing.B) {
|
||||||
@@ -106,4 +106,3 @@ func BenchmarkParse(b *testing.B) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func parseAttributedType(line string) Node {
|
|||||||
return &AttributedType{
|
return &AttributedType{
|
||||||
Addr: ParseAddress(groups["address"]),
|
Addr: ParseAddress(groups["address"]),
|
||||||
Type: groups["type"],
|
Type: groups["type"],
|
||||||
Sugar: len(groups["sugar"])>0,
|
Sugar: len(groups["sugar"]) > 0,
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestAttributedType(t *testing.T) {
|
func TestAttributedType(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x10c0d6770 'CVDisplayLinkRef _Nonnull' sugar`:
|
`0x10c0d6770 'CVDisplayLinkRef _Nonnull' sugar`: testNode{&AttributedType{
|
||||||
testNode{&AttributedType{
|
|
||||||
Addr: 0x10c0d6770,
|
Addr: 0x10c0d6770,
|
||||||
Type: `CVDisplayLinkRef _Nonnull`,
|
Type: `CVDisplayLinkRef _Nonnull`,
|
||||||
Sugar: true,
|
Sugar: true,
|
||||||
@@ -17,8 +16,7 @@ func TestAttributedType(t *testing.T) {
|
|||||||
NewPositionFromString(""),
|
NewPositionFromString(""),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x10c0d68b0 'const CVTimeStamp * _Nonnull' sugar`:
|
`0x10c0d68b0 'const CVTimeStamp * _Nonnull' sugar`: testNode{&AttributedType{
|
||||||
testNode{&AttributedType{
|
|
||||||
Addr: 0x10c0d68b0,
|
Addr: 0x10c0d68b0,
|
||||||
Type: `const CVTimeStamp * _Nonnull`,
|
Type: `const CVTimeStamp * _Nonnull`,
|
||||||
Sugar: true,
|
Sugar: true,
|
||||||
@@ -28,8 +26,7 @@ func TestAttributedType(t *testing.T) {
|
|||||||
NewPositionFromString(""),
|
NewPositionFromString(""),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x10c0d6ab0 'CVOptionFlags * _Nonnull' sugar`:
|
`0x10c0d6ab0 'CVOptionFlags * _Nonnull' sugar`: testNode{&AttributedType{
|
||||||
testNode{&AttributedType{
|
|
||||||
Addr: 0x10c0d6ab0,
|
Addr: 0x10c0d6ab0,
|
||||||
Type: `CVOptionFlags * _Nonnull`,
|
Type: `CVOptionFlags * _Nonnull`,
|
||||||
Sugar: true,
|
Sugar: true,
|
||||||
@@ -39,8 +36,7 @@ func TestAttributedType(t *testing.T) {
|
|||||||
NewPositionFromString(""),
|
NewPositionFromString(""),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x10c0fc7d0 'CVPixelBufferRef _Nonnull' sugar`:
|
`0x10c0fc7d0 'CVPixelBufferRef _Nonnull' sugar`: testNode{&AttributedType{
|
||||||
testNode{&AttributedType{
|
|
||||||
Addr: 0x10c0fc7d0,
|
Addr: 0x10c0fc7d0,
|
||||||
Type: `CVPixelBufferRef _Nonnull`,
|
Type: `CVPixelBufferRef _Nonnull`,
|
||||||
Sugar: true,
|
Sugar: true,
|
||||||
@@ -50,8 +46,7 @@ func TestAttributedType(t *testing.T) {
|
|||||||
NewPositionFromString(""),
|
NewPositionFromString(""),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7faa1906d680 'NSError * _Nullable' sugar`:
|
`0x7faa1906d680 'NSError * _Nullable' sugar`: testNode{&AttributedType{
|
||||||
testNode{&AttributedType{
|
|
||||||
Addr: 0x7faa1906d680,
|
Addr: 0x7faa1906d680,
|
||||||
Type: `NSError * _Nullable`,
|
Type: `NSError * _Nullable`,
|
||||||
Sugar: true,
|
Sugar: true,
|
||||||
@@ -61,8 +56,7 @@ func TestAttributedType(t *testing.T) {
|
|||||||
NewPositionFromString(""),
|
NewPositionFromString(""),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7faa19085760 'id<NSSecureCoding> _Nullable' sugar`:
|
`0x7faa19085760 'id<NSSecureCoding> _Nullable' sugar`: testNode{&AttributedType{
|
||||||
testNode{&AttributedType{
|
|
||||||
Addr: 0x7faa19085760,
|
Addr: 0x7faa19085760,
|
||||||
Type: `id<NSSecureCoding> _Nullable`,
|
Type: `id<NSSecureCoding> _Nullable`,
|
||||||
Sugar: true,
|
Sugar: true,
|
||||||
@@ -72,8 +66,7 @@ func TestAttributedType(t *testing.T) {
|
|||||||
NewPositionFromString(""),
|
NewPositionFromString(""),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7faa19085840 'NSError * _Null_unspecified' sugar`:
|
`0x7faa19085840 'NSError * _Null_unspecified' sugar`: testNode{&AttributedType{
|
||||||
testNode{&AttributedType{
|
|
||||||
Addr: 0x7faa19085840,
|
Addr: 0x7faa19085840,
|
||||||
Type: `NSError * _Null_unspecified`,
|
Type: `NSError * _Null_unspecified`,
|
||||||
Sugar: true,
|
Sugar: true,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ type AvailabilityAttr struct {
|
|||||||
Version string
|
Version string
|
||||||
Unknown1 string
|
Unknown1 string
|
||||||
Unknown2 string
|
Unknown2 string
|
||||||
|
Unknown3 string
|
||||||
IsUnavailable bool
|
IsUnavailable bool
|
||||||
Message1 string
|
Message1 string
|
||||||
Message2 string
|
Message2 string
|
||||||
@@ -26,7 +27,7 @@ func parseAvailabilityAttr(line string) Node {
|
|||||||
(?P<unknown2>[\d_.]+)
|
(?P<unknown2>[\d_.]+)
|
||||||
(?P<unavalable> Unavailable)?
|
(?P<unavalable> Unavailable)?
|
||||||
"(?P<message1>.*?)"
|
"(?P<message1>.*?)"
|
||||||
(?P<message2> ".*?")?`,
|
(?P<message2> ".*?")?( (?P<unknown3>[\d_.]+))?`,
|
||||||
line,
|
line,
|
||||||
)
|
)
|
||||||
if groups == nil {
|
if groups == nil {
|
||||||
@@ -40,6 +41,7 @@ func parseAvailabilityAttr(line string) Node {
|
|||||||
Version: groups["version"],
|
Version: groups["version"],
|
||||||
Unknown1: groups["unknown1"],
|
Unknown1: groups["unknown1"],
|
||||||
Unknown2: groups["unknown2"],
|
Unknown2: groups["unknown2"],
|
||||||
|
Unknown3: groups["unknown3"],
|
||||||
IsUnavailable: len(groups["unavalable"]) > 0,
|
IsUnavailable: len(groups["unavalable"]) > 0,
|
||||||
Message1: removeQuotes(groups["message1"]),
|
Message1: removeQuotes(groups["message1"]),
|
||||||
Message2: removeQuotes(groups["message2"]),
|
Message2: removeQuotes(groups["message2"]),
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ import (
|
|||||||
|
|
||||||
func TestAvailabilityAttr(t *testing.T) {
|
func TestAvailabilityAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc5ff8e5d18 </usr/include/AvailabilityInternal.h:21697:88, col:124> macos 10.10 0 0 "" ""`:
|
`0x7fc5ff8e5d18 </usr/include/AvailabilityInternal.h:21697:88, col:124> macos 10.10 0 0 "" ""`: testNode{&AvailabilityAttr{
|
||||||
testNode{&AvailabilityAttr{
|
|
||||||
Addr: 0x7fc5ff8e5d18,
|
Addr: 0x7fc5ff8e5d18,
|
||||||
Pos: NewPositionFromString("/usr/include/AvailabilityInternal.h:21697:88, col:124"),
|
Pos: NewPositionFromString("/usr/include/AvailabilityInternal.h:21697:88, col:124"),
|
||||||
OS: "macos",
|
OS: "macos",
|
||||||
Version: "10.10",
|
Version: "10.10",
|
||||||
Unknown1: "0",
|
Unknown1: "0",
|
||||||
Unknown2: "0",
|
Unknown2: "0",
|
||||||
|
Unknown3: "",
|
||||||
IsUnavailable: false,
|
IsUnavailable: false,
|
||||||
Message1: "",
|
Message1: "",
|
||||||
Message2: "",
|
Message2: "",
|
||||||
@@ -24,14 +24,14 @@ func TestAvailabilityAttr(t *testing.T) {
|
|||||||
NewPositionFromString("/usr/include/AvailabilityInternal.h:21697:88, col:124"),
|
NewPositionFromString("/usr/include/AvailabilityInternal.h:21697:88, col:124"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fc5ff8e60d0 </usr/include/Availability.h:215:81, col:115> watchos 3.0 0 0 "" ""`:
|
`0x7fc5ff8e60d0 </usr/include/Availability.h:215:81, col:115> watchos 3.0 0 0 "" ""`: testNode{&AvailabilityAttr{
|
||||||
testNode{&AvailabilityAttr{
|
|
||||||
Addr: 0x7fc5ff8e60d0,
|
Addr: 0x7fc5ff8e60d0,
|
||||||
Pos: NewPositionFromString("/usr/include/Availability.h:215:81, col:115"),
|
Pos: NewPositionFromString("/usr/include/Availability.h:215:81, col:115"),
|
||||||
OS: "watchos",
|
OS: "watchos",
|
||||||
Version: "3.0",
|
Version: "3.0",
|
||||||
Unknown1: "0",
|
Unknown1: "0",
|
||||||
Unknown2: "0",
|
Unknown2: "0",
|
||||||
|
Unknown3: "",
|
||||||
IsUnavailable: false,
|
IsUnavailable: false,
|
||||||
Message1: "",
|
Message1: "",
|
||||||
Message2: "",
|
Message2: "",
|
||||||
@@ -42,14 +42,14 @@ func TestAvailabilityAttr(t *testing.T) {
|
|||||||
NewPositionFromString("/usr/include/Availability.h:215:81, col:115"),
|
NewPositionFromString("/usr/include/Availability.h:215:81, col:115"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fc5ff8e6170 <col:81, col:115> tvos 10.0 0 0 "" ""`:
|
`0x7fc5ff8e6170 <col:81, col:115> tvos 10.0 0 0 "" ""`: testNode{&AvailabilityAttr{
|
||||||
testNode{&AvailabilityAttr{
|
|
||||||
Addr: 0x7fc5ff8e6170,
|
Addr: 0x7fc5ff8e6170,
|
||||||
Pos: NewPositionFromString("col:81, col:115"),
|
Pos: NewPositionFromString("col:81, col:115"),
|
||||||
OS: "tvos",
|
OS: "tvos",
|
||||||
Version: "10.0",
|
Version: "10.0",
|
||||||
Unknown1: "0",
|
Unknown1: "0",
|
||||||
Unknown2: "0",
|
Unknown2: "0",
|
||||||
|
Unknown3: "",
|
||||||
IsUnavailable: false,
|
IsUnavailable: false,
|
||||||
Message1: "",
|
Message1: "",
|
||||||
Message2: "",
|
Message2: "",
|
||||||
@@ -60,14 +60,14 @@ func TestAvailabilityAttr(t *testing.T) {
|
|||||||
NewPositionFromString("col:81, col:115"),
|
NewPositionFromString("col:81, col:115"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fc5ff8e61d8 <col:81, col:115> ios 10.0 0 0 "" ""`:
|
`0x7fc5ff8e61d8 <col:81, col:115> ios 10.0 0 0 "" ""`: testNode{&AvailabilityAttr{
|
||||||
testNode{&AvailabilityAttr{
|
|
||||||
Addr: 0x7fc5ff8e61d8,
|
Addr: 0x7fc5ff8e61d8,
|
||||||
Pos: NewPositionFromString("col:81, col:115"),
|
Pos: NewPositionFromString("col:81, col:115"),
|
||||||
OS: "ios",
|
OS: "ios",
|
||||||
Version: "10.0",
|
Version: "10.0",
|
||||||
Unknown1: "0",
|
Unknown1: "0",
|
||||||
Unknown2: "0",
|
Unknown2: "0",
|
||||||
|
Unknown3: "",
|
||||||
IsUnavailable: false,
|
IsUnavailable: false,
|
||||||
Message1: "",
|
Message1: "",
|
||||||
Message2: "",
|
Message2: "",
|
||||||
@@ -78,14 +78,14 @@ func TestAvailabilityAttr(t *testing.T) {
|
|||||||
NewPositionFromString("col:81, col:115"),
|
NewPositionFromString("col:81, col:115"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fc5ff8f0e18 </usr/include/sys/cdefs.h:275:50, col:99> swift 0 0 0 Unavailable "Use snprintf instead." ""`:
|
`0x7fc5ff8f0e18 </usr/include/sys/cdefs.h:275:50, col:99> swift 0 0 0 Unavailable "Use snprintf instead." ""`: testNode{&AvailabilityAttr{
|
||||||
testNode{&AvailabilityAttr{
|
|
||||||
Addr: 0x7fc5ff8f0e18,
|
Addr: 0x7fc5ff8f0e18,
|
||||||
Pos: NewPositionFromString("/usr/include/sys/cdefs.h:275:50, col:99"),
|
Pos: NewPositionFromString("/usr/include/sys/cdefs.h:275:50, col:99"),
|
||||||
OS: "swift",
|
OS: "swift",
|
||||||
Version: "0",
|
Version: "0",
|
||||||
Unknown1: "0",
|
Unknown1: "0",
|
||||||
Unknown2: "0",
|
Unknown2: "0",
|
||||||
|
Unknown3: "",
|
||||||
IsUnavailable: true,
|
IsUnavailable: true,
|
||||||
Message1: "Use snprintf instead.",
|
Message1: "Use snprintf instead.",
|
||||||
Message2: "",
|
Message2: "",
|
||||||
@@ -96,14 +96,14 @@ func TestAvailabilityAttr(t *testing.T) {
|
|||||||
NewPositionFromString("/usr/include/sys/cdefs.h:275:50, col:99"),
|
NewPositionFromString("/usr/include/sys/cdefs.h:275:50, col:99"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fc5ff8f1988 <line:275:50, col:99> swift 0 0 0 Unavailable "Use mkstemp(3) instead." ""`:
|
`0x7fc5ff8f1988 <line:275:50, col:99> swift 0 0 0 Unavailable "Use mkstemp(3) instead." ""`: testNode{&AvailabilityAttr{
|
||||||
testNode{&AvailabilityAttr{
|
|
||||||
Addr: 0x7fc5ff8f1988,
|
Addr: 0x7fc5ff8f1988,
|
||||||
Pos: NewPositionFromString("line:275:50, col:99"),
|
Pos: NewPositionFromString("line:275:50, col:99"),
|
||||||
OS: "swift",
|
OS: "swift",
|
||||||
Version: "0",
|
Version: "0",
|
||||||
Unknown1: "0",
|
Unknown1: "0",
|
||||||
Unknown2: "0",
|
Unknown2: "0",
|
||||||
|
Unknown3: "",
|
||||||
IsUnavailable: true,
|
IsUnavailable: true,
|
||||||
Message1: "Use mkstemp(3) instead.",
|
Message1: "Use mkstemp(3) instead.",
|
||||||
Message2: "",
|
Message2: "",
|
||||||
@@ -114,14 +114,14 @@ func TestAvailabilityAttr(t *testing.T) {
|
|||||||
NewPositionFromString("line:275:50, col:99"),
|
NewPositionFromString("line:275:50, col:99"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x104035438 </usr/include/AvailabilityInternal.h:14571:88, col:124> macosx 10.10 0 0 ""`:
|
`0x104035438 </usr/include/AvailabilityInternal.h:14571:88, col:124> macosx 10.10 0 0 ""`: testNode{&AvailabilityAttr{
|
||||||
testNode{&AvailabilityAttr{
|
|
||||||
Addr: 0x104035438,
|
Addr: 0x104035438,
|
||||||
Pos: NewPositionFromString("/usr/include/AvailabilityInternal.h:14571:88, col:124"),
|
Pos: NewPositionFromString("/usr/include/AvailabilityInternal.h:14571:88, col:124"),
|
||||||
OS: "macosx",
|
OS: "macosx",
|
||||||
Version: "10.10",
|
Version: "10.10",
|
||||||
Unknown1: "0",
|
Unknown1: "0",
|
||||||
Unknown2: "0",
|
Unknown2: "0",
|
||||||
|
Unknown3: "",
|
||||||
IsUnavailable: false,
|
IsUnavailable: false,
|
||||||
Message1: "",
|
Message1: "",
|
||||||
Message2: "",
|
Message2: "",
|
||||||
@@ -132,14 +132,32 @@ func TestAvailabilityAttr(t *testing.T) {
|
|||||||
NewPositionFromString("/usr/include/AvailabilityInternal.h:14571:88, col:124"),
|
NewPositionFromString("/usr/include/AvailabilityInternal.h:14571:88, col:124"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7f9bd588b1a8 </usr/include/gethostuuid.h:39:65, col:100> Inherited macos 10.5 0 0 "" ""`:
|
`0x7f9bd588b1a8 </usr/include/gethostuuid.h:39:65, col:100> Inherited macos 10.5 0 0 "" ""`: testNode{&AvailabilityAttr{
|
||||||
testNode{&AvailabilityAttr{
|
|
||||||
Addr: 0x7f9bd588b1a8,
|
Addr: 0x7f9bd588b1a8,
|
||||||
Pos: NewPositionFromString("/usr/include/gethostuuid.h:39:65, col:100"),
|
Pos: NewPositionFromString("/usr/include/gethostuuid.h:39:65, col:100"),
|
||||||
OS: "macos",
|
OS: "macos",
|
||||||
Version: "10.5",
|
Version: "10.5",
|
||||||
Unknown1: "0",
|
Unknown1: "0",
|
||||||
Unknown2: "0",
|
Unknown2: "0",
|
||||||
|
Unknown3: "",
|
||||||
|
IsUnavailable: false,
|
||||||
|
Message1: "",
|
||||||
|
Message2: "",
|
||||||
|
IsInherited: true,
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
},
|
||||||
|
0x7f9bd588b1a8,
|
||||||
|
NewPositionFromString("/usr/include/gethostuuid.h:39:65, col:100"),
|
||||||
|
[]Node{},
|
||||||
|
},
|
||||||
|
`0x7f9bd588b1a8 </usr/include/gethostuuid.h:39:65, col:100> Inherited macos 10.5 0 0 "" "" 1`: testNode{&AvailabilityAttr{
|
||||||
|
Addr: 0x7f9bd588b1a8,
|
||||||
|
Pos: NewPositionFromString("/usr/include/gethostuuid.h:39:65, col:100"),
|
||||||
|
OS: "macos",
|
||||||
|
Version: "10.5",
|
||||||
|
Unknown1: "0",
|
||||||
|
Unknown2: "0",
|
||||||
|
Unknown3: "1",
|
||||||
IsUnavailable: false,
|
IsUnavailable: false,
|
||||||
Message1: "",
|
Message1: "",
|
||||||
Message2: "",
|
Message2: "",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestBinaryOperator(t *testing.T) {
|
func TestBinaryOperator(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fca2d8070e0 <col:11, col:23> 'unsigned char' '='`:
|
`0x7fca2d8070e0 <col:11, col:23> 'unsigned char' '='`: testNode{&BinaryOperator{
|
||||||
testNode{&BinaryOperator{
|
|
||||||
Addr: 0x7fca2d8070e0,
|
Addr: 0x7fca2d8070e0,
|
||||||
Pos: NewPositionFromString("col:11, col:23"),
|
Pos: NewPositionFromString("col:11, col:23"),
|
||||||
Type: "unsigned char",
|
Type: "unsigned char",
|
||||||
@@ -18,8 +17,7 @@ func TestBinaryOperator(t *testing.T) {
|
|||||||
NewPositionFromString("col:11, col:23"),
|
NewPositionFromString("col:11, col:23"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x1ff95b8 <line:78:2, col:7> 'T_ENUM':'T_ENUM' '='`:
|
`0x1ff95b8 <line:78:2, col:7> 'T_ENUM':'T_ENUM' '='`: testNode{&BinaryOperator{
|
||||||
testNode{&BinaryOperator{
|
|
||||||
Addr: 0x1ff95b8,
|
Addr: 0x1ff95b8,
|
||||||
Pos: NewPositionFromString("line:78:2, col:7"),
|
Pos: NewPositionFromString("line:78:2, col:7"),
|
||||||
Type: "T_ENUM",
|
Type: "T_ENUM",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestBlockCommandComment(t *testing.T) {
|
func TestBlockCommandComment(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x1069fae60 <col:4, line:163:57> Name="abstract"`:
|
`0x1069fae60 <col:4, line:163:57> Name="abstract"`: testNode{&BlockCommandComment{
|
||||||
testNode{&BlockCommandComment{
|
|
||||||
Addr: 0x1069fae60,
|
Addr: 0x1069fae60,
|
||||||
Pos: NewPositionFromString("col:4, line:163:57"),
|
Pos: NewPositionFromString("col:4, line:163:57"),
|
||||||
Name: "abstract",
|
Name: "abstract",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestBlockPointerType(t *testing.T) {
|
func TestBlockPointerType(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fa3b88bbb30 'void (^)(void)'`:
|
`0x7fa3b88bbb30 'void (^)(void)'`: testNode{&BlockPointerType{
|
||||||
testNode{&BlockPointerType{
|
|
||||||
Addr: 0x7fa3b88bbb30,
|
Addr: 0x7fa3b88bbb30,
|
||||||
Type: `void (^)(void)`,
|
Type: `void (^)(void)`,
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
@@ -16,8 +15,7 @@ func TestBlockPointerType(t *testing.T) {
|
|||||||
NewPositionFromString(""),
|
NewPositionFromString(""),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fa3b88bbb30 'NSComparisonResult (^)(id _Nonnull, id _Nonnull)'`:
|
`0x7fa3b88bbb30 'NSComparisonResult (^)(id _Nonnull, id _Nonnull)'`: testNode{&BlockPointerType{
|
||||||
testNode{&BlockPointerType{
|
|
||||||
Addr: 0x7fa3b88bbb30,
|
Addr: 0x7fa3b88bbb30,
|
||||||
Type: `NSComparisonResult (^)(id _Nonnull, id _Nonnull)`,
|
Type: `NSComparisonResult (^)(id _Nonnull, id _Nonnull)`,
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestBreakStmt(t *testing.T) {
|
func TestBreakStmt(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fca2d8070e0 <col:11, col:23>`:
|
`0x7fca2d8070e0 <col:11, col:23>`: testNode{&BreakStmt{
|
||||||
testNode{&BreakStmt{
|
|
||||||
Addr: 0x7fca2d8070e0,
|
Addr: 0x7fca2d8070e0,
|
||||||
Pos: NewPositionFromString("col:11, col:23"),
|
Pos: NewPositionFromString("col:11, col:23"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package ast
|
||||||
|
|
||||||
|
// BuiltinAttr is a type of attribute that is optionally attached to a variable
|
||||||
|
// or struct field definition.
|
||||||
|
type BuiltinAttr struct {
|
||||||
|
Addr Address
|
||||||
|
Pos Position
|
||||||
|
ChildNodes []Node
|
||||||
|
Implicit bool
|
||||||
|
Inherited bool
|
||||||
|
Value string
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseBuiltinAttr(line string) Node {
|
||||||
|
groups := groupsFromRegex(
|
||||||
|
`<(?P<position>.*)>
|
||||||
|
(?P<inherited> Inherited)?
|
||||||
|
(?P<implicit> Implicit)?
|
||||||
|
(?P<value> \d+)?
|
||||||
|
`,
|
||||||
|
line,
|
||||||
|
)
|
||||||
|
if groups == nil {
|
||||||
|
return &Unknown{}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &BuiltinAttr{
|
||||||
|
Addr: ParseAddress(groups["address"]),
|
||||||
|
Pos: NewPositionFromString(groups["position"]),
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
Inherited: len(groups["inherited"]) > 0,
|
||||||
|
Implicit: len(groups["implicit"]) > 0,
|
||||||
|
Value: groups["value"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddChild adds a new child node. Child nodes can then be accessed with the
|
||||||
|
// Children attribute.
|
||||||
|
func (n *BuiltinAttr) AddChild(node Node) {
|
||||||
|
n.ChildNodes = append(n.ChildNodes, node)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Address returns the numeric address of the node. See the documentation for
|
||||||
|
// the Address type for more information.
|
||||||
|
func (n *BuiltinAttr) Address() Address {
|
||||||
|
return n.Addr
|
||||||
|
}
|
||||||
|
|
||||||
|
// Children returns the child nodes. If this node does not have any children or
|
||||||
|
// this node does not support children it will always return an empty slice.
|
||||||
|
func (n *BuiltinAttr) Children() []Node {
|
||||||
|
return n.ChildNodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// Position returns the position in the original source code.
|
||||||
|
func (n *BuiltinAttr) Position() Position {
|
||||||
|
return n.Pos
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package ast
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestBuiltinAttr(t *testing.T) {
|
||||||
|
nodes := map[string]testNode{
|
||||||
|
`0x7fa1488273a0 <line:7:4, line:11:4>`: testNode{&BuiltinAttr{
|
||||||
|
Addr: 0x7fa1488273a0,
|
||||||
|
Pos: NewPositionFromString("line:7:4, line:11:4"),
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
Inherited: false,
|
||||||
|
Implicit: false,
|
||||||
|
},
|
||||||
|
0x7fa1488273a0,
|
||||||
|
NewPositionFromString("line:7:4, line:11:4"),
|
||||||
|
[]Node{},
|
||||||
|
},
|
||||||
|
`0x5605ceaf4b88 <col:12> Implicit`: testNode{&BuiltinAttr{
|
||||||
|
Addr: 0x5605ceaf4b88,
|
||||||
|
Pos: NewPositionFromString("col:12"),
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
Inherited: false,
|
||||||
|
Implicit: true,
|
||||||
|
},
|
||||||
|
0x5605ceaf4b88,
|
||||||
|
NewPositionFromString("col:12"),
|
||||||
|
[]Node{},
|
||||||
|
},
|
||||||
|
`0x4153c50 </usr/include/unistd.h:779:46> Inherited`: testNode{&BuiltinAttr{
|
||||||
|
Addr: 0x4153c50,
|
||||||
|
Pos: NewPositionFromString("/usr/include/unistd.h:779:46"),
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
Inherited: true,
|
||||||
|
Implicit: false,
|
||||||
|
},
|
||||||
|
0x4153c50,
|
||||||
|
NewPositionFromString("/usr/include/unistd.h:779:46"),
|
||||||
|
[]Node{},
|
||||||
|
},
|
||||||
|
`0x1038b8828 <col:20> Inherited Implicit`: testNode{&BuiltinAttr{
|
||||||
|
Addr: 0x1038b8828,
|
||||||
|
Pos: NewPositionFromString("col:20"),
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
Inherited: true,
|
||||||
|
Implicit: true,
|
||||||
|
},
|
||||||
|
0x1038b8828,
|
||||||
|
NewPositionFromString("col:20"),
|
||||||
|
[]Node{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
runNodeTests(t, nodes)
|
||||||
|
}
|
||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestBuiltinType(t *testing.T) {
|
func TestBuiltinType(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f8a43023f40 '__int128'`:
|
`0x7f8a43023f40 '__int128'`: testNode{&BuiltinType{
|
||||||
testNode{&BuiltinType{
|
|
||||||
Addr: 0x7f8a43023f40,
|
Addr: 0x7f8a43023f40,
|
||||||
Type: "__int128",
|
Type: "__int128",
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
@@ -16,8 +15,7 @@ func TestBuiltinType(t *testing.T) {
|
|||||||
NewPositionFromString(""),
|
NewPositionFromString(""),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7f8a43023ea0 'unsigned long long'`:
|
`0x7f8a43023ea0 'unsigned long long'`: testNode{&BuiltinType{
|
||||||
testNode{&BuiltinType{
|
|
||||||
Addr: 0x7f8a43023ea0,
|
Addr: 0x7f8a43023ea0,
|
||||||
Type: "unsigned long long",
|
Type: "unsigned long long",
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestCStyleCastExpr(t *testing.T) {
|
func TestCStyleCastExpr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fddc18fb2e0 <col:50, col:56> 'char' <IntegralCast>`:
|
`0x7fddc18fb2e0 <col:50, col:56> 'char' <IntegralCast>`: testNode{&CStyleCastExpr{
|
||||||
testNode{&CStyleCastExpr{
|
|
||||||
Addr: 0x7fddc18fb2e0,
|
Addr: 0x7fddc18fb2e0,
|
||||||
Pos: NewPositionFromString("col:50, col:56"),
|
Pos: NewPositionFromString("col:50, col:56"),
|
||||||
Type: "char",
|
Type: "char",
|
||||||
@@ -18,8 +17,7 @@ func TestCStyleCastExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:50, col:56"),
|
NewPositionFromString("col:50, col:56"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x2781518 <col:7, col:17> 'T_ENUM':'T_ENUM' <IntegralCast>`:
|
`0x2781518 <col:7, col:17> 'T_ENUM':'T_ENUM' <IntegralCast>`: testNode{&CStyleCastExpr{
|
||||||
testNode{&CStyleCastExpr{
|
|
||||||
Addr: 0x2781518,
|
Addr: 0x2781518,
|
||||||
Pos: NewPositionFromString("col:7, col:17"),
|
Pos: NewPositionFromString("col:7, col:17"),
|
||||||
Type: "T_ENUM",
|
Type: "T_ENUM",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestCallExpr(t *testing.T) {
|
func TestCallExpr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f9bf3033240 <col:11, col:25> 'int'`:
|
`0x7f9bf3033240 <col:11, col:25> 'int'`: testNode{&CallExpr{
|
||||||
testNode{&CallExpr{
|
|
||||||
Addr: 0x7f9bf3033240,
|
Addr: 0x7f9bf3033240,
|
||||||
Pos: NewPositionFromString("col:11, col:25"),
|
Pos: NewPositionFromString("col:11, col:25"),
|
||||||
Type: "int",
|
Type: "int",
|
||||||
@@ -17,8 +16,7 @@ func TestCallExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:11, col:25"),
|
NewPositionFromString("col:11, col:25"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7f9bf3035c20 <line:7:4, col:64> 'int'`:
|
`0x7f9bf3035c20 <line:7:4, col:64> 'int'`: testNode{&CallExpr{
|
||||||
testNode{&CallExpr{
|
|
||||||
Addr: 0x7f9bf3035c20,
|
Addr: 0x7f9bf3035c20,
|
||||||
Pos: NewPositionFromString("line:7:4, col:64"),
|
Pos: NewPositionFromString("line:7:4, col:64"),
|
||||||
Type: "int",
|
Type: "int",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestCaseStmt(t *testing.T) {
|
func TestCaseStmt(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc8b5094688 <line:11:5, line:12:21>`:
|
`0x7fc8b5094688 <line:11:5, line:12:21>`: testNode{&CaseStmt{
|
||||||
testNode{&CaseStmt{
|
|
||||||
Addr: 0x7fc8b5094688,
|
Addr: 0x7fc8b5094688,
|
||||||
Pos: NewPositionFromString("line:11:5, line:12:21"),
|
Pos: NewPositionFromString("line:11:5, line:12:21"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestCFAuditedTransferAttr(t *testing.T) {
|
func TestCFAuditedTransferAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7> content`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7> content`: testNode{&CFAuditedTransferAttr{
|
||||||
testNode{&CFAuditedTransferAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
Content: " content",
|
Content: " content",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestCFConsumedAttr(t *testing.T) {
|
func TestCFConsumedAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7> content`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7> content`: testNode{&CFConsumedAttr{
|
||||||
testNode{&CFConsumedAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
Content: " content",
|
Content: " content",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestCFReturnsNotRetainedAttr(t *testing.T) {
|
func TestCFReturnsNotRetainedAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7>`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7>`: testNode{&CFReturnsNotRetainedAttr{
|
||||||
testNode{&CFReturnsNotRetainedAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestCFReturnsRetainedAttr(t *testing.T) {
|
func TestCFReturnsRetainedAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7>`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7>`: testNode{&CFReturnsRetainedAttr{
|
||||||
testNode{&CFReturnsRetainedAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestCharacterLiteral(t *testing.T) {
|
func TestCharacterLiteral(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f980b858308 <col:62> 'int' 10`:
|
`0x7f980b858308 <col:62> 'int' 10`: testNode{&CharacterLiteral{
|
||||||
testNode{&CharacterLiteral{
|
|
||||||
Addr: 0x7f980b858308,
|
Addr: 0x7f980b858308,
|
||||||
Pos: NewPositionFromString("col:62"),
|
Pos: NewPositionFromString("col:62"),
|
||||||
Type: "int",
|
Type: "int",
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package ast
|
||||||
|
|
||||||
|
// ColdAttr is a type of attribute that is optionally attached to function
|
||||||
|
// declaration.
|
||||||
|
type ColdAttr struct {
|
||||||
|
Addr Address
|
||||||
|
Pos Position
|
||||||
|
ChildNodes []Node
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseColdAttr(line string) Node {
|
||||||
|
groups := groupsFromRegex(
|
||||||
|
"<(?P<position>.*)>",
|
||||||
|
line,
|
||||||
|
)
|
||||||
|
if groups == nil {
|
||||||
|
return &Unknown{}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &ColdAttr{
|
||||||
|
Addr: ParseAddress(groups["address"]),
|
||||||
|
Pos: NewPositionFromString(groups["position"]),
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddChild adds a new child node. Child nodes can then be accessed with the
|
||||||
|
// Children attribute.
|
||||||
|
func (n *ColdAttr) AddChild(node Node) {
|
||||||
|
n.ChildNodes = append(n.ChildNodes, node)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Address returns the numeric address of the node. See the documentation for
|
||||||
|
// the Address type for more information.
|
||||||
|
func (n *ColdAttr) Address() Address {
|
||||||
|
return n.Addr
|
||||||
|
}
|
||||||
|
|
||||||
|
// Children returns the child nodes. If this node does not have any children or
|
||||||
|
// this node does not support children it will always return an empty slice.
|
||||||
|
func (n *ColdAttr) Children() []Node {
|
||||||
|
return n.ChildNodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// Position returns the position in the original source code.
|
||||||
|
func (n *ColdAttr) Position() Position {
|
||||||
|
return n.Pos
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package ast
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestColdAttr(t *testing.T) {
|
||||||
|
nodes := map[string]testNode{
|
||||||
|
`0x7fc8fa094558 <col:107>`: testNode{&ColdAttr{
|
||||||
|
Addr: 0x7fc8fa094558,
|
||||||
|
Pos: NewPositionFromString("col:107"),
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
},
|
||||||
|
0x7fc8fa094558,
|
||||||
|
NewPositionFromString("col:107"),
|
||||||
|
[]Node{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
runNodeTests(t, nodes)
|
||||||
|
}
|
||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestCompoundAssignOperator(t *testing.T) {
|
func TestCompoundAssignOperator(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x2dc5758 <line:5:2, col:7> 'int' '+=' ComputeLHSTy='int' ComputeResultTy='int'`:
|
`0x2dc5758 <line:5:2, col:7> 'int' '+=' ComputeLHSTy='int' ComputeResultTy='int'`: testNode{&CompoundAssignOperator{
|
||||||
testNode{&CompoundAssignOperator{
|
|
||||||
Addr: 0x2dc5758,
|
Addr: 0x2dc5758,
|
||||||
Pos: NewPositionFromString("line:5:2, col:7"),
|
Pos: NewPositionFromString("line:5:2, col:7"),
|
||||||
Type: "int",
|
Type: "int",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestCompoundLiteralExpr(t *testing.T) {
|
func TestCompoundLiteralExpr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x5575acce81f0 <col:21, col:40> 'struct node':'struct node' lvalue`:
|
`0x5575acce81f0 <col:21, col:40> 'struct node':'struct node' lvalue`: testNode{&CompoundLiteralExpr{
|
||||||
testNode{&CompoundLiteralExpr{
|
|
||||||
Addr: 0x5575acce81f0,
|
Addr: 0x5575acce81f0,
|
||||||
Pos: NewPositionFromString("col:21, col:40"),
|
Pos: NewPositionFromString("col:21, col:40"),
|
||||||
Type1: "struct node",
|
Type1: "struct node",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestCompoundStmt(t *testing.T) {
|
func TestCompoundStmt(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fbd0f014f18 <col:54, line:358:1>`:
|
`0x7fbd0f014f18 <col:54, line:358:1>`: testNode{&CompoundStmt{
|
||||||
testNode{&CompoundStmt{
|
|
||||||
Addr: 0x7fbd0f014f18,
|
Addr: 0x7fbd0f014f18,
|
||||||
Pos: NewPositionFromString("col:54, line:358:1"),
|
Pos: NewPositionFromString("col:54, line:358:1"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
@@ -16,8 +15,7 @@ func TestCompoundStmt(t *testing.T) {
|
|||||||
NewPositionFromString("col:54, line:358:1"),
|
NewPositionFromString("col:54, line:358:1"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fbd0f8360b8 <line:4:1, line:13:1>`:
|
`0x7fbd0f8360b8 <line:4:1, line:13:1>`: testNode{&CompoundStmt{
|
||||||
testNode{&CompoundStmt{
|
|
||||||
Addr: 0x7fbd0f8360b8,
|
Addr: 0x7fbd0f8360b8,
|
||||||
Pos: NewPositionFromString("line:4:1, line:13:1"),
|
Pos: NewPositionFromString("line:4:1, line:13:1"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestConditionalOperator(t *testing.T) {
|
func TestConditionalOperator(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc6ae0bc678 <col:6, col:89> 'void'`:
|
`0x7fc6ae0bc678 <col:6, col:89> 'void'`: testNode{&ConditionalOperator{
|
||||||
testNode{&ConditionalOperator{
|
|
||||||
Addr: 0x7fc6ae0bc678,
|
Addr: 0x7fc6ae0bc678,
|
||||||
Pos: NewPositionFromString("col:6, col:89"),
|
Pos: NewPositionFromString("col:6, col:89"),
|
||||||
Type: "void",
|
Type: "void",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestConstAttr(t *testing.T) {
|
func TestConstAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fa3b88bbb38 <line:4:1, line:13:1>foo`:
|
`0x7fa3b88bbb38 <line:4:1, line:13:1>foo`: testNode{&ConstAttr{
|
||||||
testNode{&ConstAttr{
|
|
||||||
Addr: 0x7fa3b88bbb38,
|
Addr: 0x7fa3b88bbb38,
|
||||||
Pos: NewPositionFromString("line:4:1, line:13:1"),
|
Pos: NewPositionFromString("line:4:1, line:13:1"),
|
||||||
Tags: "foo",
|
Tags: "foo",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestConstantArrayType(t *testing.T) {
|
func TestConstantArrayType(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f94ad016a40 'struct __va_list_tag [1]' 1 `:
|
`0x7f94ad016a40 'struct __va_list_tag [1]' 1 `: testNode{&ConstantArrayType{
|
||||||
testNode{&ConstantArrayType{
|
|
||||||
Addr: 0x7f94ad016a40,
|
Addr: 0x7f94ad016a40,
|
||||||
Type: "struct __va_list_tag [1]",
|
Type: "struct __va_list_tag [1]",
|
||||||
Size: 1,
|
Size: 1,
|
||||||
@@ -17,8 +16,7 @@ func TestConstantArrayType(t *testing.T) {
|
|||||||
NewPositionFromString(""),
|
NewPositionFromString(""),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7f8c5f059d20 'char [37]' 37 `:
|
`0x7f8c5f059d20 'char [37]' 37 `: testNode{&ConstantArrayType{
|
||||||
testNode{&ConstantArrayType{
|
|
||||||
Addr: 0x7f8c5f059d20,
|
Addr: 0x7f8c5f059d20,
|
||||||
Type: "char [37]",
|
Type: "char [37]",
|
||||||
Size: 37,
|
Size: 37,
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package ast
|
||||||
|
|
||||||
|
// ConstantExpr is expression.
|
||||||
|
type ConstantExpr struct {
|
||||||
|
Addr Address
|
||||||
|
Pos Position
|
||||||
|
Type string
|
||||||
|
Type2 string
|
||||||
|
Extra string
|
||||||
|
ChildNodes []Node
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseConstantExpr(line string) Node {
|
||||||
|
groups := groupsFromRegex(
|
||||||
|
`<(?P<position>.*)> '(?P<type>[\w ]+)'(:'(?P<type2>[\w ]+)')?( .*)?`,
|
||||||
|
line,
|
||||||
|
)
|
||||||
|
if groups == nil {
|
||||||
|
return &Unknown{}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &ConstantExpr{
|
||||||
|
Addr: ParseAddress(groups["address"]),
|
||||||
|
Pos: NewPositionFromString(groups["position"]),
|
||||||
|
Type: groups["type"],
|
||||||
|
Type2: groups["type2"],
|
||||||
|
Extra: groups["extra"],
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddChild adds a new child node. Child nodes can then be accessed with the
|
||||||
|
// Children attribute.
|
||||||
|
func (n *ConstantExpr) AddChild(node Node) {
|
||||||
|
n.ChildNodes = append(n.ChildNodes, node)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Address returns the numeric address of the node. See the documentation for
|
||||||
|
// the Address type for more information.
|
||||||
|
func (n *ConstantExpr) Address() Address {
|
||||||
|
return n.Addr
|
||||||
|
}
|
||||||
|
|
||||||
|
// Children returns the child nodes. If this node does not have any children or
|
||||||
|
// this node does not support children it will always return an empty slice.
|
||||||
|
func (n *ConstantExpr) Children() []Node {
|
||||||
|
return n.ChildNodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// Position returns the position in the original source code.
|
||||||
|
func (n *ConstantExpr) Position() Position {
|
||||||
|
return n.Pos
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package ast
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestConstantExpr(t *testing.T) {
|
||||||
|
nodes := map[string]testNode{
|
||||||
|
`0x7f9bf3033240 <col:11, col:25> 'int'`: testNode{&ConstantExpr{
|
||||||
|
Addr: 0x7f9bf3033240,
|
||||||
|
Pos: NewPositionFromString("col:11, col:25"),
|
||||||
|
Type: "int",
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
},
|
||||||
|
0x7f9bf3033240,
|
||||||
|
NewPositionFromString("col:11, col:25"),
|
||||||
|
[]Node{},
|
||||||
|
},
|
||||||
|
`0x7f9bf3035c20 <line:7:4, col:64> 'int'`: testNode{&ConstantExpr{
|
||||||
|
Addr: 0x7f9bf3035c20,
|
||||||
|
Pos: NewPositionFromString("line:7:4, col:64"),
|
||||||
|
Type: "int",
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
},
|
||||||
|
0x7f9bf3035c20,
|
||||||
|
NewPositionFromString("line:7:4, col:64"),
|
||||||
|
[]Node{},
|
||||||
|
},
|
||||||
|
`0x7f9bf3035c20 <line:7:4, col:64> 'unsigned int'`: testNode{&ConstantExpr{
|
||||||
|
Addr: 0x7f9bf3035c20,
|
||||||
|
Pos: NewPositionFromString("line:7:4, col:64"),
|
||||||
|
Type: "unsigned int",
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
},
|
||||||
|
0x7f9bf3035c20,
|
||||||
|
NewPositionFromString("line:7:4, col:64"),
|
||||||
|
[]Node{},
|
||||||
|
},
|
||||||
|
`0x7f9bf3035c20 <line:7:4, col:64> 'NSModalResponse':'long' Int: 1`: testNode{&ConstantExpr{
|
||||||
|
Addr: 0x7f9bf3035c20,
|
||||||
|
Pos: NewPositionFromString("line:7:4, col:64"),
|
||||||
|
Type: "NSModalResponse",
|
||||||
|
Type2: "long",
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
},
|
||||||
|
0x7f9bf3035c20,
|
||||||
|
NewPositionFromString("line:7:4, col:64"),
|
||||||
|
[]Node{},
|
||||||
|
},
|
||||||
|
`0x7f9bf3035c20 <line:7:4, col:64> 'NSModalResponse':'unsigned long' Int: 1`: testNode{&ConstantExpr{
|
||||||
|
Addr: 0x7f9bf3035c20,
|
||||||
|
Pos: NewPositionFromString("line:7:4, col:64"),
|
||||||
|
Type: "NSModalResponse",
|
||||||
|
Type2: "unsigned long",
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
},
|
||||||
|
0x7f9bf3035c20,
|
||||||
|
NewPositionFromString("line:7:4, col:64"),
|
||||||
|
[]Node{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
runNodeTests(t, nodes)
|
||||||
|
}
|
||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestContinueStmt(t *testing.T) {
|
func TestContinueStmt(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x1e044e0 <col:20>`:
|
`0x1e044e0 <col:20>`: testNode{&ContinueStmt{
|
||||||
testNode{&ContinueStmt{
|
|
||||||
Addr: 0x1e044e0,
|
Addr: 0x1e044e0,
|
||||||
Pos: NewPositionFromString("col:20"),
|
Pos: NewPositionFromString("col:20"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestConvertVectorExpr(t *testing.T) {
|
func TestConvertVectorExpr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fdef0862430 <line:120:1, col:16>`:
|
`0x7fdef0862430 <line:120:1, col:16>`: testNode{&ConvertVectorExpr{
|
||||||
testNode{&ConvertVectorExpr{
|
|
||||||
Addr: 0x7fdef0862430,
|
Addr: 0x7fdef0862430,
|
||||||
Pos: NewPositionFromString("line:120:1, col:16"),
|
Pos: NewPositionFromString("line:120:1, col:16"),
|
||||||
Type: "",
|
Type: "",
|
||||||
@@ -18,8 +17,7 @@ func TestConvertVectorExpr(t *testing.T) {
|
|||||||
NewPositionFromString("line:120:1, col:16"),
|
NewPositionFromString("line:120:1, col:16"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x113368318 <line:1354:20, line:1355:70> '__v2df':'__attribute__((__vector_size__(2 * sizeof(double)))) double'`:
|
`0x113368318 <line:1354:20, line:1355:70> '__v2df':'__attribute__((__vector_size__(2 * sizeof(double)))) double'`: testNode{&ConvertVectorExpr{
|
||||||
testNode{&ConvertVectorExpr{
|
|
||||||
Addr: 0x113368318,
|
Addr: 0x113368318,
|
||||||
Pos: NewPositionFromString("line:1354:20, line:1355:70"),
|
Pos: NewPositionFromString("line:1354:20, line:1355:70"),
|
||||||
Type: `__v2df`,
|
Type: `__v2df`,
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestDecayedType(t *testing.T) {
|
func TestDecayedType(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f1234567890 'struct __va_list_tag *' sugar`:
|
`0x7f1234567890 'struct __va_list_tag *' sugar`: testNode{&DecayedType{
|
||||||
testNode{&DecayedType{
|
|
||||||
Addr: 0x7f1234567890,
|
Addr: 0x7f1234567890,
|
||||||
Type: "struct __va_list_tag *",
|
Type: "struct __va_list_tag *",
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestDeclRefExpr(t *testing.T) {
|
func TestDeclRefExpr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc972064460 <col:8> 'FILE *' lvalue ParmVar 0x7fc9720642d0 '_p' 'FILE *'`:
|
`0x7fc972064460 <col:8> 'FILE *' lvalue ParmVar 0x7fc9720642d0 '_p' 'FILE *'`: testNode{&DeclRefExpr{
|
||||||
testNode{&DeclRefExpr{
|
|
||||||
Addr: 0x7fc972064460,
|
Addr: 0x7fc972064460,
|
||||||
Pos: NewPositionFromString("col:8"),
|
Pos: NewPositionFromString("col:8"),
|
||||||
Type: "FILE *",
|
Type: "FILE *",
|
||||||
@@ -24,8 +23,7 @@ func TestDeclRefExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:8"),
|
NewPositionFromString("col:8"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fc97206a958 <col:11> 'int (int, FILE *)' Function 0x7fc972064198 '__swbuf' 'int (int, FILE *)'`:
|
`0x7fc97206a958 <col:11> 'int (int, FILE *)' Function 0x7fc972064198 '__swbuf' 'int (int, FILE *)'`: testNode{&DeclRefExpr{
|
||||||
testNode{&DeclRefExpr{
|
|
||||||
Addr: 0x7fc97206a958,
|
Addr: 0x7fc97206a958,
|
||||||
Pos: NewPositionFromString("col:11"),
|
Pos: NewPositionFromString("col:11"),
|
||||||
Type: "int (int, FILE *)",
|
Type: "int (int, FILE *)",
|
||||||
@@ -42,8 +40,7 @@ func TestDeclRefExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:11"),
|
NewPositionFromString("col:11"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fa36680f170 <col:19> 'struct programming':'struct programming' lvalue Var 0x7fa36680dc20 'variable' 'struct programming':'struct programming'`:
|
`0x7fa36680f170 <col:19> 'struct programming':'struct programming' lvalue Var 0x7fa36680dc20 'variable' 'struct programming':'struct programming'`: testNode{&DeclRefExpr{
|
||||||
testNode{&DeclRefExpr{
|
|
||||||
Addr: 0x7fa36680f170,
|
Addr: 0x7fa36680f170,
|
||||||
Pos: NewPositionFromString("col:19"),
|
Pos: NewPositionFromString("col:19"),
|
||||||
Type: "struct programming",
|
Type: "struct programming",
|
||||||
@@ -60,8 +57,7 @@ func TestDeclRefExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:19"),
|
NewPositionFromString("col:19"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x35cb438 <col:13> 'int' EnumConstant 0x35ca300 'Jan' 'int'`:
|
`0x35cb438 <col:13> 'int' EnumConstant 0x35ca300 'Jan' 'int'`: testNode{&DeclRefExpr{
|
||||||
testNode{&DeclRefExpr{
|
|
||||||
Addr: 0x35cb438,
|
Addr: 0x35cb438,
|
||||||
Pos: NewPositionFromString("col:13"),
|
Pos: NewPositionFromString("col:13"),
|
||||||
Type: "int",
|
Type: "int",
|
||||||
@@ -78,8 +74,7 @@ func TestDeclRefExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:13"),
|
NewPositionFromString("col:13"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x1ff8770 <col:33> 'T_ENUM':'T_ENUM' lvalue Var 0x1ff8600 'cc' 'T_ENUM':'T_ENUM'`:
|
`0x1ff8770 <col:33> 'T_ENUM':'T_ENUM' lvalue Var 0x1ff8600 'cc' 'T_ENUM':'T_ENUM'`: testNode{&DeclRefExpr{
|
||||||
testNode{&DeclRefExpr{
|
|
||||||
Addr: 0x1ff8770,
|
Addr: 0x1ff8770,
|
||||||
Pos: NewPositionFromString("col:33"),
|
Pos: NewPositionFromString("col:33"),
|
||||||
Type: "T_ENUM",
|
Type: "T_ENUM",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestDeclStmt(t *testing.T) {
|
func TestDeclStmt(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fb791846e80 <line:11:4, col:31>`:
|
`0x7fb791846e80 <line:11:4, col:31>`: testNode{&DeclStmt{
|
||||||
testNode{&DeclStmt{
|
|
||||||
Addr: 0x7fb791846e80,
|
Addr: 0x7fb791846e80,
|
||||||
Pos: NewPositionFromString("line:11:4, col:31"),
|
Pos: NewPositionFromString("line:11:4, col:31"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestDefaultStmt(t *testing.T) {
|
func TestDefaultStmt(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f951308bfb0 <line:17:5, line:18:34>`:
|
`0x7f951308bfb0 <line:17:5, line:18:34>`: testNode{&DefaultStmt{
|
||||||
testNode{&DefaultStmt{
|
|
||||||
Addr: 0x7f951308bfb0,
|
Addr: 0x7f951308bfb0,
|
||||||
Pos: NewPositionFromString("line:17:5, line:18:34"),
|
Pos: NewPositionFromString("line:17:5, line:18:34"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestDeprecatedAttr(t *testing.T) {
|
func TestDeprecatedAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fec4b0ab9c0 <line:180:48, col:63> "This function is provided for compatibility reasons only. Due to security concerns inherent in the design of tempnam(3), it is highly recommended that you use mkstemp(3) instead." ""`:
|
`0x7fec4b0ab9c0 <line:180:48, col:63> "This function is provided for compatibility reasons only. Due to security concerns inherent in the design of tempnam(3), it is highly recommended that you use mkstemp(3) instead." ""`: testNode{&DeprecatedAttr{
|
||||||
testNode{&DeprecatedAttr{
|
|
||||||
Addr: 0x7fec4b0ab9c0,
|
Addr: 0x7fec4b0ab9c0,
|
||||||
Pos: NewPositionFromString("line:180:48, col:63"),
|
Pos: NewPositionFromString("line:180:48, col:63"),
|
||||||
Message1: "This function is provided for compatibility reasons only. Due to security concerns inherent in the design of tempnam(3), it is highly recommended that you use mkstemp(3) instead.",
|
Message1: "This function is provided for compatibility reasons only. Due to security concerns inherent in the design of tempnam(3), it is highly recommended that you use mkstemp(3) instead.",
|
||||||
@@ -19,8 +18,7 @@ func TestDeprecatedAttr(t *testing.T) {
|
|||||||
NewPositionFromString("line:180:48, col:63"),
|
NewPositionFromString("line:180:48, col:63"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0xb75d00 <line:1107:12> "This function or variable may be unsafe. Consider using _snwprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details." ""`:
|
`0xb75d00 <line:1107:12> "This function or variable may be unsafe. Consider using _snwprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details." ""`: testNode{&DeprecatedAttr{
|
||||||
testNode{&DeprecatedAttr{
|
|
||||||
Addr: 0xb75d00,
|
Addr: 0xb75d00,
|
||||||
Pos: NewPositionFromString("line:1107:12"),
|
Pos: NewPositionFromString("line:1107:12"),
|
||||||
Message1: "This function or variable may be unsafe. Consider using _snwprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.",
|
Message1: "This function or variable may be unsafe. Consider using _snwprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.",
|
||||||
@@ -32,8 +30,7 @@ func TestDeprecatedAttr(t *testing.T) {
|
|||||||
NewPositionFromString("line:1107:12"),
|
NewPositionFromString("line:1107:12"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0xb75d00 <line:1107:12> Inherited "This function or variable may be unsafe. Consider using _snwprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details." ""`:
|
`0xb75d00 <line:1107:12> Inherited "This function or variable may be unsafe. Consider using _snwprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details." ""`: testNode{&DeprecatedAttr{
|
||||||
testNode{&DeprecatedAttr{
|
|
||||||
Addr: 0xb75d00,
|
Addr: 0xb75d00,
|
||||||
Pos: NewPositionFromString("line:1107:12"),
|
Pos: NewPositionFromString("line:1107:12"),
|
||||||
Message1: "This function or variable may be unsafe. Consider using _snwprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.",
|
Message1: "This function or variable may be unsafe. Consider using _snwprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestDisableTailCallsAttr(t *testing.T) {
|
func TestDisableTailCallsAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc8fa094558 <col:107> `:
|
`0x7fc8fa094558 <col:107> `: testNode{&DisableTailCallsAttr{
|
||||||
testNode{&DisableTailCallsAttr{
|
|
||||||
Addr: 0x7fc8fa094558,
|
Addr: 0x7fc8fa094558,
|
||||||
Pos: NewPositionFromString("col:107"),
|
Pos: NewPositionFromString("col:107"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
+1
-2
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestDoStmt(t *testing.T) {
|
func TestDoStmt(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7ff36d0a0938 <line:11:5, line:14:23>`:
|
`0x7ff36d0a0938 <line:11:5, line:14:23>`: testNode{&DoStmt{
|
||||||
testNode{&DoStmt{
|
|
||||||
Addr: 0x7ff36d0a0938,
|
Addr: 0x7ff36d0a0938,
|
||||||
Pos: NewPositionFromString("line:11:5, line:14:23"),
|
Pos: NewPositionFromString("line:11:5, line:14:23"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestElaboratedType(t *testing.T) {
|
func TestElaboratedType(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f873686c120 'union __mbstate_t' sugar`:
|
`0x7f873686c120 'union __mbstate_t' sugar`: testNode{&ElaboratedType{
|
||||||
testNode{&ElaboratedType{
|
|
||||||
Addr: 0x7f873686c120,
|
Addr: 0x7f873686c120,
|
||||||
Type: "union __mbstate_t",
|
Type: "union __mbstate_t",
|
||||||
Tags: "sugar",
|
Tags: "sugar",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestEmptyDecl(t *testing.T) {
|
func TestEmptyDecl(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x480bec8 <col:13> col:13`:
|
`0x480bec8 <col:13> col:13`: testNode{&EmptyDecl{
|
||||||
testNode{&EmptyDecl{
|
|
||||||
Addr: 0x480bec8,
|
Addr: 0x480bec8,
|
||||||
Pos: NewPositionFromString("col:13"),
|
Pos: NewPositionFromString("col:13"),
|
||||||
Position2: NewPositionFromString("col:13"),
|
Position2: NewPositionFromString("col:13"),
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestEnumConstantDecl(t *testing.T) {
|
func TestEnumConstantDecl(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x1660db0 <line:185:3> __codecvt_noconv 'int'`:
|
`0x1660db0 <line:185:3> __codecvt_noconv 'int'`: testNode{&EnumConstantDecl{
|
||||||
testNode{&EnumConstantDecl{
|
|
||||||
Addr: 0x1660db0,
|
Addr: 0x1660db0,
|
||||||
Pos: NewPositionFromString("line:185:3"),
|
Pos: NewPositionFromString("line:185:3"),
|
||||||
Position2: "",
|
Position2: "",
|
||||||
@@ -20,8 +19,7 @@ func TestEnumConstantDecl(t *testing.T) {
|
|||||||
NewPositionFromString("line:185:3"),
|
NewPositionFromString("line:185:3"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x3c77ba8 <line:59:3, col:65> col:3 referenced _ISalnum 'int'`:
|
`0x3c77ba8 <line:59:3, col:65> col:3 referenced _ISalnum 'int'`: testNode{&EnumConstantDecl{
|
||||||
testNode{&EnumConstantDecl{
|
|
||||||
Addr: 0x3c77ba8,
|
Addr: 0x3c77ba8,
|
||||||
Pos: NewPositionFromString("line:59:3, col:65"),
|
Pos: NewPositionFromString("line:59:3, col:65"),
|
||||||
Position2: "col:3",
|
Position2: "col:3",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestEnumDecl(t *testing.T) {
|
func TestEnumDecl(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x22a6c80 <line:180:1, line:186:1> __codecvt_result`:
|
`0x22a6c80 <line:180:1, line:186:1> __codecvt_result`: testNode{&EnumDecl{
|
||||||
testNode{&EnumDecl{
|
|
||||||
Addr: 0x22a6c80,
|
Addr: 0x22a6c80,
|
||||||
Pos: NewPositionFromString("line:180:1, line:186:1"),
|
Pos: NewPositionFromString("line:180:1, line:186:1"),
|
||||||
Position2: "",
|
Position2: "",
|
||||||
@@ -18,8 +17,7 @@ func TestEnumDecl(t *testing.T) {
|
|||||||
NewPositionFromString("line:180:1, line:186:1"),
|
NewPositionFromString("line:180:1, line:186:1"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x32fb5a0 <enum.c:3:1, col:45> col:6 week`:
|
`0x32fb5a0 <enum.c:3:1, col:45> col:6 week`: testNode{&EnumDecl{
|
||||||
testNode{&EnumDecl{
|
|
||||||
Addr: 0x32fb5a0,
|
Addr: 0x32fb5a0,
|
||||||
Pos: NewPositionFromString("enum.c:3:1, col:45"),
|
Pos: NewPositionFromString("enum.c:3:1, col:45"),
|
||||||
Position2: " col:6",
|
Position2: " col:6",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestEnumExtensibilityAttr(t *testing.T) {
|
func TestEnumExtensibilityAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7> content`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7> content`: testNode{&EnumExtensibilityAttr{
|
||||||
testNode{&EnumExtensibilityAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
Content: " content",
|
Content: " content",
|
||||||
|
|||||||
+1
-2
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestEnum(t *testing.T) {
|
func TestEnum(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f980b858308 'foo'`:
|
`0x7f980b858308 'foo'`: testNode{&Enum{
|
||||||
testNode{&Enum{
|
|
||||||
Addr: 0x7f980b858308,
|
Addr: 0x7f980b858308,
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestEnumType(t *testing.T) {
|
func TestEnumType(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f980b858309 'foo'`:
|
`0x7f980b858309 'foo'`: testNode{&EnumType{
|
||||||
testNode{&EnumType{
|
|
||||||
Addr: 0x7f980b858309,
|
Addr: 0x7f980b858309,
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
+10
-20
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestFieldDecl(t *testing.T) {
|
func TestFieldDecl(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fef510c4848 <line:141:2, col:6> col:6 _ur 'int'`:
|
`0x7fef510c4848 <line:141:2, col:6> col:6 _ur 'int'`: testNode{&FieldDecl{
|
||||||
testNode{&FieldDecl{
|
|
||||||
Addr: 0x7fef510c4848,
|
Addr: 0x7fef510c4848,
|
||||||
Pos: NewPositionFromString("line:141:2, col:6"),
|
Pos: NewPositionFromString("line:141:2, col:6"),
|
||||||
Position2: "col:6",
|
Position2: "col:6",
|
||||||
@@ -22,8 +21,7 @@ func TestFieldDecl(t *testing.T) {
|
|||||||
NewPositionFromString("line:141:2, col:6"),
|
NewPositionFromString("line:141:2, col:6"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fef510c46f8 <line:139:2, col:16> col:16 _ub 'struct __sbuf':'struct __sbuf'`:
|
`0x7fef510c46f8 <line:139:2, col:16> col:16 _ub 'struct __sbuf':'struct __sbuf'`: testNode{&FieldDecl{
|
||||||
testNode{&FieldDecl{
|
|
||||||
Addr: 0x7fef510c46f8,
|
Addr: 0x7fef510c46f8,
|
||||||
Pos: NewPositionFromString("line:139:2, col:16"),
|
Pos: NewPositionFromString("line:139:2, col:16"),
|
||||||
Position2: "col:16",
|
Position2: "col:16",
|
||||||
@@ -38,8 +36,7 @@ func TestFieldDecl(t *testing.T) {
|
|||||||
NewPositionFromString("line:139:2, col:16"),
|
NewPositionFromString("line:139:2, col:16"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fef510c3fe0 <line:134:2, col:19> col:19 _read 'int (* _Nullable)(void *, char *, int)':'int (*)(void *, char *, int)'`:
|
`0x7fef510c3fe0 <line:134:2, col:19> col:19 _read 'int (* _Nullable)(void *, char *, int)':'int (*)(void *, char *, int)'`: testNode{&FieldDecl{
|
||||||
testNode{&FieldDecl{
|
|
||||||
Addr: 0x7fef510c3fe0,
|
Addr: 0x7fef510c3fe0,
|
||||||
Pos: NewPositionFromString("line:134:2, col:19"),
|
Pos: NewPositionFromString("line:134:2, col:19"),
|
||||||
Position2: "col:19",
|
Position2: "col:19",
|
||||||
@@ -54,8 +51,7 @@ func TestFieldDecl(t *testing.T) {
|
|||||||
NewPositionFromString("line:134:2, col:19"),
|
NewPositionFromString("line:134:2, col:19"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fef51073a60 <line:105:2, col:40> col:40 __cleanup_stack 'struct __darwin_pthread_handler_rec *'`:
|
`0x7fef51073a60 <line:105:2, col:40> col:40 __cleanup_stack 'struct __darwin_pthread_handler_rec *'`: testNode{&FieldDecl{
|
||||||
testNode{&FieldDecl{
|
|
||||||
Addr: 0x7fef51073a60,
|
Addr: 0x7fef51073a60,
|
||||||
Pos: NewPositionFromString("line:105:2, col:40"),
|
Pos: NewPositionFromString("line:105:2, col:40"),
|
||||||
Position2: "col:40",
|
Position2: "col:40",
|
||||||
@@ -70,8 +66,7 @@ func TestFieldDecl(t *testing.T) {
|
|||||||
NewPositionFromString("line:105:2, col:40"),
|
NewPositionFromString("line:105:2, col:40"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fef510738e8 <line:100:2, col:43> col:7 __opaque 'char [16]'`:
|
`0x7fef510738e8 <line:100:2, col:43> col:7 __opaque 'char [16]'`: testNode{&FieldDecl{
|
||||||
testNode{&FieldDecl{
|
|
||||||
Addr: 0x7fef510738e8,
|
Addr: 0x7fef510738e8,
|
||||||
Pos: NewPositionFromString("line:100:2, col:43"),
|
Pos: NewPositionFromString("line:100:2, col:43"),
|
||||||
Position2: "col:7",
|
Position2: "col:7",
|
||||||
@@ -86,8 +81,7 @@ func TestFieldDecl(t *testing.T) {
|
|||||||
NewPositionFromString("line:100:2, col:43"),
|
NewPositionFromString("line:100:2, col:43"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fe9f5072268 <line:129:2, col:6> col:6 referenced _lbfsize 'int'`:
|
`0x7fe9f5072268 <line:129:2, col:6> col:6 referenced _lbfsize 'int'`: testNode{&FieldDecl{
|
||||||
testNode{&FieldDecl{
|
|
||||||
Addr: 0x7fe9f5072268,
|
Addr: 0x7fe9f5072268,
|
||||||
Pos: NewPositionFromString("line:129:2, col:6"),
|
Pos: NewPositionFromString("line:129:2, col:6"),
|
||||||
Position2: "col:6",
|
Position2: "col:6",
|
||||||
@@ -102,8 +96,7 @@ func TestFieldDecl(t *testing.T) {
|
|||||||
NewPositionFromString("line:129:2, col:6"),
|
NewPositionFromString("line:129:2, col:6"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7f9bc9083d00 <line:91:5, line:97:8> line:91:5 'unsigned short'`:
|
`0x7f9bc9083d00 <line:91:5, line:97:8> line:91:5 'unsigned short'`: testNode{&FieldDecl{
|
||||||
testNode{&FieldDecl{
|
|
||||||
Addr: 0x7f9bc9083d00,
|
Addr: 0x7f9bc9083d00,
|
||||||
Pos: NewPositionFromString("line:91:5, line:97:8"),
|
Pos: NewPositionFromString("line:91:5, line:97:8"),
|
||||||
Position2: "line:91:5",
|
Position2: "line:91:5",
|
||||||
@@ -118,8 +111,7 @@ func TestFieldDecl(t *testing.T) {
|
|||||||
NewPositionFromString("line:91:5, line:97:8"),
|
NewPositionFromString("line:91:5, line:97:8"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x30363a0 <col:18, col:29> __val 'int [2]'`:
|
`0x30363a0 <col:18, col:29> __val 'int [2]'`: testNode{&FieldDecl{
|
||||||
testNode{&FieldDecl{
|
|
||||||
Addr: 0x30363a0,
|
Addr: 0x30363a0,
|
||||||
Pos: NewPositionFromString("col:18, col:29"),
|
Pos: NewPositionFromString("col:18, col:29"),
|
||||||
Position2: "",
|
Position2: "",
|
||||||
@@ -134,8 +126,7 @@ func TestFieldDecl(t *testing.T) {
|
|||||||
NewPositionFromString("col:18, col:29"),
|
NewPositionFromString("col:18, col:29"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x17aeac0 <line:3:9> col:9 implicit referenced 'struct vec3d_t::(anonymous at main.c:3:9)'`:
|
`0x17aeac0 <line:3:9> col:9 implicit referenced 'struct vec3d_t::(anonymous at main.c:3:9)'`: testNode{&FieldDecl{
|
||||||
testNode{&FieldDecl{
|
|
||||||
Addr: 0x17aeac0,
|
Addr: 0x17aeac0,
|
||||||
Pos: NewPositionFromString("line:3:9"),
|
Pos: NewPositionFromString("line:3:9"),
|
||||||
Position2: "col:9",
|
Position2: "col:9",
|
||||||
@@ -150,8 +141,7 @@ func TestFieldDecl(t *testing.T) {
|
|||||||
NewPositionFromString("line:3:9"),
|
NewPositionFromString("line:3:9"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x56498bf52160 <line:269:5, col:21> col:21 type 'enum __pid_type':'enum __pid_type'`:
|
`0x56498bf52160 <line:269:5, col:21> col:21 type 'enum __pid_type':'enum __pid_type'`: testNode{&FieldDecl{
|
||||||
testNode{&FieldDecl{
|
|
||||||
Addr: 0x56498bf52160,
|
Addr: 0x56498bf52160,
|
||||||
Pos: NewPositionFromString("line:269:5, col:21"),
|
Pos: NewPositionFromString("line:269:5, col:21"),
|
||||||
Position2: "col:21",
|
Position2: "col:21",
|
||||||
|
|||||||
+1
-2
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestField(t *testing.T) {
|
func TestField(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x44159a0 '' 'union sigcontext::(anonymous at /usr/include/x86_64-linux-gnu/bits/sigcontext.h:165:17)'`:
|
`0x44159a0 '' 'union sigcontext::(anonymous at /usr/include/x86_64-linux-gnu/bits/sigcontext.h:165:17)'`: testNode{&Field{
|
||||||
testNode{&Field{
|
|
||||||
Addr: 0x44159a0,
|
Addr: 0x44159a0,
|
||||||
String1: "",
|
String1: "",
|
||||||
String2: "union sigcontext::(anonymous at /usr/include/x86_64-linux-gnu/bits/sigcontext.h:165:17)",
|
String2: "union sigcontext::(anonymous at /usr/include/x86_64-linux-gnu/bits/sigcontext.h:165:17)",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestFlagEnumAttr(t *testing.T) {
|
func TestFlagEnumAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7> content`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7> content`: testNode{&FlagEnumAttr{
|
||||||
testNode{&FlagEnumAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
Content: " content",
|
Content: " content",
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package ast
|
package ast
|
||||||
|
|
||||||
import (
|
import (
|
||||||
//"errors"
|
//"errors"
|
||||||
//"fmt"
|
//"fmt"
|
||||||
//"reflect"
|
//"reflect"
|
||||||
|
|
||||||
//"github.com/elliotchance/c2go/cc"
|
//"github.com/elliotchance/c2go/cc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FloatingLiteral is type of float literal
|
// FloatingLiteral is type of float literal
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestFloatingLiteral(t *testing.T) {
|
func TestFloatingLiteral(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7febe106f5e8 <col:24> 'double' 1.230000e+00`:
|
`0x7febe106f5e8 <col:24> 'double' 1.230000e+00`: testNode{&FloatingLiteral{
|
||||||
testNode{&FloatingLiteral{
|
|
||||||
Addr: 0x7febe106f5e8,
|
Addr: 0x7febe106f5e8,
|
||||||
Pos: NewPositionFromString("col:24"),
|
Pos: NewPositionFromString("col:24"),
|
||||||
Type: "double",
|
Type: "double",
|
||||||
@@ -18,8 +17,7 @@ func TestFloatingLiteral(t *testing.T) {
|
|||||||
NewPositionFromString("col:24"),
|
NewPositionFromString("col:24"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x21c65b8 <col:41> 'double' 2.718282e+00`:
|
`0x21c65b8 <col:41> 'double' 2.718282e+00`: testNode{&FloatingLiteral{
|
||||||
testNode{&FloatingLiteral{
|
|
||||||
Addr: 0x21c65b8,
|
Addr: 0x21c65b8,
|
||||||
Pos: NewPositionFromString("col:41"),
|
Pos: NewPositionFromString("col:41"),
|
||||||
Type: "double",
|
Type: "double",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestForStmt(t *testing.T) {
|
func TestForStmt(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f961e018848 <line:9:4, line:10:70>`:
|
`0x7f961e018848 <line:9:4, line:10:70>`: testNode{&ForStmt{
|
||||||
testNode{&ForStmt{
|
|
||||||
Addr: 0x7f961e018848,
|
Addr: 0x7f961e018848,
|
||||||
Pos: NewPositionFromString("line:9:4, line:10:70"),
|
Pos: NewPositionFromString("line:9:4, line:10:70"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestFormatArgAttr(t *testing.T) {
|
func TestFormatArgAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f1234567890 <col:47, col:57> 1`:
|
`0x7f1234567890 <col:47, col:57> 1`: testNode{&FormatArgAttr{
|
||||||
testNode{&FormatArgAttr{
|
|
||||||
Addr: 0x7f1234567890,
|
Addr: 0x7f1234567890,
|
||||||
Pos: NewPositionFromString("col:47, col:57"),
|
Pos: NewPositionFromString("col:47, col:57"),
|
||||||
Arg: "1",
|
Arg: "1",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestFormatAttr(t *testing.T) {
|
func TestFormatAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fcc8d8ecee8 <col:6> Implicit printf 2 3`:
|
`0x7fcc8d8ecee8 <col:6> Implicit printf 2 3`: testNode{&FormatAttr{
|
||||||
testNode{&FormatAttr{
|
|
||||||
Addr: 0x7fcc8d8ecee8,
|
Addr: 0x7fcc8d8ecee8,
|
||||||
Pos: NewPositionFromString("col:6"),
|
Pos: NewPositionFromString("col:6"),
|
||||||
Implicit: true,
|
Implicit: true,
|
||||||
@@ -21,8 +20,7 @@ func TestFormatAttr(t *testing.T) {
|
|||||||
NewPositionFromString("col:6"),
|
NewPositionFromString("col:6"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fcc8d8ecff8 </usr/include/sys/cdefs.h:351:18, col:61> printf 2 3`:
|
`0x7fcc8d8ecff8 </usr/include/sys/cdefs.h:351:18, col:61> printf 2 3`: testNode{&FormatAttr{
|
||||||
testNode{&FormatAttr{
|
|
||||||
Addr: 0x7fcc8d8ecff8,
|
Addr: 0x7fcc8d8ecff8,
|
||||||
Pos: NewPositionFromString("/usr/include/sys/cdefs.h:351:18, col:61"),
|
Pos: NewPositionFromString("/usr/include/sys/cdefs.h:351:18, col:61"),
|
||||||
Implicit: false,
|
Implicit: false,
|
||||||
@@ -36,8 +34,7 @@ func TestFormatAttr(t *testing.T) {
|
|||||||
NewPositionFromString("/usr/include/sys/cdefs.h:351:18, col:61"),
|
NewPositionFromString("/usr/include/sys/cdefs.h:351:18, col:61"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x273b4d0 <line:357:12> Inherited printf 2 3`:
|
`0x273b4d0 <line:357:12> Inherited printf 2 3`: testNode{&FormatAttr{
|
||||||
testNode{&FormatAttr{
|
|
||||||
Addr: 0x273b4d0,
|
Addr: 0x273b4d0,
|
||||||
Pos: NewPositionFromString("line:357:12"),
|
Pos: NewPositionFromString("line:357:12"),
|
||||||
Implicit: false,
|
Implicit: false,
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestFullComment(t *testing.T) {
|
func TestFullComment(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x3860920 <line:10176:4, line:10180:45>`:
|
`0x3860920 <line:10176:4, line:10180:45>`: testNode{&FullComment{
|
||||||
testNode{&FullComment{
|
|
||||||
Addr: 0x3860920,
|
Addr: 0x3860920,
|
||||||
Pos: NewPositionFromString("line:10176:4, line:10180:45"),
|
Pos: NewPositionFromString("line:10176:4, line:10180:45"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
+13
-26
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestFunctionDecl(t *testing.T) {
|
func TestFunctionDecl(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fb5a90e60d0 <line:231:1, col:22> col:7 clearerr 'void (FILE *)'`:
|
`0x7fb5a90e60d0 <line:231:1, col:22> col:7 clearerr 'void (FILE *)'`: testNode{&FunctionDecl{
|
||||||
testNode{&FunctionDecl{
|
|
||||||
Addr: 0x7fb5a90e60d0,
|
Addr: 0x7fb5a90e60d0,
|
||||||
Pos: NewPositionFromString("line:231:1, col:22"),
|
Pos: NewPositionFromString("line:231:1, col:22"),
|
||||||
Prev: "",
|
Prev: "",
|
||||||
@@ -27,8 +26,7 @@ func TestFunctionDecl(t *testing.T) {
|
|||||||
NewPositionFromString("line:231:1, col:22"),
|
NewPositionFromString("line:231:1, col:22"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fb5a90e2a50 </usr/include/sys/stdio.h:39:1, /usr/include/AvailabilityInternal.h:21697:126> /usr/include/sys/stdio.h:39:5 renameat 'int (int, const char *, int, const char *)'`:
|
`0x7fb5a90e2a50 </usr/include/sys/stdio.h:39:1, /usr/include/AvailabilityInternal.h:21697:126> /usr/include/sys/stdio.h:39:5 renameat 'int (int, const char *, int, const char *)'`: testNode{&FunctionDecl{
|
||||||
testNode{&FunctionDecl{
|
|
||||||
Addr: 0x7fb5a90e2a50,
|
Addr: 0x7fb5a90e2a50,
|
||||||
Pos: NewPositionFromString("/usr/include/sys/stdio.h:39:1, /usr/include/AvailabilityInternal.h:21697:126"),
|
Pos: NewPositionFromString("/usr/include/sys/stdio.h:39:1, /usr/include/AvailabilityInternal.h:21697:126"),
|
||||||
Prev: "",
|
Prev: "",
|
||||||
@@ -48,8 +46,7 @@ func TestFunctionDecl(t *testing.T) {
|
|||||||
NewPositionFromString("/usr/include/sys/stdio.h:39:1, /usr/include/AvailabilityInternal.h:21697:126"),
|
NewPositionFromString("/usr/include/sys/stdio.h:39:1, /usr/include/AvailabilityInternal.h:21697:126"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fb5a90e9b70 </usr/include/stdio.h:244:6> col:6 implicit fprintf 'int (FILE *, const char *, ...)' extern`:
|
`0x7fb5a90e9b70 </usr/include/stdio.h:244:6> col:6 implicit fprintf 'int (FILE *, const char *, ...)' extern`: testNode{&FunctionDecl{
|
||||||
testNode{&FunctionDecl{
|
|
||||||
Addr: 0x7fb5a90e9b70,
|
Addr: 0x7fb5a90e9b70,
|
||||||
Pos: NewPositionFromString("/usr/include/stdio.h:244:6"),
|
Pos: NewPositionFromString("/usr/include/stdio.h:244:6"),
|
||||||
Prev: "",
|
Prev: "",
|
||||||
@@ -69,8 +66,7 @@ func TestFunctionDecl(t *testing.T) {
|
|||||||
NewPositionFromString("/usr/include/stdio.h:244:6"),
|
NewPositionFromString("/usr/include/stdio.h:244:6"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fb5a90e9d40 prev 0x7fb5a90e9b70 <col:1, /usr/include/sys/cdefs.h:351:63> /usr/include/stdio.h:244:6 fprintf 'int (FILE *, const char *, ...)'`:
|
`0x7fb5a90e9d40 prev 0x7fb5a90e9b70 <col:1, /usr/include/sys/cdefs.h:351:63> /usr/include/stdio.h:244:6 fprintf 'int (FILE *, const char *, ...)'`: testNode{&FunctionDecl{
|
||||||
testNode{&FunctionDecl{
|
|
||||||
Addr: 0x7fb5a90e9d40,
|
Addr: 0x7fb5a90e9d40,
|
||||||
Pos: NewPositionFromString("col:1, /usr/include/sys/cdefs.h:351:63"),
|
Pos: NewPositionFromString("col:1, /usr/include/sys/cdefs.h:351:63"),
|
||||||
Prev: "0x7fb5a90e9b70",
|
Prev: "0x7fb5a90e9b70",
|
||||||
@@ -90,8 +86,7 @@ func TestFunctionDecl(t *testing.T) {
|
|||||||
NewPositionFromString("col:1, /usr/include/sys/cdefs.h:351:63"),
|
NewPositionFromString("col:1, /usr/include/sys/cdefs.h:351:63"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fb5a90ec210 <line:259:6> col:6 implicit used printf 'int (const char *, ...)' extern`:
|
`0x7fb5a90ec210 <line:259:6> col:6 implicit used printf 'int (const char *, ...)' extern`: testNode{&FunctionDecl{
|
||||||
testNode{&FunctionDecl{
|
|
||||||
Addr: 0x7fb5a90ec210,
|
Addr: 0x7fb5a90ec210,
|
||||||
Pos: NewPositionFromString("line:259:6"),
|
Pos: NewPositionFromString("line:259:6"),
|
||||||
Prev: "",
|
Prev: "",
|
||||||
@@ -111,8 +106,7 @@ func TestFunctionDecl(t *testing.T) {
|
|||||||
NewPositionFromString("line:259:6"),
|
NewPositionFromString("line:259:6"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x2ae30d8 </usr/include/math.h:65:3, /usr/include/x86_64-linux-gnu/sys/cdefs.h:57:54> <scratch space>:17:1 __acos 'double (double)' extern`:
|
`0x2ae30d8 </usr/include/math.h:65:3, /usr/include/x86_64-linux-gnu/sys/cdefs.h:57:54> <scratch space>:17:1 __acos 'double (double)' extern`: testNode{&FunctionDecl{
|
||||||
testNode{&FunctionDecl{
|
|
||||||
Addr: 0x2ae30d8,
|
Addr: 0x2ae30d8,
|
||||||
Pos: NewPositionFromString("/usr/include/math.h:65:3, /usr/include/x86_64-linux-gnu/sys/cdefs.h:57:54"),
|
Pos: NewPositionFromString("/usr/include/math.h:65:3, /usr/include/x86_64-linux-gnu/sys/cdefs.h:57:54"),
|
||||||
Prev: "",
|
Prev: "",
|
||||||
@@ -132,8 +126,7 @@ func TestFunctionDecl(t *testing.T) {
|
|||||||
NewPositionFromString("/usr/include/math.h:65:3, /usr/include/x86_64-linux-gnu/sys/cdefs.h:57:54"),
|
NewPositionFromString("/usr/include/math.h:65:3, /usr/include/x86_64-linux-gnu/sys/cdefs.h:57:54"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fc595071500 <line:26:1, line:69:1> line:26:5 referenced main 'int (int, char **)'`:
|
`0x7fc595071500 <line:26:1, line:69:1> line:26:5 referenced main 'int (int, char **)'`: testNode{&FunctionDecl{
|
||||||
testNode{&FunctionDecl{
|
|
||||||
Addr: 0x7fc595071500,
|
Addr: 0x7fc595071500,
|
||||||
Pos: NewPositionFromString("line:26:1, line:69:1"),
|
Pos: NewPositionFromString("line:26:1, line:69:1"),
|
||||||
Prev: "",
|
Prev: "",
|
||||||
@@ -153,8 +146,7 @@ func TestFunctionDecl(t *testing.T) {
|
|||||||
NewPositionFromString("line:26:1, line:69:1"),
|
NewPositionFromString("line:26:1, line:69:1"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x55973a008cb0 <line:93619:1, line:93630:1> line:93619:12 used exprIsConst 'int (Expr *, int, int)' static`:
|
`0x55973a008cb0 <line:93619:1, line:93630:1> line:93619:12 used exprIsConst 'int (Expr *, int, int)' static`: testNode{&FunctionDecl{
|
||||||
testNode{&FunctionDecl{
|
|
||||||
Addr: 0x55973a008cb0,
|
Addr: 0x55973a008cb0,
|
||||||
Pos: NewPositionFromString("line:93619:1, line:93630:1"),
|
Pos: NewPositionFromString("line:93619:1, line:93630:1"),
|
||||||
Prev: "",
|
Prev: "",
|
||||||
@@ -174,8 +166,7 @@ func TestFunctionDecl(t *testing.T) {
|
|||||||
NewPositionFromString("line:93619:1, line:93630:1"),
|
NewPositionFromString("line:93619:1, line:93630:1"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x563ade547cb8 <safe_math.h:13:1, line:25:1> line:14:2 safe_unary_minus_func_int8_t_s 'int8_t (int8_t)':'int8_t (int8_t)' static`:
|
`0x563ade547cb8 <safe_math.h:13:1, line:25:1> line:14:2 safe_unary_minus_func_int8_t_s 'int8_t (int8_t)':'int8_t (int8_t)' static`: testNode{&FunctionDecl{
|
||||||
testNode{&FunctionDecl{
|
|
||||||
Addr: 0x563ade547cb8,
|
Addr: 0x563ade547cb8,
|
||||||
Pos: NewPositionFromString("safe_math.h:13:1, line:25:1"),
|
Pos: NewPositionFromString("safe_math.h:13:1, line:25:1"),
|
||||||
Prev: "",
|
Prev: "",
|
||||||
@@ -195,8 +186,7 @@ func TestFunctionDecl(t *testing.T) {
|
|||||||
NewPositionFromString("safe_math.h:13:1, line:25:1"),
|
NewPositionFromString("safe_math.h:13:1, line:25:1"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x556cac571be0 <tests/asm.c:9:1, line:13:1> line:9:26 sqlite3Hwtime1 'unsigned long (void)' inline`:
|
`0x556cac571be0 <tests/asm.c:9:1, line:13:1> line:9:26 sqlite3Hwtime1 'unsigned long (void)' inline`: testNode{&FunctionDecl{
|
||||||
testNode{&FunctionDecl{
|
|
||||||
Addr: 0x556cac571be0,
|
Addr: 0x556cac571be0,
|
||||||
Pos: NewPositionFromString("tests/asm.c:9:1, line:13:1"),
|
Pos: NewPositionFromString("tests/asm.c:9:1, line:13:1"),
|
||||||
Prev: "",
|
Prev: "",
|
||||||
@@ -216,8 +206,7 @@ func TestFunctionDecl(t *testing.T) {
|
|||||||
NewPositionFromString("tests/asm.c:9:1, line:13:1"),
|
NewPositionFromString("tests/asm.c:9:1, line:13:1"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x21c3da0 <line:8201:1, line:8786:1> line:8201:25 used insertvertex 'enum insertvertexresult (struct mesh *, struct behavior *, vertex, struct otri *, struct osub *, int, int)'`:
|
`0x21c3da0 <line:8201:1, line:8786:1> line:8201:25 used insertvertex 'enum insertvertexresult (struct mesh *, struct behavior *, vertex, struct otri *, struct osub *, int, int)'`: testNode{&FunctionDecl{
|
||||||
testNode{&FunctionDecl{
|
|
||||||
Addr: 0x21c3da0,
|
Addr: 0x21c3da0,
|
||||||
Pos: NewPositionFromString("line:8201:1, line:8786:1"),
|
Pos: NewPositionFromString("line:8201:1, line:8786:1"),
|
||||||
Prev: "",
|
Prev: "",
|
||||||
@@ -237,8 +226,7 @@ func TestFunctionDecl(t *testing.T) {
|
|||||||
NewPositionFromString("line:8201:1, line:8786:1"),
|
NewPositionFromString("line:8201:1, line:8786:1"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x30bdba8 parent 0x304fbb0 <col:3, col:38> col:30 used getinfo 'enum countries ()'`:
|
`0x30bdba8 parent 0x304fbb0 <col:3, col:38> col:30 used getinfo 'enum countries ()'`: testNode{&FunctionDecl{
|
||||||
testNode{&FunctionDecl{
|
|
||||||
Addr: 0x30bdba8,
|
Addr: 0x30bdba8,
|
||||||
Pos: NewPositionFromString("col:3, col:38"),
|
Pos: NewPositionFromString("col:3, col:38"),
|
||||||
Prev: "",
|
Prev: "",
|
||||||
@@ -259,8 +247,7 @@ func TestFunctionDecl(t *testing.T) {
|
|||||||
NewPositionFromString("col:3, col:38"),
|
NewPositionFromString("col:3, col:38"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x353d3b8 parent 0x31e9ba0 prev 0x33b0810 <col:2, col:30> col:22 used dmatrix 'double **(long, long, long, long)'`:
|
`0x353d3b8 parent 0x31e9ba0 prev 0x33b0810 <col:2, col:30> col:22 used dmatrix 'double **(long, long, long, long)'`: testNode{&FunctionDecl{
|
||||||
testNode{&FunctionDecl{
|
|
||||||
Addr: 0x353d3b8,
|
Addr: 0x353d3b8,
|
||||||
Pos: NewPositionFromString("col:2, col:30"),
|
Pos: NewPositionFromString("col:2, col:30"),
|
||||||
Prev: "0x33b0810",
|
Prev: "0x33b0810",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestFunctionProtoType(t *testing.T) {
|
func TestFunctionProtoType(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fa3b88bbb30 'struct _opaque_pthread_t *' foo`:
|
`0x7fa3b88bbb30 'struct _opaque_pthread_t *' foo`: testNode{&FunctionProtoType{
|
||||||
testNode{&FunctionProtoType{
|
|
||||||
Addr: 0x7fa3b88bbb30,
|
Addr: 0x7fa3b88bbb30,
|
||||||
Type: "struct _opaque_pthread_t *",
|
Type: "struct _opaque_pthread_t *",
|
||||||
Kind: "foo",
|
Kind: "foo",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestGCCAsmStmtStmt(t *testing.T) {
|
func TestGCCAsmStmtStmt(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fad830c9e38 <line:13:5, col:57>`:
|
`0x7fad830c9e38 <line:13:5, col:57>`: testNode{&GCCAsmStmt{
|
||||||
testNode{&GCCAsmStmt{
|
|
||||||
Addr: 0x7fad830c9e38,
|
Addr: 0x7fad830c9e38,
|
||||||
Pos: NewPositionFromString("line:13:5, col:57"),
|
Pos: NewPositionFromString("line:13:5, col:57"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
+1
-2
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestGotoStmt(t *testing.T) {
|
func TestGotoStmt(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fb9cc1994d8 <line:18893:9, col:14> 'end_getDigits' 0x7fb9cc199490`:
|
`0x7fb9cc1994d8 <line:18893:9, col:14> 'end_getDigits' 0x7fb9cc199490`: testNode{&GotoStmt{
|
||||||
testNode{&GotoStmt{
|
|
||||||
Addr: 0x7fb9cc1994d8,
|
Addr: 0x7fb9cc1994d8,
|
||||||
Pos: NewPositionFromString("line:18893:9, col:14"),
|
Pos: NewPositionFromString("line:18893:9, col:14"),
|
||||||
Name: "end_getDigits",
|
Name: "end_getDigits",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestHTMLEndTagComment(t *testing.T) {
|
func TestHTMLEndTagComment(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x4259670 <col:27, col:30> Name="i"`:
|
`0x4259670 <col:27, col:30> Name="i"`: testNode{&HTMLEndTagComment{
|
||||||
testNode{&HTMLEndTagComment{
|
|
||||||
Addr: 0x4259670,
|
Addr: 0x4259670,
|
||||||
Pos: NewPositionFromString("col:27, col:30"),
|
Pos: NewPositionFromString("col:27, col:30"),
|
||||||
Name: "i",
|
Name: "i",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestHTMLStartTagComment(t *testing.T) {
|
func TestHTMLStartTagComment(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x4259670 <col:27, col:30> Name="i"`:
|
`0x4259670 <col:27, col:30> Name="i"`: testNode{&HTMLStartTagComment{
|
||||||
testNode{&HTMLStartTagComment{
|
|
||||||
Addr: 0x4259670,
|
Addr: 0x4259670,
|
||||||
Pos: NewPositionFromString("col:27, col:30"),
|
Pos: NewPositionFromString("col:27, col:30"),
|
||||||
Name: "i",
|
Name: "i",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestIBActionAttr(t *testing.T) {
|
func TestIBActionAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7>`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7>`: testNode{&IBActionAttr{
|
||||||
testNode{&IBActionAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestIBOutletAttr(t *testing.T) {
|
func TestIBOutletAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7>`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7>`: testNode{&IBOutletAttr{
|
||||||
testNode{&IBOutletAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
+3
-1
@@ -4,12 +4,13 @@ package ast
|
|||||||
type IfStmt struct {
|
type IfStmt struct {
|
||||||
Addr Address
|
Addr Address
|
||||||
Pos Position
|
Pos Position
|
||||||
|
HasElse bool
|
||||||
ChildNodes []Node
|
ChildNodes []Node
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseIfStmt(line string) Node {
|
func parseIfStmt(line string) Node {
|
||||||
groups := groupsFromRegex(
|
groups := groupsFromRegex(
|
||||||
"<(?P<position>.*)>",
|
"<(?P<position>.*)>(?P<has_else> has_else)?",
|
||||||
line,
|
line,
|
||||||
)
|
)
|
||||||
if groups == nil {
|
if groups == nil {
|
||||||
@@ -19,6 +20,7 @@ func parseIfStmt(line string) Node {
|
|||||||
return &IfStmt{
|
return &IfStmt{
|
||||||
Addr: ParseAddress(groups["address"]),
|
Addr: ParseAddress(groups["address"]),
|
||||||
Pos: NewPositionFromString(groups["position"]),
|
Pos: NewPositionFromString(groups["position"]),
|
||||||
|
HasElse: len(groups["has_else"]) > 0,
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-2
@@ -6,9 +6,19 @@ import (
|
|||||||
|
|
||||||
func TestIfStmt(t *testing.T) {
|
func TestIfStmt(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d0 <line:11:7, line:18:7>`:
|
`0x7fc0a69091d0 <line:11:7, line:18:7>`: testNode{&IfStmt{
|
||||||
testNode{&IfStmt{
|
|
||||||
Addr: 0x7fc0a69091d0,
|
Addr: 0x7fc0a69091d0,
|
||||||
|
HasElse: false,
|
||||||
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
|
ChildNodes: []Node{},
|
||||||
|
},
|
||||||
|
0x7fc0a69091d0,
|
||||||
|
NewPositionFromString("line:11:7, line:18:7"),
|
||||||
|
[]Node{},
|
||||||
|
},
|
||||||
|
`0x7fc0a69091d0 <line:11:7, line:18:7> has_else`: testNode{&IfStmt{
|
||||||
|
Addr: 0x7fc0a69091d0,
|
||||||
|
HasElse: true,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestImplicitCastExpr(t *testing.T) {
|
func TestImplicitCastExpr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f9f5b0a1288 <col:8> 'FILE *' <LValueToRValue>`:
|
`0x7f9f5b0a1288 <col:8> 'FILE *' <LValueToRValue>`: testNode{&ImplicitCastExpr{
|
||||||
testNode{&ImplicitCastExpr{
|
|
||||||
Addr: 0x7f9f5b0a1288,
|
Addr: 0x7f9f5b0a1288,
|
||||||
Pos: NewPositionFromString("col:8"),
|
Pos: NewPositionFromString("col:8"),
|
||||||
Type: "FILE *",
|
Type: "FILE *",
|
||||||
@@ -18,8 +17,7 @@ func TestImplicitCastExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:8"),
|
NewPositionFromString("col:8"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7f9f5b0a7828 <col:11> 'int (*)(int, FILE *)' <FunctionToPointerDecay>`:
|
`0x7f9f5b0a7828 <col:11> 'int (*)(int, FILE *)' <FunctionToPointerDecay>`: testNode{&ImplicitCastExpr{
|
||||||
testNode{&ImplicitCastExpr{
|
|
||||||
Addr: 0x7f9f5b0a7828,
|
Addr: 0x7f9f5b0a7828,
|
||||||
Pos: NewPositionFromString("col:11"),
|
Pos: NewPositionFromString("col:11"),
|
||||||
Type: "int (*)(int, FILE *)",
|
Type: "int (*)(int, FILE *)",
|
||||||
@@ -30,8 +28,7 @@ func TestImplicitCastExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:11"),
|
NewPositionFromString("col:11"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x21267c8 <col:8> 'enum week1':'enum week2' <IntegralCast>`:
|
`0x21267c8 <col:8> 'enum week1':'enum week2' <IntegralCast>`: testNode{&ImplicitCastExpr{
|
||||||
testNode{&ImplicitCastExpr{
|
|
||||||
Addr: 0x21267c8,
|
Addr: 0x21267c8,
|
||||||
Pos: NewPositionFromString("col:8"),
|
Pos: NewPositionFromString("col:8"),
|
||||||
Type: "enum week1",
|
Type: "enum week1",
|
||||||
@@ -43,8 +40,7 @@ func TestImplicitCastExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:8"),
|
NewPositionFromString("col:8"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x26fd2d8 <col:20, col:32> 'extCoord':'extCoord' <LValueToRValue>`:
|
`0x26fd2d8 <col:20, col:32> 'extCoord':'extCoord' <LValueToRValue>`: testNode{&ImplicitCastExpr{
|
||||||
testNode{&ImplicitCastExpr{
|
|
||||||
Addr: 0x26fd2d8,
|
Addr: 0x26fd2d8,
|
||||||
Pos: NewPositionFromString("col:20, col:32"),
|
Pos: NewPositionFromString("col:20, col:32"),
|
||||||
Type: "extCoord",
|
Type: "extCoord",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestImplicitValueInitExpr(t *testing.T) {
|
func TestImplicitValueInitExpr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f8c3396fbd8 <<invalid sloc>> 'sqlite3StatValueType':'long long'`:
|
`0x7f8c3396fbd8 <<invalid sloc>> 'sqlite3StatValueType':'long long'`: testNode{&ImplicitValueInitExpr{
|
||||||
testNode{&ImplicitValueInitExpr{
|
|
||||||
Addr: 0x7f8c3396fbd8,
|
Addr: 0x7f8c3396fbd8,
|
||||||
Pos: NewPositionFromString("<invalid sloc>"),
|
Pos: NewPositionFromString("<invalid sloc>"),
|
||||||
Type1: "sqlite3StatValueType",
|
Type1: "sqlite3StatValueType",
|
||||||
@@ -18,8 +17,7 @@ func TestImplicitValueInitExpr(t *testing.T) {
|
|||||||
NewPositionFromString("<invalid sloc>"),
|
NewPositionFromString("<invalid sloc>"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7feecb0d6af0 <<invalid sloc>> 'char'`:
|
`0x7feecb0d6af0 <<invalid sloc>> 'char'`: testNode{&ImplicitValueInitExpr{
|
||||||
testNode{&ImplicitValueInitExpr{
|
|
||||||
Addr: 0x7feecb0d6af0,
|
Addr: 0x7feecb0d6af0,
|
||||||
Pos: NewPositionFromString("<invalid sloc>"),
|
Pos: NewPositionFromString("<invalid sloc>"),
|
||||||
Type1: "char",
|
Type1: "char",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestIncompleteArrayType(t *testing.T) {
|
func TestIncompleteArrayType(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fcb7d005c20 'int []' `:
|
`0x7fcb7d005c20 'int []' `: testNode{&IncompleteArrayType{
|
||||||
testNode{&IncompleteArrayType{
|
|
||||||
Addr: 0x7fcb7d005c20,
|
Addr: 0x7fcb7d005c20,
|
||||||
Type: "int []",
|
Type: "int []",
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestIndirectFieldDecl(t *testing.T) {
|
func TestIndirectFieldDecl(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x2be19a8 <line:167:25> col:25 implicit fpstate 'struct _fpstate *'`:
|
`0x2be19a8 <line:167:25> col:25 implicit fpstate 'struct _fpstate *'`: testNode{&IndirectFieldDecl{
|
||||||
testNode{&IndirectFieldDecl{
|
|
||||||
Addr: 0x2be19a8,
|
Addr: 0x2be19a8,
|
||||||
Pos: NewPositionFromString("line:167:25"),
|
Pos: NewPositionFromString("line:167:25"),
|
||||||
Position2: "col:25",
|
Position2: "col:25",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestInitListExpr(t *testing.T) {
|
func TestInitListExpr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fbdd1906c20 <col:52, line:17160:1> 'const unsigned char [256]'`:
|
`0x7fbdd1906c20 <col:52, line:17160:1> 'const unsigned char [256]'`: testNode{&InitListExpr{
|
||||||
testNode{&InitListExpr{
|
|
||||||
Addr: 0x7fbdd1906c20,
|
Addr: 0x7fbdd1906c20,
|
||||||
Pos: NewPositionFromString("col:52, line:17160:1"),
|
Pos: NewPositionFromString("col:52, line:17160:1"),
|
||||||
Type1: "const unsigned char [256]",
|
Type1: "const unsigned char [256]",
|
||||||
@@ -17,8 +16,7 @@ func TestInitListExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:52, line:17160:1"),
|
NewPositionFromString("col:52, line:17160:1"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x32017f0 <col:24, col:41> 'struct node [2]'`:
|
`0x32017f0 <col:24, col:41> 'struct node [2]'`: testNode{&InitListExpr{
|
||||||
testNode{&InitListExpr{
|
|
||||||
Addr: 0x32017f0,
|
Addr: 0x32017f0,
|
||||||
Pos: NewPositionFromString("col:24, col:41"),
|
Pos: NewPositionFromString("col:24, col:41"),
|
||||||
Type1: "struct node [2]",
|
Type1: "struct node [2]",
|
||||||
@@ -28,8 +26,7 @@ func TestInitListExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:24, col:41"),
|
NewPositionFromString("col:24, col:41"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x3201840 <col:25, col:31> 'struct node':'struct node'`:
|
`0x3201840 <col:25, col:31> 'struct node':'struct node'`: testNode{&InitListExpr{
|
||||||
testNode{&InitListExpr{
|
|
||||||
Addr: 0x3201840,
|
Addr: 0x3201840,
|
||||||
Pos: NewPositionFromString("col:25, col:31"),
|
Pos: NewPositionFromString("col:25, col:31"),
|
||||||
Type1: "struct node",
|
Type1: "struct node",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestInlineCommandComment(t *testing.T) {
|
func TestInlineCommandComment(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x22e3510 <col:2, col:6> Name="NOTE" RenderNormal`:
|
`0x22e3510 <col:2, col:6> Name="NOTE" RenderNormal`: testNode{&InlineCommandComment{
|
||||||
testNode{&InlineCommandComment{
|
|
||||||
Addr: 0x22e3510,
|
Addr: 0x22e3510,
|
||||||
Pos: NewPositionFromString("col:2, col:6"),
|
Pos: NewPositionFromString("col:2, col:6"),
|
||||||
Other: "Name=\"NOTE\" RenderNormal",
|
Other: "Name=\"NOTE\" RenderNormal",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestIntegerLiteral(t *testing.T) {
|
func TestIntegerLiteral(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fbe9804bcc8 <col:14> 'int' 1`:
|
`0x7fbe9804bcc8 <col:14> 'int' 1`: testNode{&IntegerLiteral{
|
||||||
testNode{&IntegerLiteral{
|
|
||||||
Addr: 0x7fbe9804bcc8,
|
Addr: 0x7fbe9804bcc8,
|
||||||
Pos: NewPositionFromString("col:14"),
|
Pos: NewPositionFromString("col:14"),
|
||||||
Type: "int",
|
Type: "int",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestLabelStmt(t *testing.T) {
|
func TestLabelStmt(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fe3ba82edb8 <line:18906:1, line:18907:22> 'end_getDigits'`:
|
`0x7fe3ba82edb8 <line:18906:1, line:18907:22> 'end_getDigits'`: testNode{&LabelStmt{
|
||||||
testNode{&LabelStmt{
|
|
||||||
Addr: 0x7fe3ba82edb8,
|
Addr: 0x7fe3ba82edb8,
|
||||||
Pos: NewPositionFromString("line:18906:1, line:18907:22"),
|
Pos: NewPositionFromString("line:18906:1, line:18907:22"),
|
||||||
Name: "end_getDigits",
|
Name: "end_getDigits",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestMallocAttr(t *testing.T) {
|
func TestMallocAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7>`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7>`: testNode{&MallocAttr{
|
||||||
testNode{&MallocAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestMaxFieldAlignmentAttr(t *testing.T) {
|
func TestMaxFieldAlignmentAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fd4b7063ac0 <<invalid sloc>> Implicit 32`:
|
`0x7fd4b7063ac0 <<invalid sloc>> Implicit 32`: testNode{&MaxFieldAlignmentAttr{
|
||||||
testNode{&MaxFieldAlignmentAttr{
|
|
||||||
Addr: 0x7fd4b7063ac0,
|
Addr: 0x7fd4b7063ac0,
|
||||||
Pos: NewPositionFromString("<invalid sloc>"),
|
Pos: NewPositionFromString("<invalid sloc>"),
|
||||||
Size: 32,
|
Size: 32,
|
||||||
@@ -17,8 +16,7 @@ func TestMaxFieldAlignmentAttr(t *testing.T) {
|
|||||||
NewPositionFromString("<invalid sloc>"),
|
NewPositionFromString("<invalid sloc>"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fd4b7063ac0 <<invalid sloc>> Implicit 8`:
|
`0x7fd4b7063ac0 <<invalid sloc>> Implicit 8`: testNode{&MaxFieldAlignmentAttr{
|
||||||
testNode{&MaxFieldAlignmentAttr{
|
|
||||||
Addr: 0x7fd4b7063ac0,
|
Addr: 0x7fd4b7063ac0,
|
||||||
Pos: NewPositionFromString("<invalid sloc>"),
|
Pos: NewPositionFromString("<invalid sloc>"),
|
||||||
Size: 8,
|
Size: 8,
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestMayAliasAttr(t *testing.T) {
|
func TestMayAliasAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7>`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7>`: testNode{&MayAliasAttr{
|
||||||
testNode{&MayAliasAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
+7
-14
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestMemberExpr(t *testing.T) {
|
func TestMemberExpr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fcc758e34a0 <col:8, col:12> 'int' lvalue ->_w 0x7fcc758d60c8`:
|
`0x7fcc758e34a0 <col:8, col:12> 'int' lvalue ->_w 0x7fcc758d60c8`: testNode{&MemberExpr{
|
||||||
testNode{&MemberExpr{
|
|
||||||
Addr: 0x7fcc758e34a0,
|
Addr: 0x7fcc758e34a0,
|
||||||
Pos: NewPositionFromString("col:8, col:12"),
|
Pos: NewPositionFromString("col:8, col:12"),
|
||||||
Type: "int",
|
Type: "int",
|
||||||
@@ -23,8 +22,7 @@ func TestMemberExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:8, col:12"),
|
NewPositionFromString("col:8, col:12"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fcc76004210 <col:12, col:16> 'unsigned char *' lvalue ->_p 0x7fcc758d6018`:
|
`0x7fcc76004210 <col:12, col:16> 'unsigned char *' lvalue ->_p 0x7fcc758d6018`: testNode{&MemberExpr{
|
||||||
testNode{&MemberExpr{
|
|
||||||
Addr: 0x7fcc76004210,
|
Addr: 0x7fcc76004210,
|
||||||
Pos: NewPositionFromString("col:12, col:16"),
|
Pos: NewPositionFromString("col:12, col:16"),
|
||||||
Type: "unsigned char *",
|
Type: "unsigned char *",
|
||||||
@@ -40,8 +38,7 @@ func TestMemberExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:12, col:16"),
|
NewPositionFromString("col:12, col:16"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7f85338325b0 <col:4, col:13> 'float' lvalue .constant 0x7f8533832260`:
|
`0x7f85338325b0 <col:4, col:13> 'float' lvalue .constant 0x7f8533832260`: testNode{&MemberExpr{
|
||||||
testNode{&MemberExpr{
|
|
||||||
Addr: 0x7f85338325b0,
|
Addr: 0x7f85338325b0,
|
||||||
Pos: NewPositionFromString("col:4, col:13"),
|
Pos: NewPositionFromString("col:4, col:13"),
|
||||||
Type: "float",
|
Type: "float",
|
||||||
@@ -57,8 +54,7 @@ func TestMemberExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:4, col:13"),
|
NewPositionFromString("col:4, col:13"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7f8533832670 <col:4, col:13> 'char *' lvalue .pointer 0x7f85338322b8`:
|
`0x7f8533832670 <col:4, col:13> 'char *' lvalue .pointer 0x7f85338322b8`: testNode{&MemberExpr{
|
||||||
testNode{&MemberExpr{
|
|
||||||
Addr: 0x7f8533832670,
|
Addr: 0x7f8533832670,
|
||||||
Pos: NewPositionFromString("col:4, col:13"),
|
Pos: NewPositionFromString("col:4, col:13"),
|
||||||
Type: "char *",
|
Type: "char *",
|
||||||
@@ -74,8 +70,7 @@ func TestMemberExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:4, col:13"),
|
NewPositionFromString("col:4, col:13"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x7fb7d5a49ac8 <col:3, col:6> 'bft':'unsigned int' lvalue bitfield ->isPrepareV2 0x7fb7d5967f40`:
|
`0x7fb7d5a49ac8 <col:3, col:6> 'bft':'unsigned int' lvalue bitfield ->isPrepareV2 0x7fb7d5967f40`: testNode{&MemberExpr{
|
||||||
testNode{&MemberExpr{
|
|
||||||
Addr: 0x7fb7d5a49ac8,
|
Addr: 0x7fb7d5a49ac8,
|
||||||
Pos: NewPositionFromString("col:3, col:6"),
|
Pos: NewPositionFromString("col:3, col:6"),
|
||||||
Type: "bft",
|
Type: "bft",
|
||||||
@@ -91,8 +86,7 @@ func TestMemberExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:3, col:6"),
|
NewPositionFromString("col:3, col:6"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x2914fb8 <col:12, col:14> 'union vec3d_t::(anonymous at main.c:2:5)' lvalue . 0x2914920`:
|
`0x2914fb8 <col:12, col:14> 'union vec3d_t::(anonymous at main.c:2:5)' lvalue . 0x2914920`: testNode{&MemberExpr{
|
||||||
testNode{&MemberExpr{
|
|
||||||
Addr: 0x2914fb8,
|
Addr: 0x2914fb8,
|
||||||
Pos: NewPositionFromString("col:12, col:14"),
|
Pos: NewPositionFromString("col:12, col:14"),
|
||||||
Type: "union vec3d_t::(anonymous at main.c:2:5)",
|
Type: "union vec3d_t::(anonymous at main.c:2:5)",
|
||||||
@@ -108,8 +102,7 @@ func TestMemberExpr(t *testing.T) {
|
|||||||
NewPositionFromString("col:12, col:14"),
|
NewPositionFromString("col:12, col:14"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x3180ef0 <col:32, col:48> 'int' .n 0x317f450`:
|
`0x3180ef0 <col:32, col:48> 'int' .n 0x317f450`: testNode{&MemberExpr{
|
||||||
testNode{&MemberExpr{
|
|
||||||
Addr: 0x3180ef0,
|
Addr: 0x3180ef0,
|
||||||
Pos: NewPositionFromString("col:32, col:48"),
|
Pos: NewPositionFromString("col:32, col:48"),
|
||||||
Type: "int",
|
Type: "int",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestMinVectorWidthAttr(t *testing.T) {
|
func TestMinVectorWidthAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7> content`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7> content`: testNode{&MinVectorWidthAttr{
|
||||||
testNode{&MinVectorWidthAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
Content: " content",
|
Content: " content",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func Test(t *testing.T) {
|
func Test(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7f980b858309 <line:11:7, line:18:7> foo`:
|
`0x7f980b858309 <line:11:7, line:18:7> foo`: testNode{&ModeAttr{
|
||||||
testNode{&ModeAttr{
|
|
||||||
Addr: 0x7f980b858309,
|
Addr: 0x7f980b858309,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestNoDebugAttr(t *testing.T) {
|
func TestNoDebugAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7>`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7>`: testNode{&NoDebugAttr{
|
||||||
testNode{&NoDebugAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestNoEscapeAttr(t *testing.T) {
|
func TestNoEscapeAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7>`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7>`: testNode{&NoEscapeAttr{
|
||||||
testNode{&NoEscapeAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestNoInlineAttr(t *testing.T) {
|
func TestNoInlineAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc02a8a6730 <line:24619:23>`:
|
`0x7fc02a8a6730 <line:24619:23>`: testNode{&NoInlineAttr{
|
||||||
testNode{&NoInlineAttr{
|
|
||||||
Addr: 0x7fc02a8a6730,
|
Addr: 0x7fc02a8a6730,
|
||||||
Pos: NewPositionFromString("line:24619:23"),
|
Pos: NewPositionFromString("line:24619:23"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestNoThrowAttr(t *testing.T) {
|
func TestNoThrowAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fa1488273a0 <line:7:4, line:11:4>`:
|
`0x7fa1488273a0 <line:7:4, line:11:4>`: testNode{&NoThrowAttr{
|
||||||
testNode{&NoThrowAttr{
|
|
||||||
Addr: 0x7fa1488273a0,
|
Addr: 0x7fa1488273a0,
|
||||||
Pos: NewPositionFromString("line:7:4, line:11:4"),
|
Pos: NewPositionFromString("line:7:4, line:11:4"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
@@ -18,8 +17,7 @@ func TestNoThrowAttr(t *testing.T) {
|
|||||||
NewPositionFromString("line:7:4, line:11:4"),
|
NewPositionFromString("line:7:4, line:11:4"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x5605ceaf4b88 <col:12> Implicit`:
|
`0x5605ceaf4b88 <col:12> Implicit`: testNode{&NoThrowAttr{
|
||||||
testNode{&NoThrowAttr{
|
|
||||||
Addr: 0x5605ceaf4b88,
|
Addr: 0x5605ceaf4b88,
|
||||||
Pos: NewPositionFromString("col:12"),
|
Pos: NewPositionFromString("col:12"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
@@ -30,8 +28,7 @@ func TestNoThrowAttr(t *testing.T) {
|
|||||||
NewPositionFromString("col:12"),
|
NewPositionFromString("col:12"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x4153c50 </usr/include/unistd.h:779:46> Inherited`:
|
`0x4153c50 </usr/include/unistd.h:779:46> Inherited`: testNode{&NoThrowAttr{
|
||||||
testNode{&NoThrowAttr{
|
|
||||||
Addr: 0x4153c50,
|
Addr: 0x4153c50,
|
||||||
Pos: NewPositionFromString("/usr/include/unistd.h:779:46"),
|
Pos: NewPositionFromString("/usr/include/unistd.h:779:46"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
@@ -42,8 +39,7 @@ func TestNoThrowAttr(t *testing.T) {
|
|||||||
NewPositionFromString("/usr/include/unistd.h:779:46"),
|
NewPositionFromString("/usr/include/unistd.h:779:46"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x1038b8828 <col:20> Inherited Implicit`:
|
`0x1038b8828 <col:20> Inherited Implicit`: testNode{&NoThrowAttr{
|
||||||
testNode{&NoThrowAttr{
|
|
||||||
Addr: 0x1038b8828,
|
Addr: 0x1038b8828,
|
||||||
Pos: NewPositionFromString("col:20"),
|
Pos: NewPositionFromString("col:20"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestNonNullAttr(t *testing.T) {
|
func TestNonNullAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fa1488273b0 <line:7:4, line:11:4> 1`:
|
`0x7fa1488273b0 <line:7:4, line:11:4> 1`: testNode{&NonNullAttr{
|
||||||
testNode{&NonNullAttr{
|
|
||||||
Addr: 0x7fa1488273b0,
|
Addr: 0x7fa1488273b0,
|
||||||
Pos: NewPositionFromString("line:7:4, line:11:4"),
|
Pos: NewPositionFromString("line:7:4, line:11:4"),
|
||||||
Inherited: false,
|
Inherited: false,
|
||||||
@@ -21,8 +20,7 @@ func TestNonNullAttr(t *testing.T) {
|
|||||||
NewPositionFromString("line:7:4, line:11:4"),
|
NewPositionFromString("line:7:4, line:11:4"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x2cce280 </sys/cdefs.h:286:44, /bits/mathcalls.h:115:69> 1`:
|
`0x2cce280 </sys/cdefs.h:286:44, /bits/mathcalls.h:115:69> 1`: testNode{&NonNullAttr{
|
||||||
testNode{&NonNullAttr{
|
|
||||||
Addr: 0x2cce280,
|
Addr: 0x2cce280,
|
||||||
Pos: NewPositionFromString("/sys/cdefs.h:286:44, /bits/mathcalls.h:115:69"),
|
Pos: NewPositionFromString("/sys/cdefs.h:286:44, /bits/mathcalls.h:115:69"),
|
||||||
Inherited: false,
|
Inherited: false,
|
||||||
@@ -36,8 +34,7 @@ func TestNonNullAttr(t *testing.T) {
|
|||||||
NewPositionFromString("/sys/cdefs.h:286:44, /bits/mathcalls.h:115:69"),
|
NewPositionFromString("/sys/cdefs.h:286:44, /bits/mathcalls.h:115:69"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x201ede0 <line:145:79, col:93> 0`:
|
`0x201ede0 <line:145:79, col:93> 0`: testNode{&NonNullAttr{
|
||||||
testNode{&NonNullAttr{
|
|
||||||
Addr: 0x201ede0,
|
Addr: 0x201ede0,
|
||||||
Pos: NewPositionFromString("line:145:79, col:93"),
|
Pos: NewPositionFromString("line:145:79, col:93"),
|
||||||
Inherited: false,
|
Inherited: false,
|
||||||
@@ -51,8 +48,7 @@ func TestNonNullAttr(t *testing.T) {
|
|||||||
NewPositionFromString("line:145:79, col:93"),
|
NewPositionFromString("line:145:79, col:93"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x1b89b20 <col:76, col:93> 2 3`:
|
`0x1b89b20 <col:76, col:93> 2 3`: testNode{&NonNullAttr{
|
||||||
testNode{&NonNullAttr{
|
|
||||||
Addr: 0x1b89b20,
|
Addr: 0x1b89b20,
|
||||||
Pos: NewPositionFromString("col:76, col:93"),
|
Pos: NewPositionFromString("col:76, col:93"),
|
||||||
Inherited: false,
|
Inherited: false,
|
||||||
@@ -66,8 +62,7 @@ func TestNonNullAttr(t *testing.T) {
|
|||||||
NewPositionFromString("col:76, col:93"),
|
NewPositionFromString("col:76, col:93"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x55f0219e20d0 <line:717:22, col:42> 0 1 4`:
|
`0x55f0219e20d0 <line:717:22, col:42> 0 1 4`: testNode{&NonNullAttr{
|
||||||
testNode{&NonNullAttr{
|
|
||||||
Addr: 0x55f0219e20d0,
|
Addr: 0x55f0219e20d0,
|
||||||
Pos: NewPositionFromString("line:717:22, col:42"),
|
Pos: NewPositionFromString("line:717:22, col:42"),
|
||||||
Inherited: false,
|
Inherited: false,
|
||||||
@@ -81,8 +76,7 @@ func TestNonNullAttr(t *testing.T) {
|
|||||||
NewPositionFromString("line:717:22, col:42"),
|
NewPositionFromString("line:717:22, col:42"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x248ea60 <line:155:26, col:49> 0 1 2 4`:
|
`0x248ea60 <line:155:26, col:49> 0 1 2 4`: testNode{&NonNullAttr{
|
||||||
testNode{&NonNullAttr{
|
|
||||||
Addr: 0x248ea60,
|
Addr: 0x248ea60,
|
||||||
Pos: NewPositionFromString("line:155:26, col:49"),
|
Pos: NewPositionFromString("line:155:26, col:49"),
|
||||||
Inherited: false,
|
Inherited: false,
|
||||||
@@ -96,8 +90,7 @@ func TestNonNullAttr(t *testing.T) {
|
|||||||
NewPositionFromString("line:155:26, col:49"),
|
NewPositionFromString("line:155:26, col:49"),
|
||||||
[]Node{},
|
[]Node{},
|
||||||
},
|
},
|
||||||
`0x39cf2b0 <col:53> Inherited 0 1`:
|
`0x39cf2b0 <col:53> Inherited 0 1`: testNode{&NonNullAttr{
|
||||||
testNode{&NonNullAttr{
|
|
||||||
Addr: 0x39cf2b0,
|
Addr: 0x39cf2b0,
|
||||||
Pos: NewPositionFromString("col:53"),
|
Pos: NewPositionFromString("col:53"),
|
||||||
Inherited: true,
|
Inherited: true,
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestNotTailCalledAttr(t *testing.T) {
|
func TestNotTailCalledAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc8fa094558 <col:107> `:
|
`0x7fc8fa094558 <col:107> `: testNode{&NotTailCalledAttr{
|
||||||
testNode{&NotTailCalledAttr{
|
|
||||||
Addr: 0x7fc8fa094558,
|
Addr: 0x7fc8fa094558,
|
||||||
Pos: NewPositionFromString("col:107"),
|
Pos: NewPositionFromString("col:107"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestNSConsumedAttr(t *testing.T) {
|
func TestNSConsumedAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7> content`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7> content`: testNode{&NSConsumedAttr{
|
||||||
testNode{&NSConsumedAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
Content: " content",
|
Content: " content",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestNSConsumesSelfAttr(t *testing.T) {
|
func TestNSConsumesSelfAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7>`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7>`: testNode{&NSConsumesSelfAttr{
|
||||||
testNode{&NSConsumesSelfAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
ChildNodes: []Node{},
|
ChildNodes: []Node{},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
|
|
||||||
func TestNSErrorDomainAttr(t *testing.T) {
|
func TestNSErrorDomainAttr(t *testing.T) {
|
||||||
nodes := map[string]testNode{
|
nodes := map[string]testNode{
|
||||||
`0x7fc0a69091d1 <line:11:7, line:18:7> content`:
|
`0x7fc0a69091d1 <line:11:7, line:18:7> content`: testNode{&NSErrorDomainAttr{
|
||||||
testNode{&NSErrorDomainAttr{
|
|
||||||
Addr: 0x7fc0a69091d1,
|
Addr: 0x7fc0a69091d1,
|
||||||
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
Pos: NewPositionFromString("line:11:7, line:18:7"),
|
||||||
Content: " content",
|
Content: " content",
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user